123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- 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 CopRole : GameRoom.Role
- {
- public override Roles RoleKey => Roles.Cop;
- public override async Task NightAction()
- {
- var targets = Room.Players.Values.Except(KnownRoles).Where(p => p.IsAlive).ToList();
- var message = await Bot.SendWithMarkdown2(Player.ChatId, strings.choose_player_to_check_role,
- Keyboards.NightChooseTargetKeyboard(targets, Player.Id));
- MessageId = message.MessageId;
- }
- public override async Task ApplyNightActionResult()
- {
- if (NightTargetId == -1)
- await Bot.Get().EditMessageTextAsync(Player.ChatId, MessageId, strings.you_have_not_choosen_target);
- else
- {
- var user = Room.Players[NightTargetId];
- KnownRoles.Add(user);
- var role = user.GetRole() is Roles.Don or Roles.Mafia
- ? roles.Mafia
- : roles.Villager;
- await Bot.Get().EditMessageTextAsync(Player.ChatId, MessageId, $"{strings.role_of_your_target} {user.NickName} - {role}");
- }
- }
- public override Task<Message> SetNightTarget(long userId)
- {
- NightTargetId = userId;
- return Bot.Get().EditMessageTextAsync(Player.ChatId, MessageId, $"{strings.you_choose_target} {Room.Players[userId].NickName}");
- }
- public CopRole(GameRoom room, Player player) : base(room, player) { }
- }
- }
|