1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using System.Linq;
- using System.Threading.Tasks;
- using MafiaTelegramBot.Game.GameRooms;
- using MafiaTelegramBot.Resources;
- namespace MafiaTelegramBot.Game.GameRoles
- {
- public class NecromancerRole : GameRoom.Role
- {
- public override Roles RoleKey => Roles.Necromancer;
- public override int RankingCost { get; } = 25;
- private int _color = 1;
- public override int ColorRole
- {
- get => _color;
- set => _color = (int) value;
- }
- private bool _actionApplied;
- public override async Task NightAction()
- {
- NightTargetId = -1;
- if (Player.IsAlive)
- {
- if (!_actionApplied)
- {
- NightTargetList = Room.Players.Values.Where(p => !p.IsAlive).ToList();
- var message = NightTargetList.Count > 0
- ? await Room.PlayersMessageChannel.SendTo(Player.Info, strings.choose_player_to_ressurect,
- Keyboard.NightChooseTargetKeyboard(NightTargetList, true))
- : await Room.PlayersMessageChannel.SendTo(Player.Info, strings.nothing_to_ressurect);
- MessageId = message.MessageId;
- }
- }
- else NightTargetId = -3;
- }
- public override async Task ApplyNightActionResult()
- {
- if (_actionApplied || NightTargetId == -2) { }
- else if (NightTargetId == -1) await Room.PlayersMessageChannel.EditTo(Player.Info, MessageId, strings.you_have_not_choosen_target);
- else if (NightTargetId != -3)
- {
- _actionApplied = true;
- if(Room.Players.ContainsKey(NightTargetId))
- if (Room.Players[NightTargetId].CurrentRole.RoleKey == Roles.Parasite)
- {
- var parasiteTarget = ((ParasiteRole) Room.PlayersRole[Roles.Parasite][0].CurrentRole).ParentId;
- if (Room.Players[parasiteTarget].IsAlive) Room.Players[NightTargetId].IsAlive = true;
- else
- await Room.PlayersMessageChannel.EditTo(Player.Info, MessageId, strings.player_parasit_with_dead_owner);
- }
- else Room.Players[NightTargetId].IsAlive = true;
- }
- }
- public override async Task SetNightTarget(long userId)
- {
- if (!Room.Players.ContainsKey(userId)) await Room.PlayersMessageChannel.SendTo(Player.Info, strings.this_player_left_from_game);
- else if (userId != -1)
- {
- NightTargetId = userId;
- if(userId == Player.Info.Id) await Room.PlayersMessageChannel.EditTo(Player.Info, MessageId,strings.you_heal_yourself);
- else await Room.PlayersMessageChannel.EditTo(Player.Info, MessageId, $"{strings.you_choose_target} {Room.Players[NightTargetId].Info.NickName}");
- }
- else await Room.PlayersMessageChannel.EditTo(Player.Info, MessageId, strings.you_skip_vote);
- }
- public NecromancerRole(GameRoom room, Player player) : base(room, player) { }
- }
- }
|