Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the course project, you will implement a simplified game of Skirmish, a stra

ID: 3571490 • Letter: F

Question

For the course project, you will implement a simplified game of Skirmish, a strategy card game, with 2 players: a human (i.e., the user) and the computer. Skirmish is a card game that was funded using kickstarter.com with the objective that luck is not a component of the game. Watch a video demonstration of the game at scrimish.com Both players have a set of cards composed of the following cards and numbers: #1 Dagger Cards (x5 per player) #2 Sword Cards (x5 per player) #3 Morning Star Cards (x3 per player) #4 War Axe Cards (x3 per player) #5 Halberd Cards (x2 per player) #6 Longsword Cards (x2 per player) 'A' Archer Cards (x2 per player) 'S' Shield Cards (x2 per player) 'C' Crown Card (x1 per player) Setup: The user player places 5 Piles of 5 Cards each face down in front of him. The Crown Card should be hidden on the bottom of one of the 5 Piles. The rest of the Cards may be arranged however you like. The computer does the same thing: the crown card is placed on the bottom of a random pile, while the rest of the card are distributed into 5 piles (such that we have 5 cards in each pile). Game Play: The players take turns attacking (starting with the user first) by selecting the top card from one of their piles and laying that card face up in front of one of their opponent's piles. The defending player must then reveal the top card of the pile that was attacked. The card with the lowest number value loses and is discarded. The winning card must be returned face down to the top of the original pile it was drawn from. If the two cards have the same number value, both cards are discarded. The play continues until one of the players attacks their opponent's Crown Card, winning the game. Archer Card: If you attack with an Archer Card, it always wins. If your Archer Card is attacked, it always loses. Shield Card: Shield Cards cannot be used to attack. If your Shield Card is attacked, both your Shield Card and your opponent's attacking Card are discarded (except for Archer Cards: If a Shield Card is attacked by an Archer Card, neither Card is discarded, and both are returned face down to their original Piles). Crown Card: You can attack with your Crown Card. If you attack your opponent's Crown Card, you win. Otherwise, you lose the game. Instead of attacking, you may intentionally discard one Card on your turn. You do not have to reveal that Card to your opponent. You cannot intentionally discard your Crown Card. For maximum credit, implement a GUI for the game using JavaFX. For partial credit, implement the entire game in Java using console I/O. The number of points possible for the project are 40 points: game setup: let the human user select the cards in each pile = 10-point play one turn started by the human user = 10 points play one turn started by the computer =10 points graphical user interface = 10 points.

Explanation / Answer


