View/GamePVAIView.java
public void createEndAlert(Alert alert){
        if(getWinner().equals("Player 1")) {

            ButtonType alertButton1 = new ButtonType("Ok");

            alert.getButtonTypes().setAll(alertButton1);
            Optional<ButtonType> result = alert.showAndWait();

            if (result.get() == alertButton1 && getWinner().equals("Player 1")) {

                createRewardAlert();
            }
        }
        else{
            alert = new Alert(Alert.AlertType.NONE,  "The AI has won\nPlayer 1 score: " + ply1WinCount +"\nAI score: " + aiWinCount);
            alert.getDialogPane().getStylesheets().add("/View/stylesheet.css");

            ButtonType alertButton1 = new ButtonType("Go Back");
            ButtonType alertButton2 = new ButtonType("Exit");
            alert.getButtonTypes().setAll(alertButton1,alertButton2);
            Optional<ButtonType> result = alert.showAndWait();

            if (result.get() == alertButton1){
                StartView sv = new StartView();
                stage.close();
            }
            if (result.get() == alertButton2){
                stage.close();
            }
        }
    }
/*Creates an alert signaling that the game has ended. Shows the winner.
     *Gives option to continue playing or exit the game
     */
Creates an alert signaling that the game has ended. Shows the winner.
Gives option to continue playing or exit the game
Creates an alert signaling that the game has ended . Shows the winner . Gives option to continue playing or exit the game
public void createEndAlert(Alert alert){
        if(getWinner().equals("Player 1")) {
            ButtonType alertButton1 = new ButtonType("Ok");
            alert.getButtonTypes().setAll(alertButton1);
            Optional<ButtonType> result = alert.showAndWait();
            if (result.get() == alertButton1 && getWinner().equals("Player 1")) {
                createRewardAlert();
            }
        }
        else{
            alert = new Alert(Alert.AlertType.NONE,  "The AI has won\nPlayer 1 score: " + ply1WinCount +"\nAI score: " + aiWinCount);
            alert.getDialogPane().getStylesheets().add("/View/stylesheet.css");
            ButtonType alertButton1 = new ButtonType("Go Back");
            ButtonType alertButton2 = new ButtonType("Exit");
            alert.getButtonTypes().setAll(alertButton1,alertButton2);
            Optional<ButtonType> result = alert.showAndWait();
            if (result.get() == alertButton1){
                StartView sv = new StartView();
                stage.close();
            }
            if (result.get() == alertButton2){
                stage.close();
            }
        }
    }
public void createEndAlert ( Alert alert ) { if ( getWinner ( ) . equals ( "Player 1" ) ) { ButtonType alertButton1 = new ButtonType ( "Ok" ) ; alert . getButtonTypes ( ) . setAll ( alertButton1 ) ; Optional < ButtonType > result = alert . showAndWait ( ) ; if ( result . get ( ) == alertButton1 && getWinner ( ) . equals ( "Player 1" ) ) { createRewardAlert ( ) ; } } else { alert = new Alert ( Alert . AlertType . NONE , "The AI has won\nPlayer 1 score: " + ply1WinCount + "\nAI score: " + aiWinCount ) ; alert . getDialogPane ( ) . getStylesheets ( ) . add ( "/View/stylesheet.css" ) ; ButtonType alertButton1 = new ButtonType ( "Go Back" ) ; ButtonType alertButton2 = new ButtonType ( "Exit" ) ; alert . getButtonTypes ( ) . setAll ( alertButton1 , alertButton2 ) ; Optional < ButtonType > result = alert . showAndWait ( ) ; if ( result . get ( ) == alertButton1 ) { StartView sv = new StartView ( ) ; stage . close ( ) ; } if ( result . get ( ) == alertButton2 ) { stage . close ( ) ; } } }
Creates an alert signaling that the game has ended.
Creates an alert signaling that the game has ended .