public Game CreateGame(Player player1, Player player2) { Game game = new Game { Player1 = player1, Player2 = player2, Board = new GameBoard() }; string group = Guid.NewGuid().ToString("d"); _games[group] = game; player1.isPlaying = true; player2.isPlaying = true; player1.Group = group; player2.Group = group; Groups.Add(player1.Id, group); Groups.Add(player2.Id, group); return game; }
private bool IsMatch(Game game, Card card) { if (card == null) return false; if(game.LastCard != null) { if (game.LastCard.Pair == card.Id) return true; } return false; }
private Card FindCard(Game game, string cardName) { return game.Board.Pieces.FirstOrDefault(c => c.Name == cardName); }
public void ResetGame(Game game) { var groupName = game.Player1.Group; var player1Name = game.Player1.Name; var player2Name = game.Player2.Name; Groups.Remove(game.Player1.Id, groupName); Groups.Remove(game.Player2.Id, groupName); Player p1, p2; _players.TryRemove(player1Name, out p1); _players.TryRemove(player1Name, out p2); Game g; _games.TryRemove(groupName, out g); }
public Player GetOpponent(Game game, Player player) { return (game.Player1.Id == player.Id) ? game.Player2 : game.Player1; }