private void checkWon() { if (AlgorithmCheck.hasWon(Values.X, gameBoard)) { LoggingClass.logInfo("GAME-WIN", "X WON"); gameStart = 3; MessageBox.Show("X has won the game!", "X Won!"); promptReset(); } else if (AlgorithmCheck.hasWon(Values.O, gameBoard)) { LoggingClass.logInfo("GAME-WIN", "O WON"); gameStart = 3; MessageBox.Show("O has won the game!", "O Won!"); promptReset(); } //If not won, update if (gameStart == 1) { NextTurn(); } }
private void NextTurn() { if (isSinglePlayer()) { LoggingClass.logInfo("GAME", "Single Player Mode"); turnNo++; LoggingClass.logInfo("GAME", "Incremented Turn No"); if (currentPlayer == Values.X) { //AI's Turn currentPlayer = Values.AI; updateTurnDisplay(); grpGamePlay.Enabled = false; ComputerAI.determineNextMove(gameBoard, lastRow, lastCol, turnNo); UpdateAIRefreshes(); } else { currentPlayer = Values.X; grpGamePlay.Enabled = true; updateTurnDisplay(); } //Check drawn if (AlgorithmCheck.hasDrawn(turnNo)) { if (gameStart == 2) { LoggingClass.logInfo("SYSTEM", "Already prompted Draw Message"); } else { gameStart = 3; MessageBox.Show("This game is a draw!", "Game Drawn"); LoggingClass.logInfo("SYSTEM", "Game Drawn"); promptReset(); } } } else { LoggingClass.logInfo("GAME", "Multiplayer Mode"); turnNo++; LoggingClass.logInfo("GAME", "Incremented Turn No"); if (currentPlayer == Values.X) { currentPlayer = Values.O; } else { currentPlayer = Values.X; } updateTurnDisplay(); //Check drawn if (AlgorithmCheck.hasDrawn(turnNo)) { gameStart = 3; MessageBox.Show("This game is a draw!", "Game Drawn"); LoggingClass.logInfo("SYSTEM", "Game Drawn"); promptReset(); } } }