diff --git a/.idea/workspace.xml b/.idea/workspace.xml index ff8785b..f748ccb 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,10 @@ - + + + + @@ -13,55 +16,32 @@ - - - - - - - - - - - - - - + + - - - + - - + + - + - - - - - - - - - - + @@ -77,8 +57,6 @@ - howMuchRun - pirateName player numOfPeasantShips peasant @@ -107,6 +85,8 @@ runFromShips() dang it! dang it + destroy + destroyPeas HP @@ -172,7 +152,7 @@ - + @@ -192,7 +172,7 @@ - + - - @@ -285,6 +265,8 @@ + + 1550458470138 @@ -475,17 +457,31 @@ - - - + @@ -582,9 +578,6 @@ - - - @@ -607,7 +600,10 @@ - @@ -670,23 +666,6 @@ - - - - - - - - - - - - - - - - - @@ -701,14 +680,50 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - diff --git a/src/ShipWarfareGUI.java b/src/ShipWarfareGUI.java index 92536cb..251ee8c 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,20 @@ public class ShipWarfareGUI { counter++; chooseFightOrRun.setText("Ohh, Fight ehh?"); try { - destroyPeasantShipsOrEscape(); + if (destroyPeasantShipsOrEscape()){ + completeWipe(); + continueButton.setVisible(true); + 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 +413,27 @@ public class ShipWarfareGUI { chooseFightOrRun.setVisible(false); report.setText(("Couldn't run away")); try { - destroyPeasantShipsOrEscape(); + if(destroyPeasantShipsOrEscape()==true){ + completeWipe(); + continueButton.setVisible(true); + 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(); }