import control.ScrimishManager;
import java.util.HashMap;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class ScrimishUI {

    private final Stage _primaryStage;
    private final ScrimishManager _manager;
    private final double _width;
    private final double _height;

    private final StackPane root;
    private BorderPane gameOverScreen;
    private BorderPane inGameScreen;
    private BorderPane menuScreen;
    private BorderPane ruleScreen;

    private BorderPane currentScreen;

    private Label menuaudio;
    private Label ingameaudio;
    private Label gameoveraudio;
    private boolean updatingaudio;

    private HBox redCards;
    private HBox blueCards;

    private ScrimishColors cardSourceColor;
    private int cardSourcePile;
    private ScrimishColors cardDestinationColor;
    private int cardDestinationPile;
    private boolean cardNotClicked;

    public ScrimishUI(Stage primaryStage, double width, double height) {
        _primaryStage = primaryStage;
        _width = width;
        _height = height;

        root = new StackPane();

        /* Initialize panes */
        initializePanes();
        updatingaudio = true;
        cardNotClicked = true;
        /* Connect classes */
        _manager = new ScrimishManager(this);
        resetBoard();
    }

    private void initializePanes() {
        initializeMenuScreen();
        initializeHelpScreen();
        initializeInGameScreen();
        initializeGameOverScreen();
    }

    private void initializeMenuScreen() {
        /* Create the screen */
        menuScreen = new BorderPane();

        /* Create a vertical pane to store buttons */
        VBox menu_list = new VBox();

        /* Set vertical pane alignment IMPORTANT */
        menu_list.setAlignment(Pos.CENTER);

        /* Set spacing for the vertical pane */
        menu_list.setSpacing(5);

        /* Create logo */
        ImageView logo_image = new ImageView(new Image("resource/img/logo.png"));
        Label logo = new Label();
        logo.setGraphic(logo_image);

        /* Create buttons */
        Button enter_button = new Button("Enter");
        Button rule_button = new Button("Rule");
        Button exit_button = new Button("Exit");

        /* Resizing buttons */
        setButtonSize(enter_button, rule_button, exit_button);

        /* Set handlers for buttons */
        enter_button.setOnAction((ActionEvent event) -> {
            _manager.handleEnterButtonClicked();
        });
        rule_button.setOnAction((ActionEvent event) -> {
            _manager.handleRuleButtonClicked();
        });
        exit_button.setOnAction((ActionEvent event) -> {
            _manager.handleExitButtonClicked();
        });

        /* Initialize audio label */
        ImageView volume_max_image = new ImageView(new Image("resource/img/volume-max.png"));
        ImageView volume_mute_image = new ImageView(new Image("resource/img/volume-mute.png"));
        volume_max_image.setFitWidth(35);
        volume_max_image.setFitHeight(35);
        volume_mute_image.setFitWidth(35);
        volume_mute_image.setFitHeight(35);
        menuaudio = new Label();
        menuaudio.setGraphic(volume_max_image);
        /* Set its special spacing */
        menuaudio.setPadding(new Insets(50, 0, 0, 0));

        /* Set handler for audio_image */
        menuaudio.setOnMouseClicked((MouseEvent event) -> {
            if (menuaudio.getGraphic() == volume_max_image) {
                menuaudio.setGraphic(volume_mute_image);
            } else {
                menuaudio.setGraphic(volume_max_image);
            }
            if (updatingaudio) {
                updatingaudio = false;
                Event.fireEvent(gameoveraudio, new MouseEvent(MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY,
                        1, false, false, false, false, false, false, false, false, false, false, null));
                Event.fireEvent(ingameaudio, new MouseEvent(MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY,
                        1, false, false, false, false, false, false, false, false, false, false, null));
                updatingaudio = true;
            }
            _manager.handleAudioButtonClicked();
        });

        /*Add the logo and buttons to the vertical pane */
        menu_list.getChildren().addAll(logo, enter_button, rule_button, exit_button, menuaudio);

        /* Place the vertical pane to the center of the screen */
        menuScreen.setCenter(menu_list);

        /* Add this inital screen to the pane */
        root.getChildren().add(menuScreen);
        currentScreen = menuScreen;
    }

    private void initializeInGameScreen() {
        inGameScreen = new BorderPane();

        /* Create cheat to test game over screen */
        inGameScreen.setOnKeyReleased((KeyEvent event) -> {
            if (event.isControlDown()) {
                switch (event.getCode()) {
                    case B:
                        _manager.handleVictory(ScrimishColors.BLUE);
                        break;
                    case R:
                        _manager.handleVictory(ScrimishColors.RED);
                        break;
                    default:

                }
            }
        });

        /* Set up in_game menu */
        VBox ingameMenu = new VBox();
        ingameMenu.setAlignment(Pos.CENTER);
        ingameMenu.setSpacing(5);

        Button reset_button = new Button("Reset");
        Button menu_button = new Button("Menu");

        reset_button.setOnMouseClicked((MouseEvent event) -> {
            _manager.handleRestartButtonClicked();
        });

        menu_button.setOnMouseClicked((MouseEvent event) -> {
            _manager.handleMenuButtonClicked();
        });

        setButtonSize(reset_button, menu_button);

        /* Set audio and handler */
        ImageView volume_max_image = new ImageView(new Image("resource/img/volume-max.png"));
        ImageView volume_mute_image = new ImageView(new Image("resource/img/volume-mute.png"));
        volume_max_image.setFitWidth(35);
        volume_max_image.setFitHeight(35);
        volume_mute_image.setFitWidth(35);
        volume_mute_image.setFitHeight(35);
        ingameaudio = new Label();
        ingameaudio.setGraphic(volume_max_image);
        ingameaudio.setOnMouseClicked((MouseEvent event) -> {
            if (ingameaudio.getGraphic() == volume_max_image) {
                ingameaudio.setGraphic(volume_mute_image);
            } else {
                ingameaudio.setGraphic(volume_max_image);
            }
            if (updatingaudio) {
                updatingaudio = false;
                Event.fireEvent(gameoveraudio, new MouseEvent(MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY,
                        1, false, false, false, false, false, false, false, false, false, false, null));
                Event.fireEvent(menuaudio, new MouseEvent(MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY,
                        1, false, false, false, false, false, false, false, false, false, false, null));
                updatingaudio = true;
            }
            _manager.handleAudioButtonClicked();
        });
        /* Add all components to ingame menu */
        ingameMenu.getChildren().addAll(reset_button, menu_button, ingameaudio);

        BorderPane board = new BorderPane();
        blueCards = new HBox();
        blueCards.setAlignment(Pos.CENTER);
        blueCards.setSpacing(5);
        for (int i = 0; i < 6; i++) {
            Label newPile = new Label();
            newPile.setPrefSize(100, 200);
            newPile.setStyle("-fx-border-width: 2px;-fx-border-color: blue;");
            blueCards.getChildren().add(newPile);
        }
        redCards = new HBox();
        redCards.setAlignment(Pos.CENTER);
        redCards.setSpacing(5);
        for (int i = 0; i < 6; i++) {
            Label newPile = new Label();
            newPile.setPrefSize(100, 200);
            newPile.setStyle("-fx-border-width: 2px;-fx-border-color: red;");
            redCards.getChildren().add(newPile);
        }

        board.setTop(blueCards);
        board.setBottom(redCards);
        BorderPane.setMargin(board, new Insets(10, 0, 10, 150));

        /* Set componenets in the screen */
        inGameScreen.setCenter(board);
        inGameScreen.setRight(ingameMenu);
        /* Set it invisible initially*/
        inGameScreen.setVisible(false);
        root.getChildren().add(inGameScreen);
    }

    private void initializeGameOverScreen() {
        gameOverScreen = new BorderPane();

        /* Created vertical pane */
        VBox game_over_list = new VBox();
        /* Set vertical pane alignment IMPORTANT */
        game_over_list.setAlignment(Pos.CENTER);
        /* Set spacing for the vertical pane */
        game_over_list.setSpacing(5);

        /* Create winner announcement */
        HBox announcement = new HBox();
        /* Set horizontal pane alignment IMPORTANT */
        announcement.setAlignment(Pos.CENTER);
        /* Create texts */
        Label winner = new Label();
        Label won = new Label(" Won!");
        /* Style texts */
        winner.setStyle("-fx-font-size: 69px;");
        won.setStyle("-fx-font-size: 69px;");
        /* Add labels to annoucement */
        announcement.getChildren().addAll(winner, won);

        /* Create buttons */
        Button menu_button = new Button("Menu");
        Button restart_button = new Button("Restart");
        Button exit_button = new Button("Exit");

        /* Set button handlers */
        menu_button.setOnAction((ActionEvent event) -> {
            _manager.handleMenuButtonClicked();
        });
        restart_button.setOnAction((ActionEvent event) -> {
            _manager.handleRestartButtonClicked();
        });
        exit_button.setOnAction((ActionEvent event) -> {
            _manager.handleExitButtonClicked();
        });

        /* Resize buttons */
        setButtonSize(menu_button, restart_button, exit_button);

        /* Set audio and handler */
        ImageView volume_max_image = new ImageView(new Image("resource/img/volume-max.png"));
        ImageView volume_mute_image = new ImageView(new Image("resource/img/volume-mute.png"));
        volume_max_image.setFitWidth(35);
        volume_max_image.setFitHeight(35);
        volume_mute_image.setFitWidth(35);
        volume_mute_image.setFitHeight(35);
        gameoveraudio = new Label();
        gameoveraudio.setPadding(new Insets(10, 0, 0, 0));
        gameoveraudio.setGraphic(volume_max_image);
        gameoveraudio.setOnMouseClicked((MouseEvent event) -> {
            if (gameoveraudio.getGraphic() == volume_max_image) {
                gameoveraudio.setGraphic(volume_mute_image);
            } else {
                gameoveraudio.setGraphic(volume_max_image);
            }
            if (updatingaudio) {
                updatingaudio = false;
                Event.fireEvent(menuaudio, new MouseEvent(MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY,
                        1, false, false, false, false, false, false, false, false, false, false, null));
                Event.fireEvent(ingameaudio, new MouseEvent(MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY,
                        1, false, false, false, false, false, false, false, false, false, false, null));
                updatingaudio = true;
            }
            _manager.handleAudioButtonClicked();
        });

        game_over_list.getChildren().addAll(announcement, menu_button, restart_button, exit_button, gameoveraudio);

        gameOverScreen.setCenter(game_over_list);
        /* Set it invisible initially */
        gameOverScreen.setVisible(false);
        root.getChildren().add(gameOverScreen);
    }

    private void initializeHelpScreen() {
        ruleScreen = new BorderPane();

        /* Make dark background */
        ruleScreen.setStyle("-fx-background-color: rgba(0,0,0,0.8);");

        /* Set handler for screen */
        ruleScreen.setOnMouseClicked((MouseEvent event) -> {
            _manager.handleRuleScreenClicked();
        });

        /* Create a horizontal pane to store pictures */
        HBox image_list = new HBox();

        /* Set horizontal pane alignment IMPORTANT */
        image_list.setAlignment(Pos.CENTER);

        /* Set spacing for the horizontal pane */
        image_list.setSpacing(160);

        /* Get image from local */
        ImageView rule1 = new ImageView(new Image("resource/img/rule1.jpg"));
        ImageView rule2 = new ImageView(new Image("resource/img/rule2.jpg"));

        /* Resize images */
        rule1.setPreserveRatio(true);
        rule2.setPreserveRatio(true);
        rule1.setFitHeight(_height);
        rule2.setFitHeight(_height);

        /* Add images to the image list */
        image_list.getChildren().addAll(rule1, rule2);

        /* Place the image list at the center of the screen */
        ruleScreen.setCenter(image_list);
        /* Set it invisible initially */
        ruleScreen.setVisible(false);
        root.getChildren().add(ruleScreen);
    }

    public void switchScreen(ScrimishScreens screen) {
        switch (screen) {
            case MENU_SCREEN:
                screenTransition(currentScreen, menuScreen);
                currentScreen = menuScreen;
                break;
            case IN_GAME_SCREEN:
                screenTransition(currentScreen, inGameScreen);
                currentScreen = inGameScreen;
                inGameScreen.requestFocus();
                break;
            case GAME_OVER_SCREEN:
                screenTransition(currentScreen, gameOverScreen);
                currentScreen = gameOverScreen;
                break;
            case RULE_SCREEN:
                screenTransition(currentScreen, ruleScreen);
                currentScreen = ruleScreen;
                break;
            default:

        }
    }

    private void screenTransition(BorderPane a, BorderPane b) {
        a.setVisible(false);
        b.setVisible(true);
    }

    private void setButtonSize(Button... buttons) {
        for (Button button : buttons) {
            button.setPrefSize(150, 50);
        }
    }

    public void resetBoard() {
        /* Clean the 6 labels' images*/
        for (int i = 0; i < 6; i++) {
            /* Clean and set handler */
            ((Label) blueCards.getChildren().get(i)).setGraphic(null);
            ((Label) blueCards.getChildren().get(i)).setOnMouseClicked((MouseEvent e) -> {
                if(e.getClickCount() >= 2 && blueCards.getChildren().indexOf(e.getSource()) == 5){
                    _manager.rotateBlueCard();
                    displayCard();
                }
                else if(cardNotClicked){
                    cardSourceColor = ScrimishColors.BLUE;
                    cardSourcePile = blueCards.getChildren().indexOf(e.getSource());
                    cardNotClicked = false;
                    _manager.playCardSound();
                }
                else{
                    cardDestinationColor = ScrimishColors.BLUE;
                    cardDestinationPile = blueCards.getChildren().indexOf(e.getSource());
                    _manager.cardFight(cardSourceColor, cardSourcePile, cardDestinationColor, cardDestinationPile);
                    cardNotClicked = true;
                    displayCard();
                }
            });
            ((Label) redCards.getChildren().get(i)).setGraphic(null);
            ((Label) redCards.getChildren().get(i)).setOnMouseClicked((MouseEvent e) -> {
                if(e.getClickCount() >= 2 && redCards.getChildren().indexOf(e.getSource()) == 5){
                    _manager.rotateRedCard();
                    displayCard();
                }
                else if(cardNotClicked){
                    cardSourceColor = ScrimishColors.RED;
                    cardSourcePile = redCards.getChildren().indexOf(e.getSource());
                    cardNotClicked = false;
                    _manager.playCardSound();
                }
                else{
                    cardDestinationColor = ScrimishColors.RED;
                    cardDestinationPile = redCards.getChildren().indexOf(e.getSource());
                    _manager.cardFight(cardSourceColor, cardSourcePile, cardDestinationColor, cardDestinationPile);
                    cardNotClicked = true;
                    displayCard();
                }
            });
        }
        _manager.resetCardBoard();
        displayCard();
    }
  
    public void displayCard(){
        for(int i = 0; i < 6; i++){
            String blueCard = _manager.getBlueCard(i);
            if(blueCard == null){
                ((Label) blueCards.getChildren().get(i)).setGraphic(null);
            }
            else{
                ((Label) blueCards.getChildren().get(i)).setGraphic(createImageView(blueCard));
            }
            String redCard = _manager.getRedCard(i);
            if(redCard == null){
                ((Label) redCards.getChildren().get(i)).setGraphic(null);
            }
            else{
                ((Label) redCards.getChildren().get(i)).setGraphic(createImageView(redCard));
            }
        }
    }
  
    private ImageView createImageView(String name){
        switch(name){
            case "archerBlue":
                return new ImageView(new Image("resource/img/archerBlue.jpg", 100, 200, true, true));
            case "archerRed":
                return new ImageView(new Image("resource/img/archerRed.jpg", 100, 200, true, true));
            case "crownBlue":
                return new ImageView(new Image("resource/img/crownBlue.jpg", 100, 200, true, true));
            case "crownRed":
                return new ImageView(new Image("resource/img/crownRed.jpg", 100, 200, true, true));
            case "daggerBlue":
                return new ImageView(new Image("resource/img/daggerBlue.jpg", 100, 200, true, true));
            case "daggerRed":
                return new ImageView(new Image("resource/img/daggerRed.jpg", 100, 200, true, true));
            case "halberdBlue":
                return new ImageView(new Image("resource/img/halberdBlue.jpg", 100, 200, true, true));
            case "halberdRed":
                return new ImageView(new Image("resource/img/halberdRed.jpg", 100, 200, true, true));
            case "longSwordBlue":
                return new ImageView(new Image("resource/img/longSwordBlue.jpg", 100, 200, true, true));
            case "longSwordRed":
                return new ImageView(new Image("resource/img/longSwordRed.jpg", 100, 200, true, true));
            case "morningStarBlue":
                return new ImageView(new Image("resource/img/morningStarBlue.jpg", 100, 200, true, true));
            case "morningStarRed":
                return new ImageView(new Image("resource/img/morningStarRed.jpg", 100, 200, true, true));
            case "shieldBlue":
                return new ImageView(new Image("resource/img/shieldBlue.jpg", 100, 200, true, true));
            case "shieldRed":
                return new ImageView(new Image("resource/img/shieldRed.jpg", 100, 200, true, true));
            case "swordBlue":
                return new ImageView(new Image("resource/img/swordBlue.jpg", 100, 200, true, true));
            case "swordRed":
                return new ImageView(new Image("resource/img/swordRed.jpg", 100, 200, true, true));
            case "warAxeBlue":
                return new ImageView(new Image("resource/img/warAxeBlue.jpg", 100, 200, true, true));
            case "warAxeRed":
                return new ImageView(new Image("resource/img/warAxeRed.jpg", 100, 200, true, true));
            default:
                return null;
        }
    }

    public enum ScrimishScreens {
        MENU_SCREEN, IN_GAME_SCREEN, GAME_OVER_SCREEN, RULE_SCREEN
    }

    public enum ScrimishColors {
        BLUE, RED
    }

    public Stage getPrimaryStage() {
        return _primaryStage;
    }

    public StackPane getRoot() {
        return root;
    }

    public BorderPane getMenuScreen() {
        return menuScreen;
    }

    public BorderPane getRuleScreen() {
        return ruleScreen;
    }

    public BorderPane getInGameScreen() {
        return inGameScreen;
    }

    public BorderPane getGameOverScreen() {
        return gameOverScreen;
    }

}

