public void MakeVote(Vote vote) { try { vote.Name = playersDict[vote.UserId].Name; CurrentRound.AddVote(vote); } catch (Exception ex) { Console.WriteLine("MakeVote.ex :" + ex.Message); } }
public void CastVote(Player player, string word) { var card = Cards.Find(c => c.Word.Equals(word)); CurrentRound.AddVote(player, card); // Check if game has finished // Assassing has been revealed: currentTeam loses if (Cards.Exists(cardInBoard => cardInBoard.Agent.Equals(Agent.ASSASSIN) && cardInBoard.HasBeenRevealed)) { HasGameFinished = true; WinningTeam = CurrentRound.Team.Equals(player.Room.TeamA) ? player.Room.TeamB : player.Room.TeamA; WinningCondition = $"{player.UserName} has selected the assassin. {WinningTeam.Name} wins."; } // Check if there are some team whose all the cards have been revealed if (Cards.Where(cardInBoard => cardInBoard.Agent.Equals(Agent.TEAM_A)).All(cardOfTeam => cardOfTeam.HasBeenRevealed)) { HasGameFinished = true; WinningTeam = player.Room.TeamA; WinningCondition = $"{player.UserName} has selected the last card. {WinningTeam.Name} wins."; } if (Cards.Where(cardInBoard => cardInBoard.Agent.Equals(Agent.TEAM_B)).All(cardOfTeam => cardOfTeam.HasBeenRevealed)) { HasGameFinished = true; WinningTeam = player.Room.TeamB; WinningCondition = $"{player.UserName} has selected the last card. {WinningTeam.Name} wins."; } // Initiate new round if finished if (CurrentRound.HasFinished) { PassTurn(player); } }