diff --git a/.idea/workspace.xml b/.idea/workspace.xml index ff8785b..4d27f11 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,10 @@ - + + + + @@ -14,10 +17,10 @@ - + - - + + @@ -25,43 +28,29 @@ + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -77,13 +66,6 @@ - howMuchRun - pirateName - player - numOfPeasantShips - peasant - litty - userAttacks numOfLittyShips delay Hp @@ -107,6 +89,13 @@ runFromShips() dang it! dang it + destroy + destroyPeas + cash + op + continue + cashTex + cashTe HP @@ -133,6 +122,8 @@ @@ -172,7 +163,7 @@ - + @@ -192,7 +183,7 @@ - + - - @@ -285,6 +276,8 @@ + + 1550458470138 @@ -475,17 +468,52 @@ - - - + @@ -582,12 +610,6 @@ - - - - - - @@ -607,7 +629,13 @@ - @@ -670,23 +698,6 @@ - - - - - - - - - - - - - - - - - @@ -701,18 +712,54 @@ - + - - + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ShipWarfareGUI.java b/src/ShipWarfareGUI.java index 92536cb..11d66ab 100644 --- a/src/ShipWarfareGUI.java +++ b/src/ShipWarfareGUI.java @@ -29,13 +29,16 @@ public class ShipWarfareGUI { private Label gunsLeftOrTaken; private Label continueToFight; private int counter1; + private Button continueButton; + + /* - /** - * constructor; only runs when a Player object is provided. The constructor is fully encapsulated. - * - * @param player is a Player object that will be copied and the player instance variable is set to the copy. - */ + /** + * constructor; only runs when a Player object is provided. The constructor is fully encapsulated. + * + * @param player is a Player object that will be copied and the player instance variable is set to the copy. + */ public ShipWarfareGUI(Player player){ Player playerDummy = new Player(player); this.player = playerDummy; @@ -175,6 +178,8 @@ public class ShipWarfareGUI { HPLeft.setVisible(true); gunsLeftOrTaken.setVisible(true); continueToFight.setVisible(true); + continueButton.setVisible(false); + runAwayOrLeft.setText("No ships ran away"); @@ -270,12 +275,14 @@ public class ShipWarfareGUI { calculateLoot = (startingPeasantShips *100) + randomValue.nextInt(startingPeasantShips) *200; player.setMoney(player.getMoney() + calculateLoot); report.setText(String.format("Our firm has earned $%,d in loot! ", calculateLoot)); + continueButton.setVisible(true); return true; } else if (exitValue == 2) { player.gameOver(); return true; } else if (exitValue == 3) { System.out.printf("We made it out at %d%% ship status!\n", player.getHP()); + continueButton.setVisible(true); return true; } return false; @@ -302,6 +309,10 @@ public class ShipWarfareGUI { HPLeft = new Label(); gunsLeftOrTaken = new Label(); continueToFight = new Label(); + continueButton = new Button(); + + continueButton.setVisible(false); + BorderPane.setPrefHeight(400.0); @@ -317,6 +328,9 @@ public class ShipWarfareGUI { title.setText(String.format("%d ships attacking. Would you like to Fight or Run?",numOfPeasantShips)); title.setPadding(new Insets(6.0, 0.0, 0.0, 0.0)); + continueButton.setMnemonicParsing(false); + continueButton.setText("Continue?"); + fightButton.setAlignment(javafx.geometry.Pos.CENTER); fightButton.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER); fightButton.setId("Button1"); @@ -353,6 +367,8 @@ public class ShipWarfareGUI { vBox.getChildren().add(HPLeft); vBox.getChildren().add(gunsLeftOrTaken); vBox.getChildren().add(continueToFight); + vBox.getChildren().add(continueButton); + //Fight fightButton.setOnAction(new EventHandler() { @@ -361,7 +377,22 @@ public class ShipWarfareGUI { counter++; chooseFightOrRun.setText("Ohh, Fight ehh?"); try { - destroyPeasantShipsOrEscape(); + if (destroyPeasantShipsOrEscape()){ + completeWipe(); + continueButton.setVisible(true); + fightButton.setVisible(false); + runButton.setVisible(false); + continueButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent event) { + TaipanShopGUI shop = new TaipanShopGUI(player); + shop.initializeShop(stage); + stage.show(); + } + }); + + + } } catch (Exception e) { } @@ -384,12 +415,29 @@ public class ShipWarfareGUI { chooseFightOrRun.setVisible(false); report.setText(("Couldn't run away")); try { - destroyPeasantShipsOrEscape(); + if(destroyPeasantShipsOrEscape()==true){ + completeWipe(); + continueButton.setVisible(true); + fightButton.setVisible(false); + runButton.setVisible(false); + continueButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent event) { + TaipanShopGUI shop = new TaipanShopGUI(player); + shop.initializeShop(stage); + stage.show(); + } + }); + } + } catch (Exception e) { } } else { completeWipe(); report.setText("Phew! Got away safely"); + TaipanShopGUI shop = new TaipanShopGUI(player); + shop.initializeShop(stage); + stage.show(); } diff --git a/src/TaipanShopGUI.java b/src/TaipanShopGUI.java index 50fb961..e00af07 100644 --- a/src/TaipanShopGUI.java +++ b/src/TaipanShopGUI.java @@ -803,7 +803,7 @@ public class TaipanShopGUI { gunsText.setText(String.format("Guns %d\n\n\n\n ", player.getGuns())); inventoryHeldText.setText(String.format("\n %d\n %d\n %d\n %d", player.getOpiumHeld(), player.getSilkHeld(), player.getArmsHeld(), player.getGeneralHeld())); shipStatusText.setText(String.format("\tDebt\n\t%d\n\n\tShip status\n\t%s: %d", player.getDebt(), shipStatusString(), player.getHP())); - cashText.setText(String.format(" Cash: %d", player.getMoney())); + cashText.setText(String.format(" Cash: $%,d", player.getMoney())); bankText.setText(String.format("Bank: %d", player.getBank())); } diff --git a/src/TravelGUI.java b/src/TravelGUI.java index 8505996..a5b96d6 100644 --- a/src/TravelGUI.java +++ b/src/TravelGUI.java @@ -452,7 +452,7 @@ public class TravelGUI{ gunsText.setText(String.format("Guns %d\n\n\n\n ", player.getGuns())); inventoryHeldText.setText(String.format("\n %d\n %d\n %d\n %d", player.getOpiumHeld(), player.getSilkHeld(), player.getArmsHeld(), player.getGeneralHeld())); shipStatusText.setText(String.format("\tDebt\n\t%d\n\n\tShip status\n\t%s: %d", player.getDebt(), shipStatusString(), player.getHP())); - cashText.setText(String.format(" Cash: %d", player.getMoney())); + cashText.setText(String.format(" Cash: $%,d", player.getMoney())); bankText.setText(String.format("Bank: %d", player.getBank())); }