Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author Dean
- */
- import java.util.Timer;
- import java.util.TimerTask;
- import javafx.application.Application;
- import javafx.application.Platform;
- import java.io.IOException;
- import java.util.ArrayList;
- import javafx.application.Application;
- import javafx.event.EventHandler;
- import javafx.event.ActionEvent;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.TextArea;
- import javafx.scene.control.TextField;
- import javafx.scene.effect.DropShadow;
- import javafx.scene.image.Image;
- import javafx.scene.image.ImageView;
- import javafx.scene.input.MouseEvent;
- import javafx.scene.layout.GridPane;
- import javafx.scene.layout.HBox;
- import javafx.scene.layout.StackPane;
- import javafx.scene.layout.VBox;
- import javafx.scene.paint.Color;
- import javafx.scene.text.Text;
- import javafx.stage.Stage;
- public class Interface extends Application {
- /**
- * @todo update the interface so that it displays real player information
- * refreshes whenever the next player is loaded
- * players take goes
- */
- GridPane grid;
- int previousPlayersAgeIndex;
- Player [] players;
- Player currentPlayer;
- TextField input;
- Timer timer;
- TextArea console;
- TextArea playerConsole;
- StackPane stackPane,playerConsoleStack, root;
- Text job, number,money, debt, username, islandName;
- Button takeLoan, payDebt;
- Button accept, confirm, decline;
- Button ageOne, ageTwo, ageThree, ageFour, ageFive, ageSix, ageSeven;
- Button volcanoButton;
- Button island1, island2, island3, island4, island5;//Travel Space Button - Delete?;
- Button [] ageButtons;
- ImageView boatImage;
- ImageView planeImage;
- HBox badgeBox, secondRow, minimapBox, numberBox, volcanoButtonBox, firstRow;
- HBox usernameBox, debtBox,fourthRow,buttonBox,fifthRow, cardCareerDescriptionBox, islandButtonBox;
- HBox careerButtonBox;
- VBox userDetails,financeDetails,thirdRow;
- ImageView carImageView;
- // Image defaultCar = new Image("img/defaultCar.png");
- // Image partner = new Image("img/partner.png");
- // Image oneCh = new Image("img/1k.png");
- // Image twoCh = new Image("img/2k.png");
- // Image threeCh = new Image("img/3k.png");
- // Image fourCh = new Image("img/4k.png");
- // Image oneChThreeP = new Image("img/1k3p.png");
- // Image oneChTwoP = new Image("img/1k2p.png");
- // Image oneChOneP = new Image("img/1k1p.png");
- // Image twoChOneP = new Image("img/2k1p.png");
- // Image twoChTwoP = new Image("img/2k2p.png");
- // Image threeChOneP = new Image("img/3k1p.png");
- // Image oneP = new Image("img/1p.png");
- // Image twoP = new Image("img/2p.png");
- // Image threeP = new Image("img/3p.png");
- // Image fourP = new Image("img/4p.png");
- //
- // Image carImage;
- DropShadow borderGlow;
- Scene scene;
- String dialog = "";
- boolean valueEntered;
- boolean waitForAccept;
- boolean isPayingDebt;
- boolean isTakingLoan;
- boolean isTakingGoldToken;
- boolean isBuyingHouse;
- boolean isPayingBankerForExams;//they are going to
- boolean canPayBankerForExams;//they can
- boolean isSpinToWin;
- boolean acceptedHouse;
- String inp;
- Image islandPath,planePath, boatPath;
- ImageView islandImage,spinnerImage;
- VBox spinnerImageBox, carImageBox;
- //Code used for graduate career card
- GridPane gridCareer;
- CareerCardholder careerCards;
- GraduateCareer graduateCard,option1,option2,option3;
- TextField description1, description2, description3;
- Button career1, career2, career3;
- Boolean chosenCareer=false;
- Minimap map;
- ///////////////////////////////////////////////////////////////////////////////
- /**
- * screen objects go here so they can be accessed from other classes
- */
- HBox playerInput;
- boolean waitingOnPlayerSpin; //the boolean value indicating that the player needs to spin to move forward set amount of spaces
- boolean spaceRequiresSpin = false;
- boolean accepted = false;
- boolean declined = true;
- boolean spinnerDisabled;
- Board board;
- Island island;
- int i=0;
- int goldToken;
- public static void main(String[] args) {
- launch(args);
- }
- public void start(Stage stage) throws IOException {
- stage.setTitle("Game of Life");
- spinnerDisabled=false;
- waitingOnPlayerSpin = true;
- isPayingDebt = false;
- isTakingLoan = false;
- isBuyingHouse = false;
- board = new Board(this, players);
- //border effect that will be applied to the node representing the player's current age.
- borderGlow = new DropShadow();
- borderGlow.setColor(Color.GREEN);
- borderGlow.setHeight(30);
- borderGlow.setWidth(30);
- grid = new GridPane();
- grid.setPadding(new Insets(25, 25, 25, 25));
- grid.setVgap(0);
- grid.setAlignment(Pos.CENTER);
- grid.setGridLinesVisible(false);
- //loading in the minimap
- map = new Minimap();
- map.update(board);
- root = map.getRoot();
- spinnerImage = new ImageView(board.spinner.spinnerImage);
- spinnerImage.setFitWidth(275);
- spinnerImage.setFitHeight(275);
- spinnerImageBox = new VBox();
- spinnerImageBox.getChildren().add(spinnerImage);
- spinnerImageBox.setPadding(new Insets(0, 0, 30, 400));
- // carImage = new Image("img/defaultCar.png");
- carImageView = new ImageView(board.currentPlayer.carImage);
- carImageBox = new VBox();
- carImageBox.getChildren().add(carImageView);
- carImageBox.setPadding(new Insets(0,0, 30, 100));
- Button volcanoButton = new Button("Volcano");
- volcanoButton.getStyleClass().add("redButton");
- number = new Text("-");
- number.getStyleClass().add("largeNumber");
- numberBox = new HBox();
- numberBox.getChildren().add(number);
- numberBox.setPadding(new Insets(75, 0, 0, 502));
- volcanoButtonBox = new HBox();
- volcanoButtonBox.getChildren().add(volcanoButton);
- volcanoButtonBox.setAlignment(Pos.BOTTOM_RIGHT);
- volcanoButtonBox.setPadding(new Insets(0, 100, 0, 0)); //250 502
- spinnerImageBox.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- if(!spinnerDisabled) {
- if(spaceRequiresSpin) {
- board.currentPlayer.space.action();
- return;
- }
- if(waitingOnPlayerSpin && !spaceRequiresSpin) { //we don't want the player to advance to the next space whenever the space they are currently on requires a spin to complete its action
- updatePositionAndRefresh();
- }
- }
- });
- stackPane = new StackPane();
- stackPane.getChildren().addAll(numberBox, carImageBox, volcanoButtonBox, spinnerImageBox);
- firstRow = new HBox();
- firstRow.getChildren().addAll(root, stackPane);
- firstRow.setPadding(new Insets(0, 0, 10, 0));
- ageOne = new Button("18");
- ageOne.getStyleClass().add("roundButton");
- ageTwo = new Button("21");
- ageTwo.getStyleClass().add("roundButton");
- ageThree = new Button("30");
- ageThree.getStyleClass().add("roundButton");
- ageFour = new Button("40");
- ageFour.getStyleClass().add("roundButton");
- ageFive = new Button("50");
- ageFive.getStyleClass().add("roundButton");
- ageSix = new Button("60");
- ageSix.getStyleClass().add("roundButton");
- ageSeven = new Button("70");
- ageSeven.getStyleClass().add("roundButton");
- Button [] temp = {ageOne, ageTwo, ageThree, ageFour, ageFive, ageSix, ageSeven};
- ageButtons = temp;
- secondRow = new HBox();
- secondRow.getChildren().addAll(ageOne, ageTwo, ageThree, ageFour, ageFive, ageSix, ageSeven);
- secondRow.setPadding(new Insets(0, 0, 15, 0));
- planePath = new Image("img/greenPlane.png");
- planeImage = new ImageView(planePath);
- planeImage.setFitHeight(25);
- planeImage.setFitWidth(25);
- boatPath = new Image("img/greenBoat.png");
- boatImage = new ImageView(boatPath);
- boatImage.setFitHeight(25);
- boatImage.setFitWidth(25);
- username = new Text();
- username.getStyleClass().add("userText");
- job = new Text();
- job.getStyleClass().add("userText");
- usernameBox = new HBox();
- usernameBox.getChildren().add(username);
- islandName= new Text();
- islandName.getStyleClass().add("userText");
- badgeBox = new HBox();
- badgeBox.setPadding(new Insets(0, 0, 0, 5));
- badgeBox.getChildren().addAll(planeImage, boatImage);
- usernameBox.getChildren().add(badgeBox);
- userDetails = new VBox();
- userDetails.getChildren().addAll(usernameBox, job, islandName);
- userDetails.setPadding(new Insets(0, 0, 10, 5));
- money = new Text();
- money.getStyleClass().add("moneyText");
- debt = new Text();
- debt.getStyleClass().add("debtText");
- //early retirement
- Button earlyRetire = new Button("Retire Early");
- earlyRetire.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- new EndScreen(this, players);
- });
- takeLoan = new Button("Take Loan");
- takeLoan.getStyleClass().add("greenButton");
- takeLoan.setOnAction(new EventHandler<ActionEvent>() {
- public void handle(ActionEvent event) {
- isTakingLoan = true;
- System.out.println("Is taking loan"+isTakingLoan);
- disableInputNodes();
- input.setPromptText("Insert amount");
- }
- });
- /**
- * @author Dean
- */
- payDebt = new Button("Pay Debt");
- payDebt.getStyleClass().add("redButton");
- payDebt.setOnAction(new EventHandler<ActionEvent>() {
- public void handle(ActionEvent event) {
- isPayingDebt = true;
- disableInputNodes();
- input.setPromptText("Insert amount");
- }
- });
- debtBox = new HBox();
- debtBox.getChildren().add(debt);
- debtBox.getChildren().add(takeLoan);
- debtBox.getChildren().add(payDebt);
- financeDetails = new VBox();
- financeDetails.getChildren().addAll(money, debtBox);
- financeDetails.setPadding(new Insets(0, 0, 10, 5));
- //island buttons
- island1 = new Button(board.islandNames[1]);
- island1.getStyleClass().add("yellowButton");
- island1.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- System.out.println("Island 1 button pressed");
- TravelSpace.islandID = 1;
- TravelSpace.islandPicked = true;
- board.currentPlayer.space.action();
- });
- island2 = new Button(board.islandNames[2]);
- island2.getStyleClass().add("yellowButton");
- island2.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- System.out.println("Island 2 button pressed");
- TravelSpace.islandID = 2;
- TravelSpace.islandPicked = true;
- board.currentPlayer.space.action();
- });
- island3 = new Button(board.islandNames[3]);
- island3.getStyleClass().add("yellowButton");
- island3.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- System.out.println("Island 3 button pressed");
- TravelSpace.islandID = 3;
- TravelSpace.islandPicked = true;
- board.currentPlayer.space.action();
- });
- island4 = new Button(board.islandNames[4]);
- island4.getStyleClass().add("yellowButton");
- island4.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- System.out.println("Island 4 button pressed");
- TravelSpace.islandID = 4;
- TravelSpace.islandPicked = true;
- board.currentPlayer.space.action();
- });
- island5 = new Button(board.islandNames[5]);
- island5.getStyleClass().add("yellowButton");
- island5.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- System.out.println("Island 5 button pressed");
- TravelSpace.islandID = 5;
- TravelSpace.islandPicked = true;
- board.currentPlayer.space.action();
- });
- islandButtonBox = new HBox();
- islandButtonBox.setPadding(new Insets(0, 75, 0, 0));
- islandButtonBox.getChildren().addAll(earlyRetire,island1, island2, island3, island4);
- islandButtonBox.setAlignment(Pos.CENTER_RIGHT);
- financeDetails.getChildren().add(islandButtonBox);
- thirdRow = new VBox();
- thirdRow.getChildren().addAll(userDetails, financeDetails);
- console = new TextArea("");
- console.setWrapText(true);
- console.setPrefWidth(850);
- console.setPrefHeight(200);
- console.setDisable(false);
- console.getStyleClass().add("greyTextField");
- accept = new Button("Accept");
- accept.getStyleClass().add("greenButton");
- accept.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- if(isBuyingHouse) {
- System.out.println("Accept pressed");
- acceptedHouse = true;
- board.currentPlayer.space.action();
- }
- else if(canPayBankerForExams){
- isPayingBankerForExams=true;
- board.currentPlayer.space.action();
- }
- });
- decline = new Button("Decline");
- decline.getStyleClass().add("redButton");
- decline.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- if(isBuyingHouse) {
- acceptedHouse = false;
- board.currentPlayer.space.action();
- }
- else if(canPayBankerForExams){
- isPayingBankerForExams=false;
- board.currentPlayer.space.action();
- }
- });
- buttonBox = new HBox();
- buttonBox.getChildren().addAll(accept, decline);
- buttonBox.setPadding(new Insets(0, 8, 5, 0));
- buttonBox.setAlignment(Pos.BOTTOM_RIGHT);
- StackPane consoleStackPane = new StackPane();
- consoleStackPane.getChildren().addAll(console, buttonBox);
- fourthRow = new HBox();
- fourthRow.getChildren().add(consoleStackPane);
- fourthRow.setPadding(new Insets(0, 0, 10, 0));
- playerConsole = new TextArea("This is where the player will be prompted");
- playerConsole.setPrefWidth(850);
- playerConsole.setPrefHeight(250);
- playerConsole.setDisable(false);
- playerConsole.getStyleClass().add("greyTextField");
- confirm = new Button("Confirm");
- confirm.getStyleClass().add("greenButton");
- confirm.setOnAction(new EventHandler<ActionEvent>() {
- public void handle(ActionEvent event) {
- if(isPayingDebt) { //if the player wishes to pay off debt - would be set to true if they have pressed the pay debt button.
- if(validateDebtInput()) { //input in the text field needs to be validated to make sure it is a number and within bounds
- System.out.println("Made it in to debt");
- board.currentPlayer.payDebt(Integer.valueOf(input.getText()));
- isPayingDebt = false;
- }
- }
- if(isTakingLoan) {
- if(validateLoanInput()) {
- System.out.println("Validated the input");
- board.currentPlayer.takeLoan(Integer.valueOf(input.getText()));
- System.out.println("Player's balance is now"+board.currentPlayer.balance);
- isTakingLoan = false;
- }
- }
- if(isTakingGoldToken) {
- if(validateGoldTokenInput()) {
- goldToken = Integer.parseInt(input.getText());
- valueEntered = true;
- board.currentPlayer.space.action();
- }
- }
- debt.setText(String.valueOf(board.currentPlayer.getDebt()));
- updatePlayerMoney();
- disableInputNodes();
- resetInput();
- }
- });
- input = new TextField(dialog);
- input.setPrefWidth(200);
- playerInput = new HBox();
- playerInput.getChildren().addAll(input, confirm);
- playerInput.setPadding(new Insets(0, 8, 5, 0));
- playerInput.setAlignment(Pos.BOTTOM_RIGHT);
- playerConsoleStack = new StackPane();
- playerConsoleStack.getChildren().addAll(playerConsole, playerInput);
- fifthRow = new HBox();
- fifthRow.getChildren().add(playerConsoleStack);
- createCareerUI();
- grid.add(firstRow, 0, 0);
- grid.add(secondRow, 0, 1);
- grid.add(thirdRow, 0, 2);
- grid.add(careerButtonBox, 0,0);
- grid.add(fourthRow, 0, 3);
- grid.add(cardCareerDescriptionBox, 0,1);
- grid.add(fifthRow, 0, 4);
- career1.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- graduateCard=option1;
- updateCareerInfo();
- });
- career2.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- graduateCard=option2;
- updateCareerInfo();
- });
- career3.addEventHandler(MouseEvent.MOUSE_RELEASED, (MouseEvent e) -> {
- graduateCard=option3;
- updateCareerInfo();
- });
- updateInterface(true);
- Scene scene = new Scene(grid, 1200, 1000);
- scene.getStylesheets().add(Interface.class.getResource("Interface.css").toExternalForm());
- stage.setScene(scene);
- stage.show();
- }
- public void updateCareerInfo(){
- chosenCareer=true;
- board.currentPlayer.changeToGraduate(graduateCard);
- board.currentPlayer.space.interact();
- board.currentPlayer.space.action();
- setUpMain();
- updateCareerUI();
- }
- public void updateInterface(boolean firstUpdate) {
- //setting text fields to the new player information
- username.setText(board.currentPlayer.getName());
- job.setText(board.currentPlayer.getJobTitle());
- islandName.setText(board.currentPlayer.island.islandName);
- money.setText(String.valueOf("£" + board.currentPlayer.getBalance()));
- debt.setText(String.valueOf("£" + board.currentPlayer.getDebt()));
- if(!firstUpdate) {
- //removing the previous player's highlighted age - no need to do this if it's the first update
- ageButtons[previousPlayersAgeIndex].setEffect(null);
- }
- if(board.currentPlayer.space instanceof Exams && !board.currentPlayer.passedExams) {
- spaceRequiresSpin = true;
- }
- //getting the next player, or who is now the current player's age and highlighting the correct node
- ageButtons[board.currentPlayer.findIndexOfCurrentAge()].setEffect(borderGlow);
- //setting the 'new' current player's age button index to the 'previous' variable for the next update - as it will need to be switched off the next player
- previousPlayersAgeIndex = board.currentPlayer.findIndexOfCurrentAge();
- //resetting other interface elements in preparation for the next player
- setPlayerConsoleToDefault();
- setSpinnerNumberToDefault();
- //check if player's car has gained new car items and update image accordingly
- //board.currentPlayer.checkCar();
- // updateCar();
- //if they have different badges to the player preceding them, these need to be removed and their badges added
- removeBadges();
- addBadges();
- //disabling input nodes that are not required for the current space
- disableInputNodes();
- outputToConsole();
- broadCast();
- }
- public void outputToConsole() {
- playerConsole.setText(board.currentPlayer.space.interact());
- }
- public void addBadges() {
- if(board.currentPlayer.hasBoat() && !badgeBox.getChildren().contains(boatImage) ) {
- badgeBox.getChildren().add(boatImage);
- }
- if(board.currentPlayer.hasPlane() && !badgeBox.getChildren().contains(planeImage) ) {
- badgeBox.getChildren().add(planeImage);
- }
- }
- public void removeBadges() {
- if(!board.currentPlayer.hasBoat() && badgeBox.getChildren().contains(boatImage)) {
- badgeBox.getChildren().remove(boatImage);
- }
- if(!board.currentPlayer.hasPlane() && badgeBox.getChildren().contains(planeImage)) {
- badgeBox.getChildren().remove(planeImage);
- }
- }
- public void setSpinnerNumber(int num) {
- number.setText(String.valueOf(num));
- }
- public void setSpinnerNumberToDefault() {
- number.setText("-");
- }
- //the player console is the lower of the two, it outputs player specific information.
- public void setPlayerConsoleToDefault() {
- playerConsole.setText("");
- }
- //for deleting unrequired input nodes whenever the space doesn't require them.
- public void disableInputNodes() {
- if(isPayingDebt) { //if they are updating the interface to pay debt, that's not a input type for a space - has to be updated seperately.
- accept.setDisable(true);
- decline.setDisable(true);
- input.setDisable(false);
- confirm.setDisable(false);
- }
- else if(isTakingLoan) {
- accept.setDisable(true);
- decline.setDisable(true);
- input.setDisable(false);
- confirm.setDisable(false);
- }
- else {
- switch(board.currentPlayer.space.inputType) {
- case SPIN: input.setDisable(true);
- accept.setDisable(true);
- decline.setDisable(true);
- confirm.setDisable(true);
- island1.setDisable(true);
- island2.setDisable(true);
- island3.setDisable(true);
- island4.setDisable(true);
- island5.setDisable(true);
- break;
- case ACCEPT_DECLINE_LOAN: input.setDisable(true);
- confirm.setDisable(true);
- accept.setDisable(false);
- decline.setDisable(false);
- takeLoan.setDisable(false);
- payDebt.setDisable(false);
- island1.setDisable(true);
- island2.setDisable(true);
- island3.setDisable(true);
- island4.setDisable(true);
- island5.setDisable(true);
- break;
- case ACCEPT: input.setDisable(true);
- confirm.setDisable(true);
- accept.setDisable(false);
- decline.setDisable(true);
- island1.setDisable(true);
- island2.setDisable(true);
- island3.setDisable(true);
- island4.setDisable(true);
- island5.setDisable(true);
- break;
- case TEXTINPUT: accept.setDisable(true);
- decline.setDisable(true);
- input.setDisable(false);
- confirm.setDisable(false);
- island1.setDisable(true);
- island2.setDisable(true);
- island3.setDisable(true);
- island4.setDisable(true);
- island5.setDisable(true);
- break;
- case NONE: accept.setDisable(true);
- decline.setDisable(true);
- input.setDisable(true);
- confirm.setDisable(true);
- island1.setDisable(true);
- island2.setDisable(true);
- island3.setDisable(true);
- island4.setDisable(true);
- island5.setDisable(true);
- break;
- case BUTTONS: accept.setDisable(true);
- decline.setDisable(true);
- input.setDisable(true);
- confirm.setDisable(true);
- island1.setDisable(false);
- island2.setDisable(false);
- island3.setDisable(false);
- island4.setDisable(false);
- island5.setDisable(false);
- break;
- }
- }
- if(isPayingDebt) {
- takeLoan.setDisable(true);
- }
- else if(!isPayingDebt) {
- takeLoan.setDisable(false);
- }
- if(isTakingLoan) {
- payDebt.setDisable(true);
- }
- else if(!isTakingLoan) {
- payDebt.setDisable(false);
- }
- //if the player has no debt then the button should not be activated.
- if(board.currentPlayer.debt <= 0) {
- payDebt.setDisable(true);
- }
- }
- public void getPlayerInput() {
- inp = input.getText();
- }
- public void resetInput() {
- input.clear();
- }
- public void updatePlayerMoney() {
- money.setText("£" +String.valueOf(board.currentPlayer.getBalance()));
- }
- public boolean validateDebtInput() {
- String text = input.getText(); //text field produces a string. need to get this string then convert to int for validation
- int amount = Integer.valueOf(text);
- if(amount >= 0 && amount <= board.currentPlayer.getDebt() && amount <= board.currentPlayer.getBalance()) {
- return true;
- }
- return false;
- }
- public boolean validateLoanInput() {
- String text = input.getText();
- int amount = Integer.valueOf(text);
- if(amount >= 10000 && amount % 10000 == 0) {
- return true;
- }
- return false;
- }
- public boolean validateGoldTokenInput() {
- String text = input.getText();
- int amount = Integer.valueOf(text);
- if(amount >= 1 && amount <= 10) {
- return true;
- }
- return false;
- }
- public void callSpaceAction() {
- board.currentPlayer.space.action();
- }
- public void updatePositionAndRefresh() {
- int spin = board.spinner.spin(); //spin to get how many spaces the player is going to travel
- board.currentPlayer.moveAmountOfSpaces(spin, false); //move the player to the appropriate space
- timer = new Timer();
- timer.schedule(new TimerTask() {
- public void run() {
- Platform.runLater(() -> {
- updateInterface(false);
- callSpaceAction();
- updateMinimap();
- });
- }
- }, 2750);
- }
- /**
- * if we indicate via the boolean value that the space the current player is on requires a spin,
- * the spinner, whenever clicked, will know to activate the interact method.
- * @param requires
- */
- public void setSpaceRequiresSpin(boolean requires) {
- spaceRequiresSpin = requires;
- }
- public void setOptionCards(){
- option1 = careerCards.getGraduateCard();
- option2 = careerCards.getGraduateCard();
- Boolean match=true;
- int i=0;
- while(match|| i<10){
- if(!(option1.getTitle().equals(option2.getTitle()))){
- match=false;
- i++;
- }
- else{
- option2=careerCards.getGraduateCard();
- }
- }
- match=true;
- i=0;
- option3 = careerCards.getGraduateCard();
- while(match||i<10){
- if(!((option1.getTitle().equals(option3.getTitle()))||(option2.getTitle().equals(option3.getTitle())))){
- match=false;
- i++;
- }
- else{
- option3=careerCards.getGraduateCard();
- }
- }
- }
- public void setUpCareerCard(){
- firstRow.setVisible(false);
- secondRow.setVisible(false);
- cardCareerDescriptionBox.setVisible(true);
- careerButtonBox.setVisible(true);
- }
- public void setUpMain(){
- firstRow.setVisible(true);
- secondRow.setVisible(true);
- cardCareerDescriptionBox.setVisible(false);
- careerButtonBox.setVisible(false);
- }
- public void updateCareerUI(){
- setOptionCards();
- career1.setText(option1.getTitle());
- career2.setText(option2.getTitle());
- career3.setText(option3.getTitle());
- description1.setText(option1.getDescription());
- description2.setText(option2.getDescription());
- description3.setText(option3.getDescription());
- }
- public void createCareerUI() {
- careerCards= new CareerCardholder();
- setOptionCards();
- career1= new Button(option1.getTitle());
- career2= new Button(option2.getTitle());
- career3= new Button(option3.getTitle());
- description1= new TextField(option1.getDescription());
- description1.setMinWidth(350);
- description2= new TextField(option2.getDescription());
- description2.setMinWidth(350);
- description3= new TextField(option3.getDescription());
- description3.setMinWidth(350);
- cardCareerDescriptionBox= new HBox();
- cardCareerDescriptionBox.setVisible(false);
- cardCareerDescriptionBox.setPadding(new Insets(0, 0, 0, 0));
- cardCareerDescriptionBox.getChildren().add(description1);
- cardCareerDescriptionBox.getChildren().add(description2);
- cardCareerDescriptionBox.getChildren().add(description3);
- careerButtonBox = new HBox();
- careerButtonBox.getChildren().add(career1);
- careerButtonBox.getChildren().add(career2);
- careerButtonBox.getChildren().add(career3);
- careerButtonBox.setAlignment(Pos.CENTER);
- careerButtonBox.setPadding(new Insets(0, 0, 0, 0));
- careerButtonBox.setVisible(false);
- }
- public void broadCast() {
- String name = board.currentPlayer.name;
- String typeOfSpace = "";
- if(board.currentPlayer.space instanceof Exams) {
- typeOfSpace = "Exams";
- }
- else if(board.currentPlayer.space instanceof AlternateSpace) {
- typeOfSpace = "Alternate";
- }
- else if(board.currentPlayer.space instanceof BuyHouse) {
- typeOfSpace = "Buy House";
- }
- else if(board.currentPlayer.space instanceof FirstSpace) {
- typeOfSpace = "First";
- }
- else if(board.currentPlayer.space instanceof Payday) {
- typeOfSpace = "Payday";
- }
- else if(board.currentPlayer.space instanceof SpinToWin) {
- typeOfSpace = "Spin to Win";
- }
- else if(board.currentPlayer.space instanceof BlankSpace) {
- typeOfSpace = "Blank";
- }
- else if(board.currentPlayer.space instanceof Port){
- typeOfSpace="Port";
- }
- else if(board.currentPlayer.space instanceof Airport){
- typeOfSpace= "Airport";
- }
- else if( board.currentPlayer.space instanceof ChooseCareerSpace){
- typeOfSpace= "Choose graduate career";
- }
- console.appendText(name + " landed on a " + typeOfSpace + " space!\n");
- }
- // public void updateCar(){
- // if(board.currentPlayer.single == true){
- // board.currentPlayer.setImage(carImage);
- // } else if(board.currentPlayer.partner == true){
- // board.currentPlayer.setImage(partner);
- // } else if(board.currentPlayer.oneCh == true){
- // board.currentPlayer.setImage(oneCh);
- // } else if(board.currentPlayer.twoCh == true){
- // board.currentPlayer.setImage(twoCh);
- // } else if(board.currentPlayer.threeCh == true){
- // board.currentPlayer.setImage(threeCh);
- // } else if(board.currentPlayer.fourCh == true){
- // board.currentPlayer.setImage(fourCh);
- // } else if(board.currentPlayer.oneChOneP == true){
- // board.currentPlayer.setImage(oneChOneP);
- // } else if(board.currentPlayer.oneChTwoP == true){
- // board.currentPlayer.setImage(oneChTwoP);
- // } else if(board.currentPlayer.oneChThreeP == true){
- // board.currentPlayer.setImage(oneChThreeP);
- // } else if(board.currentPlayer.twoChOneP == true){
- // board.currentPlayer.setImage(twoChOneP);
- // } else if(board.currentPlayer.twoChTwoP == true){
- // board.currentPlayer.setImage(twoChTwoP);
- // } else if(board.currentPlayer.threeChOneP == true){
- // board.currentPlayer.setImage(threeChOneP);
- // } else if(board.currentPlayer.oneP == true){
- // board.currentPlayer.setImage(oneP);
- // } else if(board.currentPlayer.twoP == true){
- // board.currentPlayer.setImage(twoP);
- // } else if(board.currentPlayer.threeP == true){
- // board.currentPlayer.setImage(threeP);
- // } else if(board.currentPlayer.fourP == true){
- // board.currentPlayer.setImage(fourP);
- // }
- // }
- public void updateJobTitle(){
- job.setText(board.currentPlayer.getJobTitle());
- };
- public void retire(){
- new EndScreen(this, players);
- }
- public void updateMinimap() {
- firstRow.getChildren().removeAll(map.getRoot(),stackPane);
- map.update(board);
- firstRow.getChildren().addAll(map.getRoot(), stackPane);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement