|
@@ -1,16 +1,51 @@
|
|
|
+using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
using MafiaTelegramBot.Game.GameRooms;
|
|
|
using MafiaTelegramBot.Resources;
|
|
|
-using Telegram.Bot.Types;
|
|
|
|
|
|
namespace MafiaTelegramBot.Game.GameRoles
|
|
|
{
|
|
|
public class LawyerRole : GameRoom.Role
|
|
|
{
|
|
|
public override Roles RoleKey => Roles.Lawyer;
|
|
|
- public override Task NightAction() { return Task.CompletedTask; }
|
|
|
- public override Task ApplyNightActionResult() { return Task.CompletedTask; }
|
|
|
- public override Task SetNightTarget(long userId) { return new (()=>new Message()); }
|
|
|
+ public override async Task NightAction()
|
|
|
+ {
|
|
|
+ NightTargetId = -1;
|
|
|
+ NightTargetList = Room.Players.Values.Where(p => p.IsAlive && !KnownRoles.ContainsKey(p.Id)).ToList();
|
|
|
+ var message = await Room.PlayersCh.SendTo(Player.ChatId, strings.choose_player_to_check_role,
|
|
|
+ Keyboard.NightChooseTargetKeyboard(NightTargetList, Player.Id));
|
|
|
+ MessageId = message.MessageId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override async Task ApplyNightActionResult()
|
|
|
+ {
|
|
|
+ if (NightTargetId != -2)
|
|
|
+ {
|
|
|
+ if (NightTargetId == -1) await SetRandomNightTarget();
|
|
|
+ if (Room.Players.ContainsKey(NightTargetId))
|
|
|
+ {
|
|
|
+ var role = Room.Players[NightTargetId].GetRole() is Roles.Don or Roles.Mafia or Roles.Dame
|
|
|
+ ? roles.Mafia
|
|
|
+ : Room.Players[NightTargetId].GetRole() is Roles.Werewolf && ((WerewolfRole) Room.Players[NightTargetId].CurrentRole).IsMafia
|
|
|
+ ? roles.Mafia
|
|
|
+ : roles.Villager;
|
|
|
+ KnownRoles.Add(Room.Players[NightTargetId].Id, role);
|
|
|
+ await Room.PlayersCh.EditTo(Player.Id, MessageId,
|
|
|
+ $"{strings.role_of_your_target} {Room.Players[NightTargetId].NickName} - {role}");
|
|
|
+ }
|
|
|
+ else await Room.PlayersCh.EditTo(Player.Id, MessageId, strings.this_player_left_from_game);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public override async Task SetNightTarget(long userId)
|
|
|
+ {
|
|
|
+ if (!Room.Players.ContainsKey(userId)) await Room.PlayersCh.SendTo(Player.Id, strings.this_player_left_from_game);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ NightTargetId = userId;
|
|
|
+ await Room.PlayersCh.EditTo(Player.Id, MessageId, $"{strings.you_choose_target} {Room.Players[userId].NickName}");
|
|
|
+ }
|
|
|
+ }
|
|
|
public LawyerRole(GameRoom room, Player player) : base(room, player) { }
|
|
|
}
|
|
|
}
|