Browse Source

werewolf opening role

zelpold 4 years ago
parent
commit
efed94c595

+ 5 - 0
MafiaTelegramBot/DataBase/Entity/OpenedRolesEntity.cs

@@ -88,5 +88,10 @@ namespace MafiaTelegramBot.DataBase.Entity
         {
             Elder = true;
         }
+
+        public void OpenWerewolf()
+        {
+            Werewolf = true;
+        }
     }
 }

+ 6 - 0
MafiaTelegramBot/Game/GameRooms/GameRoom.GameProcess.cs

@@ -514,6 +514,12 @@ namespace MafiaTelegramBot.Game.GameRooms
                         {
                             if ((player.CurrentRole.ColorRole == 1 || !(player.CurrentRole.RoleKey == Roles.Lawyer)) && player.IsAlive)
                                 UpdateWins(player);
+                            if (player.CurrentRole.RoleKey == Roles.Werewolf)
+                            {
+                                if (player.CurrentRole.ColorRole == 1)
+                                    player.WerewolfRoleAchievementEvent(1);
+                                else player.WerewolfRoleAchievementEvent(2, true);
+                            }
                         }
                         else
                         {

+ 26 - 0
MafiaTelegramBot/Game/Player.cs

@@ -280,6 +280,32 @@ namespace MafiaTelegramBot.Game
             });
         }
 
+        public void WerewolfRoleAchievementEvent(int color, bool reset = false)
+        {
+            Task.Run(async () =>
+            {
+                if (!OpenedRoles.Werewolf)
+                {
+                    if (reset)
+                    {
+                        Achievements.PreviousGameWinColor = 0;
+                    }
+                    else if ((Achievements.PreviousGameWinColor == 1 && color == 2)
+                             || (Achievements.PreviousGameWinColor == 2 && color == 1))
+                    {
+                        await Bot.SendWithMarkdown2(ChatId,
+                            $"{strings.congrats} {roles.Werewolf}! {strings.you_can_use}");
+                        await Bot.SendStickerAsync(ChatId, Stickers.Sticker[Roles.Werewolf.ToString()]);
+                        OpenedRoles.OpenWerewolf();
+                    }
+                    else
+                    {
+                        Achievements.PreviousGameWinColor = color;
+                    }
+                } 
+            });
+        }
+
         public void ParasiteRoleAchievementEvent()
         {
             Task.Run(() =>