public override bool add(int x, int y, int Player) { TictactoePiece P = null; if (Player == PLAYER1) { P = new TictactoePiece("X", PLAYER1); } else if (Player == PLAYER2) { P = new TictactoePiece("O", PLAYER2); } else { Console.WriteLine("Invalid player: '" + Player + "'. Players: '" + PLAYER1 + "' and '" + PLAYER2 + "'."); return(false); } if (canAdd(x, y, (Piece)P)) { if (BOARD.addPiece(x, y, (Piece)P)) { } else { Console.WriteLine("BLASFEMIA!!!"); } if (gameEnded()) { Console.WriteLine("End game. Winner: " + WINNER); } CONT_ID++; return(true); } return(false); }
public override bool add(int x, int y, int Player) { TictactoePiece P = null; if (Player == PLAYER1) { P = new TictactoePiece("+", PLAYER1); } else if (Player == PLAYER2) { P = new TictactoePiece("-", PLAYER2); } else { Console.WriteLine("Invalid player: '" + Player + "'. Players: '" + PLAYER1 + "' and '" + PLAYER2 + "'."); return(false); } if (canAdd(x, y, (Piece)P)) { if (BOARD.addPiece(x, y, (Piece)P)) { } else { Console.WriteLine("BLASFEMIA!!!"); } if ((BOARD.contPieces(new TictactoePiece("", -1)) == 9) && WINNER == -1) { DRAWN_GAME = true; GAME_ENDED = true; LAST_MESSAGE = "DRAWN GAME"; } if (gameEnded()) { if (DRAWN_GAME) { Console.WriteLine("End game. " + LAST_MESSAGE); } else { Console.WriteLine("End game. Winner: " + WINNER); } } CONT_ID++; return(true); } return(false); }