ScrimishManager.java

import java.io.File;
import java.util.ArrayList;
import java.util.LinkedList;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.media.AudioClip;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.paint.Paint;
import view.ScrimishUI;
import view.ScrimishUI.ScrimishColors;

public class ScrimishManager {
  
    private final ScrimishUI _ui;
  
    private MediaPlayer music;
    private AudioClip buttonSound;
    private AudioClip victorySound;
    private AudioClip cardSound;
  
    private ArrayList<LinkedList<String>> blueCards;
    private ArrayList<LinkedList<String>> redCards;
  
    public ScrimishManager(ScrimishUI ui){
        _ui = ui;
        blueCards = new ArrayList<LinkedList<String>>(6);
        redCards = new ArrayList<LinkedList<String>>(6);
        for(int i = 0; i < 6; i++){
            blueCards.add(new LinkedList<String>());
            redCards.add(new LinkedList<String>());
        }
        initializeAudio();
    }
  
    public void handleVictory(ScrimishUI.ScrimishColors color){
        Label winner = (Label)((HBox)((VBox)_ui.getGameOverScreen().getCenter()).getChildren().get(0)).getChildren().get(0);
        switch(color){
            case BLUE:
                winner.setText("Blue");
                winner.setTextFill(Paint.valueOf("blue"));
                break;
            case RED:
                winner.setText("Red");
                winner.setTextFill(Paint.valueOf("red"));
                break;
            default:
              
        }
        _ui.switchScreen(ScrimishUI.ScrimishScreens.GAME_OVER_SCREEN);
        playVictorySound();
    }
  
