12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using System.Linq;
- using System.Threading.Tasks;
- using MafiaTelegramBot.Game.GameRooms;
- using MafiaTelegramBot.Models;
- using MafiaTelegramBot.Resources;
- using Telegram.Bot.Types;
- namespace MafiaTelegramBot.Game.GameRoles
- {
- public class DoctorRole : GameRoom.Role
- {
- public override Roles RoleKey => Roles.Doctor;
- private bool _haveTargets = true;
- public override async Task NightAction()
- {
- var targets = Room.Players.Values.Where(p => p.IsAlive && p.CanBeHealed).ToList();
- Message message = null;
- if (targets.Count == 0)
- {
- message = await Bot.SendWithMarkdown2(Player.ChatId, strings.nothing_to_heal);
- _haveTargets = false;
- }
- else message = await Bot.SendWithMarkdown2(Player.ChatId, strings.choose_player_to_heal,
- Keyboard.NightChooseTargetKeyboard(targets, Player.Id));
- MessageId = message.MessageId;
- }
- public override async Task ApplyNightActionResult()
- {
- if (NightTargetId == -1 && _haveTargets)
- await Bot.EditMessageAsync(Player.ChatId, MessageId, strings.you_have_not_choosen_target);
- else
- {
- var target = Room.Players[NightTargetId];
- NightTargetId = -1;
- if (!target.IsAlive)
- {
- target.IsAlive = true;
- target.CanBeHealed = false;
- await Bot.SendWithMarkdown2(Player.ChatId, $"{strings.you_save_player} {target.NickName}");
- await Bot.SendWithMarkdown2(target.ChatId, strings.doctor_save_you);
- }
- }
- }
- public override Task CancelNightActionResult(string message)
- {
- return Task.CompletedTask;
- }
- public override async Task<Message> SetNightTarget(long userId)
- {
- NightTargetId = userId;
- var target = Room.Players[userId];
- await Bot.SendWithMarkdown2(target.ChatId, strings.doctor_heals_you);
- return await Bot.EditMessageAsync(Player.ChatId, MessageId, $"{strings.you_choose_target} {Room.Players[userId].NickName}");
- }
- public DoctorRole(GameRoom room, Player player) : base(room, player) { }
- }
- }
|