Jelajahi Sumber

mafia self-killing after resurrection bug fix

Tigran 4 tahun lalu
induk
melakukan
9e8d0f0906

+ 1 - 0
MafiaTelegramBot/Game/GameRoles/DameRole.cs

@@ -21,6 +21,7 @@ namespace MafiaTelegramBot.Game.GameRoles
         public override async Task NightAction()
         {
             NightTargetId = -1;
+            MafiaTargetId = -1;
             Player.IsSpeaker = true;
             var alivePlayers = Room.Players.Values.Where(p => p.IsAlive).ToList();
             NightTargetList = alivePlayers.Where(p=> p.CanBeBlockedDay && p.Id != Player.Id).ToList();

+ 1 - 0
MafiaTelegramBot/Game/GameRoles/DonRole.cs

@@ -19,6 +19,7 @@ namespace MafiaTelegramBot.Game.GameRoles
         public override async Task NightAction()
         {
             NightTargetId = -1;
+            MafiaTargetId = -1;
             Player.IsSpeaker = true;
             var alivePlayers = Room.Players.Values.Where(p => p.IsAlive).ToList();
             NightTargetList = alivePlayers.Where(p => p.IsAlive && (!KnownRoles.ContainsKey(p.Id) || Room.IsExtended)).ToList();

+ 3 - 5
MafiaTelegramBot/Game/GameRoles/MafiaRole.cs

@@ -18,6 +18,7 @@ namespace MafiaTelegramBot.Game.GameRoles
         public override async Task NightAction()
         {
             Player.IsSpeaker = true;
+            MafiaTargetId = -1;
             var targets = Room.Players.Values.Where(p => p.IsAlive).ToList();
             var message = await Room.PlayersCh.SendTo(Player.ChatId, strings.choose_player_to_kill, 
                 Keyboard.NightMafiaTargetKeyboard(targets, Player.Id));
@@ -27,11 +28,8 @@ namespace MafiaTelegramBot.Game.GameRoles
         public override async Task ApplyNightActionResult()
         {
             Player.IsSpeaker = false;
-            if (MafiaTargetId != -2)
-            {
-                if (MafiaTargetId == -1) await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, strings.you_have_not_choosen_target);
-                else MafiaTargetId = -1;
-            }
+            if (MafiaTargetId == -1)
+                await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, strings.you_have_not_choosen_target);
         }
 
         public override async Task SetMafiaTarget(long userId)

+ 3 - 6
MafiaTelegramBot/Game/GameRoles/WerewolfRole.cs

@@ -22,6 +22,7 @@ namespace MafiaTelegramBot.Game.GameRoles
             if (IsMafia)
             {
                 Player.IsSpeaker = true;
+                MafiaTargetId = -1;
                 var targets = Room.Players.Values.Where(p => p.IsAlive).ToList();
                 var message = await Room.PlayersCh.SendTo(Player.ChatId, strings.choose_player_to_kill, 
                     Keyboard.NightMafiaTargetKeyboard(targets, Player.Id));
@@ -34,12 +35,8 @@ namespace MafiaTelegramBot.Game.GameRoles
             if (IsMafia)
             {
                 Player.IsSpeaker = false;
-                if (MafiaTargetId != -2)
-                {
-                    if (MafiaTargetId == -1)
-                        await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, strings.you_have_not_choosen_target);
-                    else MafiaTargetId = -1;
-                }
+                if (MafiaTargetId == -1)
+                    await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, strings.you_have_not_choosen_target);
             }
         }