|
@@ -186,7 +186,7 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
await PlayersMessageChannel.Send($"{strings.now_turn} ({player.TurnOrder}) {player.NickName}");
|
|
|
if (TimerEnabled) await Bot.SendWithMarkdown2(player.ChatId, strings.you_turn_say);
|
|
|
await player.CurrentRole.SpeakAction();
|
|
|
- if (Players.ContainsKey(player.Id)) await player.CurrentRole.VotingAction(VoteUpList.Count == 0);
|
|
|
+ if (Players.ContainsKey(player.Id)) await player.CurrentRole.VotingAction(_voteUpList.Count == 0);
|
|
|
}
|
|
|
if (toEndQueue != null) _turnOrder.Enqueue(player);
|
|
|
else toEndQueue = player;
|
|
@@ -292,7 +292,7 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
var resetEvent = new ManualResetEvent(false);
|
|
|
timer.Elapsed += async (_, _) =>
|
|
|
{
|
|
|
- foreach (var voter in votersPlayers.Where(p => !VoteKillList.ContainsKey(p.Id) && Players.ContainsKey(p.Id)))
|
|
|
+ foreach (var voter in votersPlayers.Where(p => !_voteKillList.ContainsKey(p.Id) && Players.ContainsKey(p.Id)))
|
|
|
await voter.CurrentRole.RandomVoting();
|
|
|
resetEvent.Set();
|
|
|
};
|
|
@@ -305,47 +305,47 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
{
|
|
|
await Task.Run(async () =>
|
|
|
{
|
|
|
- switch (VoteUpList.Count)
|
|
|
+ switch (_voteUpList.Count)
|
|
|
{
|
|
|
case 0:
|
|
|
await PlayersMessageChannel.Send(strings.nothing_up_to_vote);
|
|
|
break;
|
|
|
case 1:
|
|
|
{
|
|
|
- await VoteUpList[0].CurrentRole.Dispatch();
|
|
|
+ await _voteUpList[0].CurrentRole.Dispatch();
|
|
|
break;
|
|
|
}
|
|
|
default:
|
|
|
{
|
|
|
- await DefencePhase(VoteUpList);
|
|
|
- VoteUpList = await CalculateCandidates();
|
|
|
- switch (VoteUpList.Count)
|
|
|
+ await DefencePhase(_voteUpList);
|
|
|
+ _voteUpList = await CalculateCandidates();
|
|
|
+ switch (_voteUpList.Count)
|
|
|
{
|
|
|
case 0:
|
|
|
await PlayersMessageChannel.Send(strings.nothing_up_to_dispatch);
|
|
|
break;
|
|
|
case 1:
|
|
|
- await VoteUpList[0].CurrentRole.Dispatch();
|
|
|
+ await _voteUpList[0].CurrentRole.Dispatch();
|
|
|
break;
|
|
|
case > 1:
|
|
|
- var copyVoteUpList = VoteUpList.ToList();
|
|
|
- await DefencePhase(VoteUpList);
|
|
|
- VoteUpList = await CalculateCandidates();
|
|
|
- var alivers = copyVoteUpList.Except(VoteUpList).ToList();
|
|
|
+ var copyVoteUpList = _voteUpList.ToList();
|
|
|
+ await DefencePhase(_voteUpList);
|
|
|
+ _voteUpList = await CalculateCandidates();
|
|
|
+ var alivers = copyVoteUpList.Except(_voteUpList).ToList();
|
|
|
foreach (var alive in alivers)
|
|
|
alive.ElderRoleAchievementEvent();
|
|
|
|
|
|
- switch (VoteUpList.Count)
|
|
|
+ switch (_voteUpList.Count)
|
|
|
{
|
|
|
case 0:
|
|
|
await PlayersMessageChannel.Send(strings.nothing_up_to_dispatch);
|
|
|
break;
|
|
|
case 1:
|
|
|
- await VoteUpList[0].CurrentRole.Dispatch();
|
|
|
+ await _voteUpList[0].CurrentRole.Dispatch();
|
|
|
break;
|
|
|
default:
|
|
|
await PlayersMessageChannel.Send(strings.villagers_could_not_decide);
|
|
|
- foreach (var alive in VoteUpList)
|
|
|
+ foreach (var alive in _voteUpList)
|
|
|
alive.ElderRoleAchievementEvent();
|
|
|
break;
|
|
|
}
|
|
@@ -354,15 +354,15 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- VoteUpList.Clear();
|
|
|
- VoteKillList.Clear();
|
|
|
+ _voteUpList.Clear();
|
|
|
+ _voteKillList.Clear();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
private async Task<List<Player>> CalculateCandidates()
|
|
|
{
|
|
|
var message = strings.results_of_voting;
|
|
|
- foreach (var (playerId, targetId) in VoteKillList)
|
|
|
+ foreach (var (playerId, targetId) in _voteKillList)
|
|
|
{
|
|
|
message += Players.ContainsKey(playerId) && Players.ContainsKey(targetId)
|
|
|
? $"\n({Players[playerId].TurnOrder}) {Players[playerId].NickName} {strings.vote_to} " +
|
|
@@ -371,7 +371,7 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
if (message == strings.results_of_voting) message = strings.no_one_voted;
|
|
|
await PlayersMessageChannel.Send(message);
|
|
|
|
|
|
- var votes = VoteUpList.Where(p=>Players.ContainsKey(p.Id))
|
|
|
+ var votes = _voteUpList.Where(p=>Players.ContainsKey(p.Id))
|
|
|
.GroupBy(p => p.Id)
|
|
|
.Select(item => new {id = item.Key, count = item.Count()})
|
|
|
.ToList();
|
|
@@ -380,8 +380,8 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
var max = votes.Max(item => item.count);
|
|
|
var maxObjects = votes.Where(item => item.count == max);
|
|
|
result.AddRange(from obj in maxObjects select Players[obj.id]);
|
|
|
- VoteKillList.Clear();
|
|
|
- VoteUpList.Clear();
|
|
|
+ _voteKillList.Clear();
|
|
|
+ _voteUpList.Clear();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -400,7 +400,7 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
{
|
|
|
if (!toKill)
|
|
|
{
|
|
|
- if (VoteUpList.AddUnique(Players[targetId]))
|
|
|
+ if (_voteUpList.AddUnique(Players[targetId]))
|
|
|
{
|
|
|
if (playerId != targetId)
|
|
|
{
|
|
@@ -414,9 +414,9 @@ namespace MafiaTelegramBot.Game.GameRooms
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (VoteKillList.AddUniqueByKey(playerId, targetId))
|
|
|
+ else if (_voteKillList.AddUniqueByKey(playerId, targetId))
|
|
|
{
|
|
|
- VoteUpList.Add(Players[targetId]);
|
|
|
+ _voteUpList.Add(Players[targetId]);
|
|
|
if (messageId != -1)
|
|
|
{
|
|
|
if (playerId != targetId)
|