Browse Source

Merge branch 'develop' of https://gogs.veloe.link/Veloe/MafiaTelegramBot into develop

 Conflicts:
	MafiaTelegramBot/DataBase/Entity/OpenedRolesEntity.cs
zelpold 4 years ago
parent
commit
60eb27f1b5

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

@@ -68,5 +68,10 @@ namespace MafiaTelegramBot.DataBase.Entity
         {
             Journalist = true;
         }
+
+        public void OpenLawyer()
+        {
+            Lawyer = true;
+        }
     }
 }

+ 7 - 1
MafiaTelegramBot/Game/GameRooms/GameRoom.GameProcess.cs

@@ -437,7 +437,7 @@ namespace MafiaTelegramBot.Game.GameRooms
                     var yellowResult = await value[0].CurrentRole.IsWon();
                     if (yellowResult != "") additionalResult += "\n" + yellowResult;
                 }
-
+                
                 if (aliveMafia == 0)
                 {
                     await PlayersCh.Send(strings.villagers_won + additionalResult, exceptDied: false);
@@ -445,6 +445,12 @@ namespace MafiaTelegramBot.Game.GameRooms
                 }
                 else
                 {
+                    if (aliveMafia == 1)
+                    {
+                        var player = Players.Values.FirstOrDefault(p => p.IsAlive && p.GetRole() is Roles.Don or Roles.Dame or Roles.Mafia) ??
+                                     PlayersRole[Roles.Werewolf][0];
+                        player.LawyerRoleAchievementEvent();
+                    }
                     await PlayersCh.Send(strings.mafia_won + additionalResult, exceptDied: false);
                     await PlayersCh.SendSticker(Stickers.Sticker["MafiaWins"]);
                 }

+ 9 - 2
MafiaTelegramBot/Game/Player.cs

@@ -209,11 +209,18 @@ namespace MafiaTelegramBot.Game
 
         public void LawyerRoleAchievementEvent()
         {
-            Task.Run(() =>
+            Task.Run(async() =>
             {
                 if (!OpenedRoles.Lawyer)
                 {
-                    
+                    Achievements.MafiaSoloWins++;
+                    if(Achievements.MafiaSoloWins == 3)
+                    {
+                        await Bot.SendWithMarkdown2(ChatId,
+                            $"{strings.congrats} {roles.Lawyer}! {strings.you_can_use}");
+                        await Bot.SendStickerAsync(ChatId, Stickers.Sticker[Roles.Lawyer.ToString()]);
+                        OpenedRoles.OpenLawyer();
+                    }
                 } 
             });
         }