using System.Linq; using System.Threading.Tasks; using MafiaTelegramBot.Game.GameRooms; using MafiaTelegramBot.Resources; namespace MafiaTelegramBot.Game.GameRoles { public class MafiaRole : GameRoom.Role { public override Roles RoleKey => Roles.Mafia; private int _color = 2; public override double ColorRole { get => _color; set => _color = (int) value; } public override async Task NightAction() { Player.IsSpeaker = true; var targets = Room.Players.Values.Where(p => p.IsAlive).ToList(); var message = await Room.PlayersCh.SendTo(Player.ChatId, strings.choose_player_to_kill, Keyboard.NightMafiaTargetKeyboard(targets, Player.Id)); MafiaMessageId = message.MessageId; } public override async Task ApplyNightActionResult() { Player.IsSpeaker = false; if (MafiaTargetId != -2) { if (MafiaTargetId == -1) await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, strings.you_have_not_choosen_target); else MafiaTargetId = -1; } } public override async Task SetMafiaTarget(long userId) { if(userId == -1) await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, strings.you_skip_vote); else { if(!Room.Players.ContainsKey(userId)) await Room.PlayersCh.SendTo(Player.Id, strings.this_player_left_from_game); else { MafiaTargetId = userId; await Room.PlayersCh.EditTo(Player.Id, MafiaMessageId, $"{strings.you_choose_target} {Room.Players[userId].NickName}"); } } } public override async Task Kill() { if (Room.PlayersRole.ContainsKey(Roles.Werewolf) && Room.PlayersRole[Roles.Werewolf].Count == 1) await ((WerewolfRole) Room.PlayersRole[Roles.Werewolf][0].CurrentRole).TransformToMafia(); await base.Kill(); } public MafiaRole(GameRoom room, Player player) : base(room, player) { } } }