Browse Source

journalist opening role

zelpold 4 years ago
parent
commit
294de3c5e0

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

@@ -63,5 +63,10 @@ namespace MafiaTelegramBot.DataBase.Entity
         {
             Fool = true;
         }
+
+        public void OpenJournalist()
+        {
+            Journalist = true;
+        }
     }
 }

+ 5 - 0
MafiaTelegramBot/Game/GameRoles/CopRole.cs

@@ -12,6 +12,9 @@ namespace MafiaTelegramBot.Game.GameRoles
 
         private int _color = 1;
 
+        public int CountBlack = 0;
+        public int CountRed = 0;
+
         public override int ColorRole
         {
             get => _color; 
@@ -43,6 +46,8 @@ namespace MafiaTelegramBot.Game.GameRoles
                         : Room.Players[NightTargetId].GetRole() is Roles.Werewolf && ((WerewolfRole) Room.Players[NightTargetId].CurrentRole).IsMafia
                             ? roles.Mafia
                             : roles.Villager;
+                    if (Room.Players[NightTargetId].CurrentRole.ColorRole == 1) CountRed++;
+                    if (Room.Players[NightTargetId].CurrentRole.ColorRole == 2) CountBlack++;
                     if (KnownRoles.ContainsKey(NightTargetId)) KnownRoles[NightTargetId] = role;
                     else KnownRoles.Add(Room.Players[NightTargetId].Id, role);
                     await Room.PlayersCh.EditTo(Player.Id, MessageId,

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

@@ -514,6 +514,12 @@ namespace MafiaTelegramBot.Game.GameRooms
                                 UpdateWins(player);
                         }
                         player.ResetState();
+                        if (player.CurrentRole.RoleKey == Roles.Cop)
+                        {
+                            if (((CopRole) PlayersRole[Roles.Cop][0].CurrentRole).CountRed ==
+                                ((CopRole) PlayersRole[Roles.Cop][0].CurrentRole).CountBlack) player.JournalistAchievementEvent();
+
+                        }
                     }
                     UserDao.DataBase.Statistics.UpdateRange(statsList);
                     UserDao.DataBase.OpenedRoles.UpdateRange(openRolesList);

+ 14 - 0
MafiaTelegramBot/Game/Player.cs

@@ -193,6 +193,20 @@ namespace MafiaTelegramBot.Game
             });
         }
 
+        public void JournalistAchievementEvent()
+        {
+            Task.Run(async() =>
+            {
+                if (!OpenedRoles.Journalist)
+                {
+                    await Bot.SendWithMarkdown2(ChatId,
+                        $"{strings.congrats} {roles.Journalist}! {strings.you_can_use}");
+                    await Bot.SendStickerAsync(ChatId, Stickers.Sticker[Roles.Journalist.ToString()]);
+                    OpenedRoles.OpenJournalist();
+                }
+            });
+        }
+
         public void LawyerRoleAchievementEvent()
         {
             Task.Run(() =>