This commit is contained in:
2019-04-06 15:20:37 -06:00
parent 3beb1ff33d
commit 7f1e8a4be8
11 changed files with 384 additions and 901 deletions

9
src/BankText.java Normal file
View File

@@ -0,0 +1,9 @@
public class BankText extends Player {
public BankText(Player player) {
Player playerDummy = new Player(player);
setPlayer(playerDummy);
}
public void bank() {
}
}

View File

@@ -19,6 +19,7 @@ import java.io.FileInputStream;
import java.util.Random;
import java.util.concurrent.ExecutionException;
/**
* 2019-03-10 (Edited on 2019-03-23)
* Author: Haris Muhammad
@@ -29,7 +30,7 @@ import java.util.concurrent.ExecutionException;
public class ShipWarfareGUI extends Player {
private ShipWarfareGUI ship;
private ShipWarfareGUILogic logic;
//private ShipWarfareGUILogic logic;
private Circle cannon;
private VBox buttonBox;
private HBox fightRunBox;
@@ -46,7 +47,6 @@ public class ShipWarfareGUI extends Player {
private Label report;
private int timeCounter;
@@ -70,9 +70,6 @@ public class ShipWarfareGUI extends Player {
}
/**
* Sets most of the labels invisible except for the "fight or run" label
*/
@@ -99,9 +96,6 @@ public class ShipWarfareGUI extends Player {
}
/**
* Player attacks enemy ships in an animation
*/
@@ -160,7 +154,8 @@ public class ShipWarfareGUI extends Player {
});
}
public boolean winOrLose( Stage stage){
/*
public boolean winOrLose(Stage stage) {
if (logic.destroyLittyShipsOrEscape() == 1) {
wipe();
report.setText(logic.getReportMessage());
@@ -189,8 +184,7 @@ public class ShipWarfareGUI extends Player {
return true;
}
}
*/
/**
* Generaties ships and deploys logic for the shipwarfare
@@ -198,303 +192,7 @@ public class ShipWarfareGUI extends Player {
* @param primaryStage sets up the stage to whcih the GUI may be based around
* @throws Exception in case of interruptions withing the graphical interface
*/
public void initializeShip(Stage primaryStage) throws Exception {
cannon.setLayoutX(beginningX);
cannon.setLayoutY(beginningY);
logic.setNumOfLittyShips(logic.numOfShips());
Pane root = new Pane();
HBox usAgainstEnemyDivisor;
BorderPane centeringUserShipPane = new BorderPane();
Circle cannon;
BorderPane centeringLittyShipPane = new BorderPane();
BorderPane encompassingPane = new BorderPane();
usAgainstEnemyDivisor = new HBox();
cannon = new Circle();
this.cannon = cannon;
cannon.setVisible(false);
buttonBox = new VBox();
fightRunBox = new HBox();
fightButton = new Button();
runButton = new Button();
continueButton = new Button();
labelBox = new VBox();
title = new Label();
HPLeft = new Label();
gunsLeftOrTaken = new Label();
runAwayOrLeft = new Label();
shipsRemaining = new Label();
report = new Label();
title.setText(String.format("%d ships from Liu Yuen's Fleet are attacking, Would you like to fight or run?", numOfLittyShips));
fightButton.setText("Fight");
runButton.setText("Run");
continueButton.setText("Continue");
fightButton.setVisible(true);
runButton.setVisible(true);
continueButton.setVisible(false);
encompassingPane.setAlignment(labelBox, javafx.geometry.Pos.CENTER);
labelBox.setAlignment(javafx.geometry.Pos.CENTER);
labelBox.setPrefHeight(41.0);
labelBox.setPrefWidth(600.0);
labelBox.setSpacing(20.0);
labelBox.setPadding(new Insets(10.0, 0.0, 0.0, 0.0));
encompassingPane.setAlignment(buttonBox, javafx.geometry.Pos.CENTER);
buttonBox.setAlignment(javafx.geometry.Pos.TOP_CENTER);
fightRunBox.setAlignment(javafx.geometry.Pos.CENTER);
fightRunBox.setPrefHeight(100.0);
fightRunBox.setPrefWidth(200.0);
fightRunBox.setSpacing(10.0);
VBox.setMargin(continueButton, new Insets(0.0, 0.0, 20.0, 0.0));
root.getChildren().add(cannon);
encompassingPane.setPrefHeight(480);
encompassingPane.setPrefWidth(600);
usAgainstEnemyDivisor.setPrefHeight(0.0);
usAgainstEnemyDivisor.setPrefWidth(600.0);
centeringUserShipPane.setPrefHeight(200.0);
centeringUserShipPane.setPrefWidth(200.0);
Image ourShip;
Image enemyShip;
try {
ourShip = new Image(new FileInputStream("src/images/ourShip.png"));
enemyShip = new Image(new FileInputStream("src/images/enemyShip.png"));
} catch (Exception e) {
ourShip = new Image(new FileInputStream("images/ourShip.png"));
enemyShip = new Image(new FileInputStream("images/enemyShip.png"));
}
//Setting the image view
ImageView userShip = new ImageView(ourShip);
ImageView littyShip = new ImageView(enemyShip);
BorderPane.setAlignment(userShip, javafx.geometry.Pos.CENTER);
userShip.setFitHeight(150.0);
userShip.setFitWidth(248.0);
userShip.setPickOnBounds(true);
userShip.setPreserveRatio(true);
centeringUserShipPane.setCenter(userShip);
BorderPane.setAlignment(buttonBox, javafx.geometry.Pos.CENTER);
buttonBox.setAlignment(javafx.geometry.Pos.TOP_CENTER);
usAgainstEnemyDivisor.setTranslateY(-20.0);
cannon.setRadius(10.0);
cannon.setStroke(javafx.scene.paint.Color.BLACK);
cannon.setStrokeType(javafx.scene.shape.StrokeType.INSIDE);
centeringUserShipPane.setRight(cannon);
centeringLittyShipPane.setPrefHeight(200.0);
centeringLittyShipPane.setPrefWidth(200.0);
centeringLittyShipPane.setOpaqueInsets(new Insets(0.0));
HBox.setMargin(centeringLittyShipPane, new Insets(0.0, 0.0, 0.0, 200.0));
encompassingPane.setAlignment(littyShip, javafx.geometry.Pos.CENTER);
littyShip.setFitHeight(165.0);
littyShip.setFitWidth(180.0);
littyShip.setPickOnBounds(true);
littyShip.setPreserveRatio(true);
encompassingPane.setMargin(littyShip, new Insets(0.0, 0.0, 20.0, 0.0));
centeringLittyShipPane.setCenter(littyShip);
usAgainstEnemyDivisor.getChildren().add(centeringUserShipPane);
usAgainstEnemyDivisor.getChildren().add(centeringLittyShipPane);
fightRunBox.getChildren().add(fightButton);
fightRunBox.getChildren().add(continueButton);
fightRunBox.getChildren().add(runButton);
buttonBox.getChildren().add(fightRunBox);
labelBox.getChildren().add(title);
labelBox.getChildren().add(HPLeft);
labelBox.getChildren().add(gunsLeftOrTaken);
labelBox.getChildren().add(runAwayOrLeft);
labelBox.getChildren().add(shipsRemaining);
labelBox.getChildren().add(report);
encompassingPane.setTop(labelBox);
encompassingPane.setCenter(usAgainstEnemyDivisor);
encompassingPane.setBottom(buttonBox);
root.getChildren().addAll(encompassingPane, cannon);
Scene scene = new Scene(root, 600, 480);
root.getStylesheets().add("styleguide.css");
primaryStage.setResizable(false);
primaryStage.setTitle("Ship Warfare");
primaryStage.setScene(scene);
primaryStage.show();
continueButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
/**
* Continue Button, engages in run logic and graphical interface
* @param event, once button is clicked, executes graphical information
*/
public void handle(ActionEvent event) {
shotsFired.stop();
/**
* Switches to Taipan Shop scene
*/
TaipanShopGUI shop = new TaipanShopGUI(getPlayer());
shop.initializeShop(primaryStage);
primaryStage.show();
}
});
//Flee
runButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
/**
* Run Button, engages in run logic and graphical interface
* @param event, once button is clicked, executes graphical information
*/
public void handle(ActionEvent event) {
report.setVisible(true);
title.setVisible(true);
shipsRemaining.setVisible(true);
gunsLeftOrTaken.setVisible(true);
title.setText("Ayy captain we will try to run!");
report.setText("Epic");
counter++;
if (logic.runFromShips() == false) {
report.setText(("Couldn't run away"));
try {
winOrLose = destroyLittyShipsOrEscape(primaryStage);
} catch (Exception e) {
e.printStackTrace();
}
if (winOrLose == true) {
report.setVisible(true);
title.setVisible(true);
shipsRemaining.setVisible(true);
gunsLeftOrTaken.setVisible(true);
}
} else {
report.setText("Phew! Got away safely");
setVisibilitiesAndTransition(primaryStage);
}
}
});
//Fight
fightButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
/**
* Fight Button, engages in fight logic and graphical interface
* @param event, once button is clicked, executes graphical information
*/
public void handle(ActionEvent event) {
report.setVisible(false);
runAwayOrLeft.setVisible(false);
shipsRemaining.setVisible(false);
HPLeft.setVisible(false);
gunsLeftOrTaken.setVisible(false);
fightButton.setVisible(false);
runButton.setVisible(false);
try {
winOrLose = destroyLittyShipsOrEscape(primaryStage);
} catch (Exception e) {
e.printStackTrace();
}
counter++;
cannon.setVisible(true);
cannon.setLayoutX(beginningX);
cannon.setLayoutY(beginningY);
if (counter >= 1) {
title.setVisible(false);
}
playerShoots(getGuns());
shotsFired.setOnFinished(new EventHandler<ActionEvent>() {
@Override
/**
* When the user is completed their volley this information will be accessed
* @param event, once the shots fired transition is completed, execute graphical information
*/
public void handle(ActionEvent event) {
shotsFired.stop();
if (!winOrLose) {
shipsRetaliate();
} else {
report.setVisible(true);
continueButton.setVisible(true);
usAgainstEnemyDivisor.setVisible(false);
cannon.setVisible(false);
shotsFired.stop();
}
enemyShots.setOnFinished(new EventHandler<ActionEvent>() {
@Override
/**
* When the user is completed their volley, this information will be accessed
* @param event, once the enemy shots transition is completed, execute graphical information
*/
public void handle(ActionEvent event) {
fightButton.setVisible(true);
runButton.setVisible(true);
report.setVisible(true);
cannon.setVisible(false);
runAwayOrLeft.setVisible(true);
gunsLeftOrTaken.setVisible(true);
shipsRemaining.setVisible(true);
HPLeft.setVisible(true);
gunsLeftOrTaken.setVisible(true);
if (winOrLose == true) {
usAgainstEnemyDivisor.setVisible(false);
}
}
});
}
});
}
});
}
/*
public void initializeShip(Stage primaryStage) throws Exception
*/
}