    public void resetCardBoard(){
        for(int i = 0; i < 6; i++){
            blueCards.get(i).clear();
            redCards.get(i).clear();
        }
        blueCards.get(5).add("archerBlue");
        redCards.get(5).add("archerRed");
        blueCards.get(5).add("crownBlue");
        redCards.get(5).add("crownRed");
        blueCards.get(5).add("daggerBlue");
        redCards.get(5).add("daggerRed");
        blueCards.get(5).add("halberdBlue");
        redCards.get(5).add("halberdRed");
        blueCards.get(5).add("longSwordBlue");
        redCards.get(5).add("longSwordRed");
        blueCards.get(5).add("morningStarBlue");
        redCards.get(5).add("morningStarRed");
        blueCards.get(5).add("shieldBlue");
        redCards.get(5).add("shieldRed");
        blueCards.get(5).add("swordBlue");
        redCards.get(5).add("swordRed");
        blueCards.get(5).add("warAxeBlue");
        redCards.get(5).add("warAxeRed");
    }
  
    public void rotateBlueCard(){
        blueCards.get(5).addFirst(blueCards.get(5).removeLast());
    }
  
    public void rotateRedCard(){
        redCards.get(5).addFirst(redCards.get(5).removeLast());
    }
  
    public String getBlueCard(int pile){
        if(blueCards.get(pile).isEmpty()){
            return null;
        }
        return blueCards.get(pile).getLast();
    }
  
