public void addPlayer(ICallBack player, int dim) { if (this.dim != dim) { player.gameError("Something went wrong...\nDifferenet dimensions of board"); return; } if (player1 == null) { player.gameError("Something went wrong...\nPlayer1 is not found"); return; } if (player == player1) { player.gameError("Something went wrong...\nTrying to add the same player"); return; } if (player1 != null && singlePlayer) { player.gameError("Something went wrong...\nThe game is already occupied by single player game"); return; } waitingForPlayer2 = false; player2 = player; game.Player2 = server.getPlayerData(player).Id; }
public Board(int dim, bool singlePlayer, ICallBack player, TTT server) { this.dim = dim; this.singlePlayer = singlePlayer; this.server = server; initBoard(); moveCount = 0; gameEnded = false; player1 = player; if (singlePlayer) { rand = new Random(); } game = new Game(); game.BoardSize = dim; game.Player1 = server.getPlayerData(player).Id; game.StartTime = DateTime.Now; game.Moves = ""; // simple array if (singlePlayer) { game.Player2 = 1; } waitingForPlayer2 = !singlePlayer; }
public Board(int dim, bool singlePlayer, ICallBack player, TTT server) { this.dim = dim; this.singlePlayer = singlePlayer; this.server = server; initBoard(); moveCount = 0; gameEnded = false; player1 = player; if (singlePlayer) rand = new Random(); game = new Game(); game.BoardSize = dim; game.Player1 = server.getPlayerData(player).Id; game.StartTime = DateTime.Now; game.Moves = ""; // simple array if (singlePlayer) game.Player2 = 1; waitingForPlayer2 = !singlePlayer; }