View File

@@ -14,7 +14,9 @@ import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.StrokeType;
import javafx.scene.text.Font;
import javafx.stage.Stage;
@@ -239,94 +241,6 @@ public class TaipanShopGUI extends Player{
FileSaving saving = new FileSaving();
saving.saveFile(getPlayer());
Font size14 = new Font(14.0);
Rectangle dialogueRectangle = new Rectangle();
dialogueRectangle.setFill(javafx.scene.paint.Color.WHITE);
dialogueRectangle.setHeight(180.0);
dialogueRectangle.setLayoutX(8.0);
dialogueRectangle.setLayoutY(294.0);
dialogueRectangle.setStroke(javafx.scene.paint.Color.BLACK);
dialogueRectangle.setStrokeType(javafx.scene.shape.StrokeType.INSIDE);
dialogueRectangle.setWidth(582.0);
Rectangle inventoryRectangle = new Rectangle();
inventoryRectangle.setFill(javafx.scene.paint.Color.WHITE);
inventoryRectangle.setHeight(108.0);
inventoryRectangle.setLayoutX(8.0);
inventoryRectangle.setLayoutY(147.0);
inventoryRectangle.setStroke(javafx.scene.paint.Color.BLACK);
inventoryRectangle.setStrokeType(javafx.scene.shape.StrokeType.INSIDE);
inventoryRectangle.setWidth(405.0);
Rectangle warehouseRectangle = new Rectangle();
warehouseRectangle.setFill(javafx.scene.paint.Color.WHITE);
warehouseRectangle.setHeight(108.0);
warehouseRectangle.setLayoutY(33.0);
warehouseRectangle.setLayoutX(8.0);
warehouseRectangle.setStroke(javafx.scene.paint.Color.BLACK);
warehouseRectangle.setStrokeType(javafx.scene.shape.StrokeType.INSIDE);
warehouseRectangle.setWidth(405.0);
AnchorPane anchorPane = new AnchorPane();
anchorPane.setPrefHeight(480.0);
anchorPane.setPrefWidth(600.0);
GridPane gridPane = new GridPane();
gridPane.setPrefHeight(480.0);
gridPane.setPrefWidth(600.0);
ColumnConstraints columnConstraints = new ColumnConstraints();
columnConstraints.setMaxWidth(590.0);
columnConstraints.setMinWidth(0.0);
columnConstraints.setPrefWidth(590.0);
RowConstraints rowConstraints = new RowConstraints();
rowConstraints.setMinHeight(20.0);
rowConstraints.setPrefHeight(20.0);
RowConstraints rowConstraints0 = new RowConstraints();
rowConstraints0.setMaxHeight(122.0);
rowConstraints0.setMinHeight(10.0);
rowConstraints0.setPrefHeight(117.0);
RowConstraints rowConstraints1 = new RowConstraints();
rowConstraints1.setMaxHeight(163.0);
rowConstraints1.setMinHeight(10.0);
rowConstraints1.setPrefHeight(112.0);
RowConstraints rowConstraints2 = new RowConstraints();
rowConstraints2.setMaxHeight(126.0);
rowConstraints2.setMinHeight(0.0);
rowConstraints2.setPrefHeight(42.0);
RowConstraints rowConstraints3 = new RowConstraints();
rowConstraints3.setMaxHeight(269.0);
rowConstraints3.setMinHeight(10.0);
rowConstraints3.setPrefHeight(118.0);
RowConstraints rowConstraints4 = new RowConstraints();
rowConstraints4.setMaxHeight(179.0);
rowConstraints4.setMinHeight(10.0);
rowConstraints4.setPrefHeight(52.0);
gridPane.setPadding(new Insets(10.0, 10.0, 10.0, 0.0));
HBox hBox = new HBox();
GridPane.setRowIndex(hBox, 1);
hBox.setPrefHeight(100.0);
hBox.setPrefWidth(200.0);
HBox hBox0 = new HBox();
GridPane.setRowIndex(hBox0, 2);
hBox0.setPrefHeight(100.0);
hBox0.setPrefWidth(200.0);
FlowPane flowPane = new FlowPane();
GridPane.setRowIndex(flowPane, 5);
flowPane.setAlignment(javafx.geometry.Pos.CENTER);
flowPane.setHgap(5.0);
flowPane.setPrefHeight(200.0);
flowPane.setPrefWidth(200.0);
buyButton.setMnemonicParsing(false);
buyButton.setPrefHeight(25.0);
@@ -603,19 +517,129 @@ public class TaipanShopGUI extends Player{
break;
}
}
updateStage();
updateStage(firm,wItemsText,wItemSpaceText,locationText,gunsText,inventoryText,inventoryHeldText,shipStatusText,cashText,bankText);
buttonSetup("reset");
}
}
});
stage.setTitle("Shop");
stage.setResizable(false);
Scene root = new Scene(declareStage(), 600, 480);
stage.setScene(root);
// general updates to the buttons, user stats/inventory, and text.
buttonSetup("reset");
if(getIsPriceChanged() == 0 || getIsPriceChanged() == 2){
TaipanShopLogic logic = new TaipanShopLogic(getPlayer());
String temp = logic.updatePrices();
setPlayer(logic.getPlayer());
defaultTextOut();
textOut.setText(temp + textOut.getText());
}
//defaultTextOut();
updateStage(firm,wItemsText,wItemSpaceText,locationText,gunsText,inventoryText,inventoryHeldText,shipStatusText,cashText,bankText);
}
public AnchorPane declareStage() {
//Declaring all the elements required for the information on screen
Rectangle dialogueRectangle = new Rectangle();
Rectangle inventoryRectangle = new Rectangle();
Rectangle warehouseRectangle = new Rectangle();
AnchorPane anchorPane = new AnchorPane();
GridPane gridPane = new GridPane();
ColumnConstraints columnConstraints = new ColumnConstraints();
RowConstraints rowConstraints = new RowConstraints();
RowConstraints rowConstraints0 = new RowConstraints();
RowConstraints rowConstraints1 = new RowConstraints();
RowConstraints rowConstraints2 = new RowConstraints();
RowConstraints rowConstraints3 = new RowConstraints();
RowConstraints rowConstraints4 = new RowConstraints();
HBox hBox = new HBox();
HBox hBox0 = new HBox();
FlowPane flowPane = new FlowPane();
Font size14 = new Font(14.0);
Label warehouseText = new Label();
dialogueRectangle.setFill(Color.WHITE);
dialogueRectangle.setHeight(180.0);
dialogueRectangle.setLayoutX(8.0);
dialogueRectangle.setLayoutY(294.0);
dialogueRectangle.setStroke(Color.BLACK);
dialogueRectangle.setStrokeType(StrokeType.INSIDE);
dialogueRectangle.setWidth(582.0);
inventoryRectangle.setFill(Color.WHITE);
inventoryRectangle.setHeight(108.0);
inventoryRectangle.setLayoutX(8.0);
inventoryRectangle.setLayoutY(147.0);
inventoryRectangle.setStroke(Color.BLACK);
inventoryRectangle.setStrokeType(StrokeType.INSIDE);
inventoryRectangle.setWidth(405.0);
warehouseRectangle.setFill(Color.WHITE);
warehouseRectangle.setHeight(108.0);
warehouseRectangle.setLayoutY(33.0);
warehouseRectangle.setLayoutX(8.0);
warehouseRectangle.setStroke(Color.BLACK);
warehouseRectangle.setStrokeType(StrokeType.INSIDE);
warehouseRectangle.setWidth(405.0);
anchorPane.setPrefHeight(480.0);
anchorPane.setPrefWidth(600.0);
gridPane.setPrefHeight(480.0);
gridPane.setPrefWidth(600.0);
columnConstraints.setMaxWidth(590.0);
columnConstraints.setMinWidth(0.0);
columnConstraints.setPrefWidth(590.0);
rowConstraints.setMinHeight(20.0);
rowConstraints.setPrefHeight(20.0);
rowConstraints0.setMaxHeight(122.0);
rowConstraints0.setMinHeight(10.0);
rowConstraints0.setPrefHeight(117.0);
rowConstraints1.setMaxHeight(163.0);
rowConstraints1.setMinHeight(10.0);
rowConstraints1.setPrefHeight(112.0);
rowConstraints2.setMaxHeight(126.0);
rowConstraints2.setMinHeight(0.0);
rowConstraints2.setPrefHeight(42.0);
rowConstraints3.setMaxHeight(269.0);
rowConstraints3.setMinHeight(10.0);
rowConstraints3.setPrefHeight(118.0);
rowConstraints4.setMaxHeight(179.0);
rowConstraints4.setMinHeight(10.0);
rowConstraints4.setPrefHeight(52.0);
gridPane.setPadding(new Insets(10.0, 10.0, 10.0, 0.0));
GridPane.setRowIndex(hBox, 1);
hBox.setPrefHeight(100.0);
hBox.setPrefWidth(200.0);
GridPane.setRowIndex(hBox0, 2);
hBox0.setPrefHeight(100.0);
hBox0.setPrefWidth(200.0);
GridPane.setRowIndex(flowPane, 5);
flowPane.setAlignment(Pos.CENTER);
flowPane.setHgap(5.0);
flowPane.setPrefHeight(200.0);
flowPane.setPrefWidth(200.0);
firm.setAlignment(Pos.CENTER);
firm.setPrefHeight(27.0);
firm.setPrefWidth(632.0);
firm.setFont(new Font(18.0));
Label warehouseText = new Label();
warehouseText.setAlignment(Pos.CENTER);
warehouseText.setPrefHeight(108.0);
warehouseText.setPrefWidth(100.0);
@@ -674,7 +698,7 @@ public class TaipanShopGUI extends Player{
textOut.setContentDisplay(javafx.scene.control.ContentDisplay.TOP);
textOut.setPrefHeight(163.0);
textOut.setPrefWidth(583.0);
defaultTextOut();
//defaultTextOut();
textOut.setFont(size14);
anchorPane.getChildren().addAll(dialogueRectangle, inventoryRectangle, warehouseRectangle);
@@ -683,7 +707,7 @@ public class TaipanShopGUI extends Player{
hBox0.getChildren().addAll(inventoryText, inventoryHeldText, gunsText, shipStatusText);
flowPane.getChildren().addAll(buyButton, sellButton, bankButton, cargoButton, loanButton, quitButton, retireButton, opiumButton, silkButton, armsButton, generalButton, numberInput);
//flowPane.getChildren().addAll(buyButton, sellButton, bankButton, cargoButton, loanButton, quitButton, retireButton, opiumButton, silkButton, armsButton, generalButton, numberInput);
gridPane.getColumnConstraints().add(columnConstraints);
gridPane.getRowConstraints().addAll(rowConstraints, rowConstraints0, rowConstraints1, rowConstraints2, rowConstraints3, rowConstraints4);
@@ -691,42 +715,13 @@ public class TaipanShopGUI extends Player{
anchorPane.getChildren().add(gridPane);
Scene root = new Scene(anchorPane, 600, 480);
root.getStylesheets().add("styleguide.css");
stage.setTitle("Shop");
stage.setResizable(false);
stage.setScene(root);
buyButton.setFocusTraversable(false);
sellButton.setFocusTraversable(false);
bankButton.setFocusTraversable(false);
loanButton.setFocusTraversable(false);
generalButton.setFocusTraversable(false);
armsButton.setFocusTraversable(false);
silkButton.setFocusTraversable(false);
opiumButton.setFocusTraversable(false);
sellButton.setFocusTraversable(false);
retireButton.setFocusTraversable(false);
cargoButton.setFocusTraversable(false);
quitButton.setFocusTraversable(false);
// general updates to the buttons, user stats/inventory, and text.
buttonSetup("reset");
if(getIsPriceChanged() == 0 || getIsPriceChanged() == 2){
TaipanShopLogic logic = new TaipanShopLogic(getPlayer());
String temp = logic.updatePrices();
setPlayer(logic.getPlayer());
defaultTextOut();
textOut.setText(temp + textOut.getText());
}
//defaultTextOut();
updateStage();
return anchorPane;
}
/**
* updates the text associated with the user's inventory.
*/
public void updateStage() {
public void updateStage(Label firm, Label wItemsText, Label wItemSpaceText, Label locationText, Label gunsText, Label inventoryText, Label inventoryHeldText, Label shipStatusText, Label cashText, Label bankText) {
TaipanShopLogic logic = new TaipanShopLogic(getPlayer());
firm.setText(String.format("Firm: %s, %s", getName(), logic.getStringLocation()));
wItemsText.setText(String.format("\n %d\n %d\n %d\n %d", getwOpium(), getwSilk(), getwArms(), getwGeneral()));
@@ -745,5 +740,4 @@ public class TaipanShopGUI extends Player{
cashText.setText(String.format(" Cash: $%,d", getMoney()));
bankText.setText(String.format("Bank: $%,d", getBank()));
}
}

View File

@@ -9,6 +9,8 @@ import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.StrokeType;
import javafx.stage.Stage;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
@@ -61,96 +63,9 @@ public class TravelGUI extends Player{
*/
public Stage initializeTravel(Stage stage) {
//Updates the stage for the first-time you read it
updateStage();
shop.updateStage(firm,wItemsText,wItemSpaceText,locationText,gunsText,inventoryText,inventoryHeldText,shipStatusText,cashText,bankText);
Font size14 = new Font(14.0);
Rectangle dialogueRectangle = new Rectangle();
dialogueRectangle.setFill(javafx.scene.paint.Color.WHITE);
dialogueRectangle.setHeight(180.0);
dialogueRectangle.setLayoutX(8.0);
dialogueRectangle.setLayoutY(294.0);
dialogueRectangle.setStroke(javafx.scene.paint.Color.BLACK);
dialogueRectangle.setStrokeType(javafx.scene.shape.StrokeType.INSIDE);
dialogueRectangle.setWidth(582.0);
Rectangle inventoryRectangle = new Rectangle();
inventoryRectangle.setFill(javafx.scene.paint.Color.WHITE);
inventoryRectangle.setHeight(108.0);
inventoryRectangle.setLayoutX(8.0);
inventoryRectangle.setLayoutY(147.0);
inventoryRectangle.setStroke(javafx.scene.paint.Color.BLACK);
inventoryRectangle.setStrokeType(javafx.scene.shape.StrokeType.INSIDE);
inventoryRectangle.setWidth(405.0);
Rectangle warehouseRectangle = new Rectangle();
warehouseRectangle.setFill(javafx.scene.paint.Color.WHITE);
warehouseRectangle.setHeight(108.0);
warehouseRectangle.setLayoutY(33.0);
warehouseRectangle.setLayoutX(8.0);
warehouseRectangle.setStroke(javafx.scene.paint.Color.BLACK);
warehouseRectangle.setStrokeType(javafx.scene.shape.StrokeType.INSIDE);
warehouseRectangle.setWidth(405.0);
AnchorPane anchorPane = new AnchorPane();
anchorPane.setPrefHeight(480.0);
anchorPane.setPrefWidth(600.0);
GridPane gridPane = new GridPane();
gridPane.setPrefHeight(480.0);
gridPane.setPrefWidth(600.0);
ColumnConstraints columnConstraints = new ColumnConstraints();
columnConstraints.setMaxWidth(590.0);
columnConstraints.setMinWidth(0.0);
columnConstraints.setPrefWidth(590.0);
RowConstraints rowConstraints = new RowConstraints();
rowConstraints.setMinHeight(20.0);
rowConstraints.setPrefHeight(20.0);
RowConstraints rowConstraints0 = new RowConstraints();
rowConstraints0.setMaxHeight(122.0);
rowConstraints0.setMinHeight(10.0);
rowConstraints0.setPrefHeight(117.0);
RowConstraints rowConstraints1 = new RowConstraints();
rowConstraints1.setMaxHeight(163.0);
rowConstraints1.setMinHeight(10.0);
rowConstraints1.setPrefHeight(112.0);
RowConstraints rowConstraints2 = new RowConstraints();
rowConstraints2.setMaxHeight(126.0);
rowConstraints2.setMinHeight(0.0);
rowConstraints2.setPrefHeight(42.0);
RowConstraints rowConstraints3 = new RowConstraints();
rowConstraints3.setMaxHeight(269.0);
rowConstraints3.setMinHeight(10.0);
rowConstraints3.setPrefHeight(118.0);
RowConstraints rowConstraints4 = new RowConstraints();
rowConstraints4.setMaxHeight(179.0);
rowConstraints4.setMinHeight(10.0);
rowConstraints4.setPrefHeight(52.0);
gridPane.setPadding(new Insets(10.0, 10.0, 10.0, 0.0));
HBox hBox = new HBox();
GridPane.setRowIndex(hBox, 1);
hBox.setPrefHeight(100.0);
hBox.setPrefWidth(200.0);
HBox hBox0 = new HBox();
GridPane.setRowIndex(hBox0, 2);
hBox0.setPrefHeight(100.0);
hBox0.setPrefWidth(200.0);
FlowPane flowPane = new FlowPane();
GridPane.setRowIndex(flowPane, 5);
flowPane.setAlignment(javafx.geometry.Pos.CENTER);
flowPane.setHgap(5.0);
flowPane.setPrefHeight(200.0);
flowPane.setPrefWidth(200.0);
shop.declareStage();
//Creating the continue and quit buttons
quitButton.setPrefHeight(25.0);
@@ -176,7 +91,7 @@ public class TravelGUI extends Player{
if(peasantShipScene && getAttackingShips()){
ShipWarfareGUI ship = new ShipWarfareGUI(getPlayer());
try {
ship.initializeShip(stage);
//ship.initializeShip(stage);
} catch (Exception e) {
e.printStackTrace();
}
@@ -257,88 +172,7 @@ public class TravelGUI extends Player{
firm.setPrefWidth(632.0);
firm.setFont(new Font(18.0));
Label warehouseText = new Label();
warehouseText.setAlignment(Pos.CENTER);
warehouseText.setPrefHeight(108.0);
warehouseText.setPrefWidth(100.0);
warehouseText.setText(" Warehouse\n\tOpium\n\tSilk\n\tArms\n\tGeneral");
warehouseText.setFont(size14);
wItemsText.setAlignment(Pos.CENTER);
wItemsText.setPrefWidth(100.0);
wItemsText.setPrefHeight(108.0);
wItemsText.setFont(size14);
wItemSpaceText.setPrefHeight(108.0);
wItemSpaceText.setPrefWidth(210.0);
wItemSpaceText.setFont(size14);
locationText.setAlignment(Pos.BOTTOM_RIGHT);
locationText.setPrefHeight(106.0);
locationText.setPrefWidth(140.0);
locationText.setTextAlignment(javafx.scene.text.TextAlignment.CENTER);
locationText.setFont(size14);
inventoryText.setAlignment(Pos.CENTER);
inventoryText.setPrefWidth(110.0);
inventoryText.setPrefHeight(108.0);
inventoryText.setFont(size14);
inventoryHeldText.setAlignment(Pos.CENTER);
inventoryHeldText.setPrefHeight(108.0);
inventoryHeldText.setPrefWidth(100.0);
inventoryHeldText.setFont(size14);
gunsText.setPrefHeight(108.0);
gunsText.setPrefWidth(212.0);
gunsText.setAlignment(Pos.CENTER_LEFT);
gunsText.setFont(size14);
shipStatusText.setAlignment(Pos.TOP_CENTER);
shipStatusText.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
shipStatusText.setPrefHeight(110.0);
shipStatusText.setPrefWidth(200.0);
shipStatusText.setTextAlignment(javafx.scene.text.TextAlignment.CENTER);
shipStatusText.setFont(size14);
GridPane.setRowIndex(cashText, 3);
cashText.setPrefHeight(17.0);
cashText.setPrefWidth(209.0);
cashText.setFont(size14);
GridPane.setHalignment(bankText, javafx.geometry.HPos.CENTER);
GridPane.setRowIndex(bankText, 3);
bankText.setAlignment(Pos.CENTER);
bankText.setPrefHeight(20.0);
bankText.setPrefWidth(264.0);
bankText.setFont(size14);
GridPane.setRowIndex(textOut, 4);
textOut.setAlignment(Pos.TOP_LEFT);
textOut.setContentDisplay(javafx.scene.control.ContentDisplay.TOP);
textOut.setPrefHeight(163.0);
textOut.setPrefWidth(583.0);
textOut.setText(" Taipan, do you wish to go to:\n\n 1) Hong Kong, 2) Shanghai, 3) Nagasaki, 4) Saigon,\n 5) Manila, 6) Singapore, or 7) Batavia?\n After typing the number you want to go to press 'Enter' or 'Z'");
textOut.setFont(size14);
//Added all the nodes into a single scene
anchorPane.getChildren().addAll(dialogueRectangle, inventoryRectangle, warehouseRectangle);
hBox.getChildren().addAll(warehouseText, wItemsText, wItemSpaceText, locationText);
hBox0.getChildren().addAll(inventoryText, inventoryHeldText, gunsText, shipStatusText);
numberInput.requestFocus();
flowPane.getChildren().addAll(numberInput, quitButton, continueButton);
gridPane.getColumnConstraints().add(columnConstraints);
gridPane.getRowConstraints().addAll(rowConstraints, rowConstraints0, rowConstraints1, rowConstraints2, rowConstraints3, rowConstraints4);
gridPane.getChildren().addAll(firm, hBox, hBox0, cashText, bankText, textOut, flowPane);
anchorPane.getChildren().add(gridPane);
Scene root = new Scene(anchorPane, 600, 480);
root.getStylesheets().add("styleguide.css");
Scene root = new Scene(shop.declareStage(), 600, 480);
stage.setTitle("Travel");
stage.setResizable(false);
@@ -481,26 +315,4 @@ public class TravelGUI extends Player{
}
return shipStatus;
}
/**
* updates the text associated with the user's inventory.
*/
public void updateStage(){
firm.setText(String.format("Firm: %s, %s", getName(), getStringLocation()));
wItemsText.setText(String.format("\n %d\n %d\n %d\n %d", getwOpium(), getwSilk(), getwArms(), getwGeneral()));
int itemsInWarehouse = getwOpium()+getwGeneral()+getwArms()+getwSilk();
wItemSpaceText.setText(String.format("\n\t\tIn use:\n\t\t %d \n\t\tVacant:\n\t\t %d", itemsInWarehouse, (10000-itemsInWarehouse)));
locationText.setText(String.format("Location\n%s", getStringLocation()));
int itemsInInventory = getCargoSpace()-getSilkHeld()-getOpiumHeld()-getGeneralHeld()-getArmsHeld()-10*getGuns();
if(itemsInInventory < 0){
inventoryText.setText(" Overloaded\n\t Opium\n\t Silk\n\t Arms\n\t General");
}else{
inventoryText.setText(String.format(" Hold %d\n\t Opium\n\t Silk\n\t Arms\n\t General", itemsInInventory));
}
gunsText.setText(String.format("Guns %d\n\n\n\n ", getGuns()));
inventoryHeldText.setText(String.format("\n %d\n %d\n %d\n %d", getOpiumHeld(), getSilkHeld(), getArmsHeld(), getGeneralHeld()));
shipStatusText.setText(String.format("\tDebt\n\t%d\n\n\tShip status\n\t%s: %d", getDebt(), shipStatusString(), getHP()));
cashText.setText(String.format(" Cash: $%,d", getMoney()));
bankText.setText(String.format("Bank: $%,d", getBank()));
}
}

9
src/TravelText.java Normal file
View File

@@ -0,0 +1,9 @@
public class TravelText extends Player{
public TravelText(Player player) {
Player playerDummy = new Player(player);
setPlayer(playerDummy);
}
public void travelTo() {
}
}

9
src/WarehouseText.java Normal file
View File

@@ -0,0 +1,9 @@
public class WarehouseText extends Player {
public WarehouseText(Player player) {
Player playerDummy = new Player(player);
setPlayer(playerDummy);
}
public void changeWarehouse() {
}
}

9
src/loanSharkText.java Normal file
View File

@@ -0,0 +1,9 @@
public class loanSharkText extends Player{
public loanSharkText(Player player) {
Player playerDummy = new Player(player);
setPlayer(playerDummy);
}
public void loanMoney() {
}
}

Binary file not shown.