using System.Linq; using System.Threading.Tasks; using MafiaTelegramBot.Game.GameRooms; using MafiaTelegramBot.Resources; namespace MafiaTelegramBot.Game.GameRoles { public class NecromancerRole : GameRoom.Role { public override Roles RoleKey => Roles.Necromancer; private bool _actionApplied; public override async Task NightAction() { if (!_actionApplied) { NightTargetList = Room.Players.Values.Where(p => !p.IsAlive).ToList(); var message = await Room.PlayersCh.SendTo(Player.Id, strings.choose_player_to_ressurect, Keyboard.NightChooseTargetKeyboard(NightTargetList, Player.Id, true)); MessageId = message.MessageId; } } public override Task ApplyNightActionResult() { if (NightTargetId is -2 or -1 || !Room.Players.ContainsKey(NightTargetId)) return Task.CompletedTask; _actionApplied = true; Room.Players[NightTargetId].IsAlive = true; return Task.CompletedTask; } public override async Task SetNightTarget(long userId) { if (!Room.Players.ContainsKey(userId)) await Room.PlayersCh.SendTo(Player.Id, strings.this_player_left_from_game); else if (userId != -1) { NightTargetId = userId; if(userId == Player.Id) await Room.PlayersCh.EditTo(Player.Id, MessageId,strings.you_heal_yourself); else await Room.PlayersCh.EditTo(Player.Id, MessageId, $"{strings.you_choose_target} {Room.Players[NightTargetId].NickName}"); } else await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, strings.you_skip_vote); } public NecromancerRole(GameRoom room, Player player) : base(room, player) { } } }