    public String getRedCard(int pile){
        if(redCards.get(pile).isEmpty()){
            return null;
        }
        return redCards.get(pile).getLast();
    }
  

    public void cardFight(ScrimishColors sourceColor, int sourcePile, ScrimishColors destinColor, int destinPile){
        if(sourceColor == destinColor && sourcePile == 5){
            if(sourceColor == ScrimishColors.BLUE){
                blueCards.get(destinPile).addFirst(blueCards.get(sourcePile).removeLast());
            }
            else{
                redCards.get(destinPile).addFirst(redCards.get(sourcePile).removeLast());
            }
        }
        else{
            playCardSound();
            handleVictory(sourceColor);
        }
    }
  
    private void initializeAudio(){
        playMusic();
        buttonSound = new AudioClip(new File("src/resource/music/ButtonSound - Sunnyside.aiff").toURI().toString());
        victorySound = new AudioClip(new File("src/resource/music/powerup-success-Gabrielaraujo.wav").toURI().toString());
        cardSound = new AudioClip(new File("src/resource/music/card-flip-f4ngy.wav").toURI().toString());
    }
  
    private void playMusic(){
        music = new MediaPlayer(new Media(new File("src/resource/music/SDS - Hiroyuki Sawano.mp3").toURI().toString()));
        music.setVolume(0.1);
        music.setOnEndOfMedia(() -> {
            music.stop();
            music.play();
        });
        music.play();
    }
  
