|
@@ -32,14 +32,39 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
protected List<Player> NightTargetList = null;
|
|
protected List<Player> NightTargetList = null;
|
|
public abstract Roles RoleKey { get; }
|
|
public abstract Roles RoleKey { get; }
|
|
public abstract int RankingCost { get; }
|
|
public abstract int RankingCost { get; }
|
|
-
|
|
|
|
- public virtual Task NightAction() { return Task.CompletedTask; }
|
|
|
|
- public virtual Task SetMafiaTarget(long userId) { return Task.CompletedTask; }
|
|
|
|
- public virtual Task ApplyNightActionResult() { return Task.CompletedTask; }
|
|
|
|
- public virtual Task SetNightTarget(long userId) { return Task.CompletedTask; }
|
|
|
|
|
|
+
|
|
|
|
+ public virtual Task NightAction()
|
|
|
|
+ {
|
|
|
|
+ Logs.LogOut(GetType(), "NightAction");
|
|
|
|
+
|
|
|
|
+ return Task.CompletedTask;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public virtual Task SetMafiaTarget(long userId)
|
|
|
|
+ {
|
|
|
|
+ Logs.LogOut(GetType(), "SetMafiaTarget");
|
|
|
|
+
|
|
|
|
+ return Task.CompletedTask;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public virtual Task ApplyNightActionResult()
|
|
|
|
+ {
|
|
|
|
+ Logs.LogOut(GetType(), "ApplyNightActionResult");
|
|
|
|
+
|
|
|
|
+ return Task.CompletedTask;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public virtual Task SetNightTarget(long userId)
|
|
|
|
+ {
|
|
|
|
+ Logs.LogOut(GetType(), "SetNightTarget");
|
|
|
|
+
|
|
|
|
+ return Task.CompletedTask;
|
|
|
|
+ }
|
|
|
|
|
|
public virtual async Task CancelNightActionResult(string message)
|
|
public virtual async Task CancelNightActionResult(string message)
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "CancelNightActionResult");
|
|
|
|
+
|
|
if (MessageId != -1)
|
|
if (MessageId != -1)
|
|
{
|
|
{
|
|
await Room.PlayersMessageChannel.EditTo(Player.Info, MessageId, strings.activity_blocked);
|
|
await Room.PlayersMessageChannel.EditTo(Player.Info, MessageId, strings.activity_blocked);
|
|
@@ -56,10 +81,14 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
|
|
|
public virtual async Task<string> IsWon()
|
|
public virtual async Task<string> IsWon()
|
|
{
|
|
{
|
|
- return await Task.Run(() => "");
|
|
|
|
|
|
+ Logs.LogOut(GetType(), "IsWon");
|
|
|
|
+
|
|
|
|
+ return await Task.FromResult("");
|
|
}
|
|
}
|
|
public virtual async Task Dispatch()
|
|
public virtual async Task Dispatch()
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "Dispatch");
|
|
|
|
+
|
|
if (Room.PlayersRole.ContainsKey(Roles.Hooker)
|
|
if (Room.PlayersRole.ContainsKey(Roles.Hooker)
|
|
&& Room.PlayersRole[Roles.Hooker].Count == 1
|
|
&& Room.PlayersRole[Roles.Hooker].Count == 1
|
|
&& Room.PlayersRole[Roles.Hooker][0].CurrentRole.NightTargetId == Player.Info.Id)
|
|
&& Room.PlayersRole[Roles.Hooker][0].CurrentRole.NightTargetId == Player.Info.Id)
|
|
@@ -82,6 +111,8 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
|
|
|
public virtual async Task Kill()
|
|
public virtual async Task Kill()
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "Kill");
|
|
|
|
+
|
|
Player.IsAlive = false;
|
|
Player.IsAlive = false;
|
|
if (Room.PlayersRole.ContainsKey(Roles.Parasite)
|
|
if (Room.PlayersRole.ContainsKey(Roles.Parasite)
|
|
&& Room.PlayersRole[Roles.Parasite].Count == 1
|
|
&& Room.PlayersRole[Roles.Parasite].Count == 1
|
|
@@ -96,6 +127,8 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
|
|
|
protected async Task SetRandomNightTarget()
|
|
protected async Task SetRandomNightTarget()
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "SetRandomNightTarget");
|
|
|
|
+
|
|
var inGamePlayers = NightTargetList.Where(p => Room.Players.ContainsKey(p.Info.Id)).ToArray();
|
|
var inGamePlayers = NightTargetList.Where(p => Room.Players.ContainsKey(p.Info.Id)).ToArray();
|
|
if (inGamePlayers.Length == 0)
|
|
if (inGamePlayers.Length == 0)
|
|
{
|
|
{
|
|
@@ -112,12 +145,16 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
|
|
|
protected Role(GameRoom room, Player player)
|
|
protected Role(GameRoom room, Player player)
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "Role");
|
|
|
|
+
|
|
Room = room;
|
|
Room = room;
|
|
Player = player;
|
|
Player = player;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task SpeakAction(int interval, bool enableTimer = false)
|
|
public async Task SpeakAction(int interval, bool enableTimer = false)
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "SpeakAction");
|
|
|
|
+
|
|
await Room.PlayersMessageChannel.SendTo(Player.Info, $"{strings.your_turn}", Keyboard.InGamePlayerMenuWithEndTurn);
|
|
await Room.PlayersMessageChannel.SendTo(Player.Info, $"{strings.your_turn}", Keyboard.InGamePlayerMenuWithEndTurn);
|
|
Player.IsSpeaker = true;
|
|
Player.IsSpeaker = true;
|
|
var timer = new Timer(interval) {AutoReset = false};
|
|
var timer = new Timer(interval) {AutoReset = false};
|
|
@@ -132,6 +169,8 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
|
|
|
public async Task VotingAction(bool isFirst = false)
|
|
public async Task VotingAction(bool isFirst = false)
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "VotingAction");
|
|
|
|
+
|
|
var voteTimer = new Timer(Constants.PUT_UP_VOTE_INTERVAL) {AutoReset = false};
|
|
var voteTimer = new Timer(Constants.PUT_UP_VOTE_INTERVAL) {AutoReset = false};
|
|
var alivePlayers = Room.Players.Values.Where(p => p.IsAlive).Except(Room.VoteUpList).ToList();
|
|
var alivePlayers = Room.Players.Values.Where(p => p.IsAlive).Except(Room.VoteUpList).ToList();
|
|
var message = await Room.PlayersMessageChannel.SendTo(Player.Info,
|
|
var message = await Room.PlayersMessageChannel.SendTo(Player.Info,
|
|
@@ -140,6 +179,8 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
|
|
|
async void OnVoteTimerOnElapsed(object o, ElapsedEventArgs elapsedEventArgs)
|
|
async void OnVoteTimerOnElapsed(object o, ElapsedEventArgs elapsedEventArgs)
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "OnVoteTimerElapsed");
|
|
|
|
+
|
|
if (isFirst)
|
|
if (isFirst)
|
|
await Room.PutUpVote(Player.Info.Id, Player.Info.Id, message.MessageId);
|
|
await Room.PutUpVote(Player.Info.Id, Player.Info.Id, message.MessageId);
|
|
else
|
|
else
|
|
@@ -159,12 +200,16 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
private List<Player> _votingTargetsList;
|
|
private List<Player> _votingTargetsList;
|
|
public async Task VotingAction(List<Player> targets)
|
|
public async Task VotingAction(List<Player> targets)
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "VotingAction2");
|
|
|
|
+
|
|
_votingMessageId = (await Room.PlayersMessageChannel.SendTo(Player.Info, strings.you_have_ten_seconds_to_vote,
|
|
_votingMessageId = (await Room.PlayersMessageChannel.SendTo(Player.Info, strings.you_have_ten_seconds_to_vote,
|
|
Keyboard.VoteKeyboard(targets, false, Callback.VoteToKill))).MessageId;
|
|
Keyboard.VoteKeyboard(targets, false, Callback.VoteToKill))).MessageId;
|
|
_votingTargetsList = targets;
|
|
_votingTargetsList = targets;
|
|
}
|
|
}
|
|
public async Task RandomVoting()
|
|
public async Task RandomVoting()
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "RandomVoting");
|
|
|
|
+
|
|
var players = _votingTargetsList.Where(p => Room.Players.ContainsKey(p.Info.Id)).ToArray();
|
|
var players = _votingTargetsList.Where(p => Room.Players.ContainsKey(p.Info.Id)).ToArray();
|
|
if(players.Length == 0) await Room.PlayersMessageChannel.EditTo(Player.Info, _votingMessageId, strings.nothing_to_choose);
|
|
if(players.Length == 0) await Room.PlayersMessageChannel.EditTo(Player.Info, _votingMessageId, strings.nothing_to_choose);
|
|
else
|
|
else
|
|
@@ -177,12 +222,16 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
|
|
|
public async Task DefenceAction()
|
|
public async Task DefenceAction()
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(GetType(), "DefenceAction");
|
|
|
|
+
|
|
await Room.PlayersMessageChannel.SendExcept(Player.Info, $"{strings.now_defence} ({Player.TurnOrder}) {Player.Info.NickName}");
|
|
await Room.PlayersMessageChannel.SendExcept(Player.Info, $"{strings.now_defence} ({Player.TurnOrder}) {Player.Info.NickName}");
|
|
await Room.PlayersMessageChannel.SendTo(Player.Info, strings.you_have_thirty_seconds_to_defence);
|
|
await Room.PlayersMessageChannel.SendTo(Player.Info, strings.you_have_thirty_seconds_to_defence);
|
|
await SpeakAction(Constants.DEFENCE_INTERVAL);
|
|
await SpeakAction(Constants.DEFENCE_INTERVAL);
|
|
}
|
|
}
|
|
public static Role GetNewRoleInstance(Roles roleKey, GameRoom room, Player player)
|
|
public static Role GetNewRoleInstance(Roles roleKey, GameRoom room, Player player)
|
|
{
|
|
{
|
|
|
|
+ Logs.LogOut(typeof(GameRoom), "GetNewRoleInstance");
|
|
|
|
+
|
|
return roleKey switch
|
|
return roleKey switch
|
|
{
|
|
{
|
|
Roles.All => new NoneRole(),
|
|
Roles.All => new NoneRole(),
|