NecromancerRole.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Linq;
  2. using System.Threading.Tasks;
  3. using MafiaTelegramBot.Game.GameRooms;
  4. using MafiaTelegramBot.Resources;
  5. namespace MafiaTelegramBot.Game.GameRoles
  6. {
  7. public class NecromancerRole : GameRoom.Role
  8. {
  9. public override Roles RoleKey => Roles.Necromancer;
  10. private bool _actionApplied;
  11. public override async Task NightAction()
  12. {
  13. if (!_actionApplied)
  14. {
  15. NightTargetList = Room.Players.Values.Where(p => !p.IsAlive).ToList();
  16. var message = await Room.PlayersCh.SendTo(Player.Id, strings.choose_player_to_ressurect,
  17. Keyboard.NightChooseTargetKeyboard(NightTargetList, Player.Id, true));
  18. MessageId = message.MessageId;
  19. }
  20. }
  21. public override Task ApplyNightActionResult()
  22. {
  23. if (NightTargetId is -2 or -1 || !Room.Players.ContainsKey(NightTargetId)) return Task.CompletedTask;
  24. _actionApplied = true;
  25. Room.Players[NightTargetId].IsAlive = true;
  26. return Task.CompletedTask;
  27. }
  28. public override async Task SetNightTarget(long userId)
  29. {
  30. if (!Room.Players.ContainsKey(userId)) await Room.PlayersCh.SendTo(Player.Id, strings.this_player_left_from_game);
  31. else if (userId != -1)
  32. {
  33. NightTargetId = userId;
  34. if(userId == Player.Id) await Room.PlayersCh.EditTo(Player.Id, MessageId,strings.you_heal_yourself);
  35. else await Room.PlayersCh.EditTo(Player.Id, MessageId, $"{strings.you_choose_target} {Room.Players[NightTargetId].NickName}");
  36. }
  37. else await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, strings.you_skip_vote);
  38. }
  39. public NecromancerRole(GameRoom room, Player player) : base(room, player) { }
  40. }
  41. }