Browse Source

edit won message

zelpold 4 years ago
parent
commit
f41bdf5256

+ 11 - 4
MafiaTelegramBot/Game/GameRooms/GameRoom.GameProcess.cs

@@ -311,18 +311,25 @@ namespace MafiaTelegramBot.Game.GameRooms
             await Task.Run(async () =>
             {
                 var aliveMafia = Players.Values.Where(p => p.GetRole() is Roles.Don or Roles.Mafia && p.IsAlive).ToList();
+                string additionalResult = "";
+                foreach (var role in PlayersRole)
+                {
+                    if (role.Value.Count() != 1) continue;
+                    string yellowResult = await role.Value[0].CurrentRole.IsWon();
+                    if (yellowResult != "") additionalResult += "\n" + yellowResult;
+                }
+
                 if (aliveMafia.Count == 0)
                 {
-                    await PlayersCh.Send(strings.villagers_won, exceptDied: false);
+                    await PlayersCh.Send(strings.villagers_won + additionalResult, exceptDied: false);
                     await PlayersCh.SendSticker(Stickers.Sticker["VillagerWins"]);
                 }
                 else
                 {
-                    await PlayersCh.Send(strings.mafia_won, exceptDied: false);
+                    await PlayersCh.Send(strings.mafia_won + additionalResult, exceptDied: false);
                     await PlayersCh.SendSticker(Stickers.Sticker["MafiaWins"]);
                 }
-                if (PlayersRole.ContainsKey(Roles.Fool))
-                    PlayersRole[Roles.Fool][0].CurrentRole.IsWon();
+                
                 var rolesMessage = strings.in_this_game_roles;
                 var sortedPLayers = Players.Values.ToList();
                 sortedPLayers.Sort((x, y) => x.TurnOrder - y.TurnOrder);

+ 2 - 2
MafiaTelegramBot/Game/GameRooms/GameRoom.Role.cs

@@ -46,9 +46,9 @@ namespace MafiaTelegramBot.Game.GameRooms
                 await Room.PlayersCh.SendTo(Player.ChatId, message);
             }
 
-            public virtual async Task IsWon()
+            public virtual async Task<string> IsWon()
             {
-                await Room.PlayersCh.SendTo(Player.ChatId, strings.you_won);
+                return await Task.Run(() => "");
             }
             public virtual async Task Dispatch()
             {