1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- 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 BodyguardRole : GameRoom.Role
- {
- public override Roles RoleKey => Roles.Bodyguard;
- public override async Task NightAction()
- {
- var targets = Room.Players.Values.Where(p => p.IsAlive && p.Id != Player.Id).ToList();
- var message = await Bot.SendWithMarkdown2(Player.ChatId, strings.choose_target_to_protect,
- Keyboard.NightChooseTargetKeyboard(targets, Player.Id, true));
- MessageId = message.MessageId;
- }
- public override async Task ApplyNightActionResult()
- {
-
- if (NightTargetId == -1)
- 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;
- Player.IsAlive = false;
- await Bot.SendWithMarkdown2(Player.ChatId, $"{strings.you_save_player} {target.NickName}");
- await Bot.SendWithMarkdown2(target.ChatId, strings.bodyguard_save_you);
- }
- }
-
- }
- public override async Task SetNightTarget(long userId)
- {
- NightTargetId = userId;
- var target = Room.Players[userId];
- await Bot.SendWithMarkdown2(target.ChatId, strings.bodyguard_protected_you);
- await Bot.EditMessageAsync(Player.ChatId, MessageId, $"{strings.you_choose_target} {Room.Players[userId].NickName}");
- }
- public BodyguardRole(GameRoom room, Player player) : base(room, player) { }
- }
- }
|