DoctorRole.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Linq;
  2. using System.Threading.Tasks;
  3. using MafiaTelegramBot.Game.GameRooms;
  4. using MafiaTelegramBot.Models;
  5. using MafiaTelegramBot.Resources;
  6. using Telegram.Bot.Types;
  7. namespace MafiaTelegramBot.Game.GameRoles
  8. {
  9. public class DoctorRole : GameRoom.Role
  10. {
  11. public override Roles RoleKey => Roles.Doctor;
  12. public override async Task NightAction()
  13. {
  14. var targets = Room.Players.Values.Where(p => p.IsAlive).ToList();
  15. var message = await Bot.SendWithMarkdown2(Player.ChatId, strings.choose_player_to_heal,
  16. Keyboard.NightChooseTargetKeyboard(targets, Player.Id));
  17. MessageId = message.MessageId;
  18. }
  19. public override async Task ApplyNightActionResult()
  20. {
  21. if (NightTargetId == -1)
  22. await Bot.Get().EditMessageTextAsync(Player.ChatId, MessageId, strings.you_have_not_choosen_target);
  23. else
  24. {
  25. var user = Room.Players[NightTargetId];
  26. var isTargetSaved = true; //TODO when doctor heals mafia target
  27. if(isTargetSaved)
  28. await Bot.Get().EditMessageTextAsync(Player.ChatId, MessageId, $"{strings.you_save_the_target} {user.NickName}");
  29. }
  30. }
  31. public override Task CancelNightActionResult(string message)
  32. {
  33. //TODO why action canceled
  34. return Task.CompletedTask;
  35. }
  36. public override Task<Message> SetNightTarget(long userId)
  37. {
  38. var canHeal = true; //TODO why doctor cant heal
  39. if (canHeal)
  40. {
  41. NightTargetId = userId;
  42. return Bot.Get().EditMessageTextAsync(Player.ChatId, MessageId, $"{strings.you_choose_target} {Room.Players[userId].NickName}");
  43. }
  44. return Bot.SendWithMarkdown2(Player.ChatId, strings.you_cant_heal_this_target);
  45. }
  46. public DoctorRole(GameRoom room, Player player) : base(room, player) { }
  47. }
  48. }