    private void playButtonClickedSound(){
        buttonSound.play();
    }
  
    private void playVictorySound(){
        victorySound.play();
    }
  
    public void playCardSound(){
        cardSound.play();
    }
  
    public void handleEnterButtonClicked(){
        playButtonClickedSound();
        _ui.switchScreen(ScrimishUI.ScrimishScreens.IN_GAME_SCREEN);
    }
  
    public void handleRuleButtonClicked(){
        playButtonClickedSound();
        _ui.switchScreen(ScrimishUI.ScrimishScreens.RULE_SCREEN);
    }
  
    public void handleExitButtonClicked(){
        playButtonClickedSound();
        _ui.getPrimaryStage().close();
    }
  
    public void handleRuleScreenClicked(){
        _ui.switchScreen(ScrimishUI.ScrimishScreens.MENU_SCREEN);
    }
  
  
    public void handleMenuButtonClicked(){
        _ui.switchScreen(ScrimishUI.ScrimishScreens.MENU_SCREEN);
    }
  
    public void handleResetButtonClicked(){
        _ui.resetBoard();
    }
  
    public void handleRestartButtonClicked(){
        _ui.resetBoard();
        _ui.switchScreen(ScrimishUI.ScrimishScreens.IN_GAME_SCREEN);
    }
  
    public void handleAudioButtonClicked(){
        if(music.isMute()){
            /* Unmute */
            music.setMute(false);
        }
        else{
            /* Mute */
            music.setMute(true);
        }
    }
  
}

note:
due to limited character i cant able to post all files