123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System.Linq;
- using System.Threading.Tasks;
- using MafiaTelegramBot.Game.GameRooms;
- using MafiaTelegramBot.Models;
- using MafiaTelegramBot.Resources;
- using User = MafiaTelegramBot.DataBase.Entity.UserEntity;
- namespace MafiaTelegramBot.Game.GameRoles
- {
- public class HookerRole : GameRoom.Role
- {
- public override Roles RoleKey => Roles.Hooker;
- public override async Task NightAction()
- {
- var targets = Room.Players.Values.Where(p => p.IsAlive && p.Id != Player.Id && p.CanBeBlockedNight).ToList();
- if (NightTargetId != -1) Room.Players[NightTargetId].CanBeBlockedNight = true;
- NightTargetId = -1;
- var message = await Bot.SendWithMarkdown2(Player.ChatId, strings.choose_player_to_block_night,
- Keyboard.NightChooseTargetKeyboard(targets, Player.Id));
- MessageId = message.MessageId;
- }
- public override async Task ApplyNightActionResult()
- {
- if(NightTargetId == -1) await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, strings.you_have_not_choosen_target);
- else Room.Players[NightTargetId].IsBlocked = false;
- }
- public override async Task SetNightTarget(long userId)
- {
- if(userId == -1) await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, strings.you_skip_vote);
- else
- {
- NightTargetId = userId;
- var target = Room.Players[userId];
- target.CanBeBlockedNight = false;
- target.IsBlocked = true;
- await target.CurrentRole.CancelNightActionResult(strings.hooker_block_you);
- await Bot.EditMessageAsync(Player.ChatId, MessageId, $"{strings.you_choose_target} {Room.Players[userId].NickName}");
- }
- }
- public override Task Kill()
- {
- if (NightTargetId != -1 && !Room.IsDay)
- {
- var target = Room.Players[NightTargetId];
- if (target.CurrentRole.RoleKey != Roles.Mafia) target.IsAlive = false;
- }
- Player.IsAlive = false;
- return Task.CompletedTask;
- }
- public HookerRole(GameRoom room, Player player) : base(room, player) { }
- }
- }
|