public void CreatesValidLynchVoteObject() { const string id = "123456"; var vote = Vote.Lynch(id); Assert.Equal(VoteType.Lynch, vote.Type); Assert.Equal(id, vote.Identifier); }
public void ReturnsListOfMultiplePlayersTiedWithMostLynchVotes() { // Create our list of players. var players = new Dictionary <string, PlayerState>() { { "1", new PlayerState() { Identifier = "1", Accusation = Vote.Lynch("4") } }, { "2", new PlayerState() { Identifier = "2", Accusation = Vote.Lynch("4") } }, { "3", new PlayerState() { Identifier = "3", Accusation = Vote.Lynch("2") } }, { "4", new PlayerState() { Identifier = "4", Accusation = Vote.None } }, { "5", new PlayerState() { Identifier = "5", Accusation = Vote.Lynch("2") } }, { "6", new PlayerState() { Identifier = "6", Accusation = Vote.None } }, { "7", new PlayerState() { Identifier = "7", Accusation = Vote.Lynch("4") } }, { "8", new PlayerState() { Identifier = "8", Accusation = Vote.Lynch("2") } }, }; // Generate our game. var game = new GameState() { Players = players.ToImmutableDictionary() }; // Get our most lynch votes. var lynchVotes = game.GetLynchCandidates(); // Expectations Assert.Equal(2, lynchVotes.Length); Assert.Contains("4", lynchVotes); Assert.Contains("2", lynchVotes); }
public void ReturnsListOfPlayersIgnoringEliminatedPlayerVotes() { // Create our list of players. var players = new Dictionary <string, PlayerState>() { { "1", new PlayerState() { Identifier = "1", Accusation = Vote.Lynch("5") } }, { "2", new PlayerState() { Identifier = "2", Accusation = Vote.Lynch("5") } }, { "3", new PlayerState() { Identifier = "3", Accusation = Vote.Lynch("5") } }, { "4", new PlayerState() { Identifier = "4", Accusation = Vote.Lynch("2") } }, { "5", new PlayerState() { Identifier = "5", Accusation = Vote.Lynch("2") } }, { "6", new PlayerState() { Identifier = "6", Accusation = Vote.Lynch("2"), CauseOfDeath = EliminationCause.Werewolves } }, { "7", new PlayerState() { Identifier = "7", Accusation = Vote.Lynch("2"), CauseOfDeath = EliminationCause.Werewolves } }, { "8", new PlayerState() { Identifier = "8", Accusation = Vote.None } }, }; // Generate our game. var game = new GameState() { Players = players.ToImmutableDictionary() }; // Get our most lynch votes. var lynchVotes = game.GetLynchCandidates(); // Expectations Assert.Single(lynchVotes); Assert.Contains("5", lynchVotes); }
public void ReturnsListOfNoPlayersIfTiedWithHighestLynchVotes() { // Create our list of players. var players = new Dictionary <string, PlayerState>() { { "1", new PlayerState() { Identifier = "1", Accusation = Vote.Lynch("4") } }, { "2", new PlayerState() { Identifier = "2", Accusation = Vote.Lynch("4") } }, { "3", new PlayerState() { Identifier = "3", Accusation = Vote.Lynch("4") } }, { "4", new PlayerState() { Identifier = "4", Accusation = Vote.None } }, { "5", new PlayerState() { Identifier = "5", Accusation = Vote.NoLynch } }, { "6", new PlayerState() { Identifier = "6", Accusation = Vote.NoLynch } }, { "7", new PlayerState() { Identifier = "7", Accusation = Vote.NoLynch } }, { "8", new PlayerState() { Identifier = "8", Accusation = Vote.Lynch("2") } }, }; // Generate our game. var game = new GameState() { Players = players.ToImmutableDictionary() }; // Get our most lynch votes. var lynchVotes = game.GetLynchCandidates(); // Expectations Assert.Empty(lynchVotes); }
private static GameState VoteLynch(GameState game, VoteLynchAction action) { // Attempt to get this player object, otherwise return our original state. if (!game.Players.TryGetValue(action.Identifier, out var player)) { return(game); } return(game with { Players = game.Players.SetItem( action.Identifier, player with { Accusation = Vote.Lynch(action.Identifier) } ) }); }