From 1bb00d0d01197467af806678b1a40f3ba936a69d Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sat, 9 Mar 2019 22:32:45 -0700
Subject: [PATCH 1/2] Super broken but fight button is in progress for
shipwarfare
---
.idea/workspace.xml | 95 ++++---
out/production/TaipanClone/ShipWarfare.class | Bin 8124 -> 8386 bytes
src/ShipWarfareGUI.java | 254 +++++++++----------
3 files changed, 175 insertions(+), 174 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 3bc1b50..827b9ae 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,6 +3,8 @@
+
+
@@ -27,21 +29,21 @@
-
+
-
-
+
+
-
-
+
+
-
+
@@ -84,10 +86,6 @@
- GetGuns
- set
- TaipanShop
- shop()
shop
being
label0
@@ -100,7 +98,6 @@
setNumOfP
setUs
starting
- destro
numOfpeasantShips
startingPeasantShips
startingLittyShips
@@ -114,6 +111,11 @@
numOfLittyShips
delay
Hp
+ shipwarfare
+ destroyPeasa
+ destr
+ destro
+ hitco
HP
@@ -137,9 +139,9 @@
-
+
@@ -155,7 +157,6 @@
-
@@ -172,6 +173,7 @@
+
@@ -179,7 +181,7 @@
-
+
@@ -199,7 +201,7 @@
-
+
@@ -244,8 +246,8 @@
-
+
@@ -279,6 +281,8 @@
+
+
1550458470138
@@ -399,17 +403,24 @@
1552181667376
-
+
+ 1552187032139
+
+
+
+ 1552187032139
+
+
-
+
-
+
@@ -418,7 +429,7 @@
-
+
@@ -524,7 +535,8 @@
-
+
+
@@ -579,6 +591,13 @@
+
+
+
+
+
+
+
@@ -589,15 +608,17 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -611,17 +632,15 @@
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
diff --git a/out/production/TaipanClone/ShipWarfare.class b/out/production/TaipanClone/ShipWarfare.class
index da08cf6213d842f125c937412fb28abad9f46416..c5ed7032c0d092c9bbcf56f86ddfa849481ff933 100644
G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4Ob_`*;a#-PTsLdPEzQ((zzOc
zn^)?z>_$w}{i{mfsKR-RvQFj`U%_9i82CN0>rbe}pP5mAK`no|VDdKxVSY2u<0tYG
ze1ua3_>u@t7XzK*fhAtVm|uNFfvpn2`BIK=OAy;7gj=P8wdf%37DA3pzzb4~S7kC@
zlf(IEfGK!SO#E8v@CTVHB1g(tnJ%WxkOuxVOIW((3v!OkkqhJ)xm1potK~SkN#@F3
za=bhs^W7X*=T%MPB-q5FB=cb8OGysrtzelWjre##!J#^
zydqu3>k>8oD3-Bbx{U)8v(c!VuzCtR|4WHHejLSmei`4&^`BFJ;KSKNAGipO0AT|B~PLm0h;R9IA(*HiWe}K->(?`@O{z}nB#b;eq
zeB)D4ak>+hOwTPNQ8CH|MaA`btWi{CXxgY~C@LDtHvTnz9{6W})Y;#0ialz8&lLm}
z*Gqw5MsNDOL9o^V!O_ZFL2wY|Ws10Eg9l%?QSU5W`83qiszfvUI;x_jLGR@MC(sM?
zQxuYgAvt(uD=K9G6XhJ#%6Ty5e1v5i=E+yFL@prcT}aToh@f{dLGKcR-lYV+uMzYv
zC+J;)E9L9>7WZ$L>##?@gL`E=9+4e*OumOFS&PZ0Q?GA7E?#u4(2(IC$f^qw>3%L~RLd6B^Pim_CFVl>HX1iPOaF?roMM}B5p
zE^in+ 0) {
@@ -320,7 +310,6 @@ public class ShipWarfareGUI extends Application {
break;
}
System.out.printf("EEK, our current ship status is %d%% \n", player.getHP());
- delayForSeconds(1);
if (userAttacks == false) {
userAttacks = true;
}
@@ -331,10 +320,8 @@ public class ShipWarfareGUI extends Application {
if (response.equalsIgnoreCase("r")) {
if (runFromShips() == false) {
System.out.println("Couldn't run away");
- delayForSeconds(1);
} else {
System.out.println("Phew! Got away safely");
- delayForSeconds(2);
break;
}
}
@@ -345,11 +332,9 @@ public class ShipWarfareGUI extends Application {
if (exitValue == 1) {
System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d%% ship status\n", player.getHP());
- delayForSeconds(1);
calculateLoot = (randomValue.nextInt(startingLittyShips) + startingLittyShips) * 300;
player.setMoney(player.getMoney() + calculateLoot);
System.out.printf("We got $%,d!\n", calculateLoot);
- delayForSeconds(2);
return true;
} else if (exitValue == 2) {
player.gameOver();
@@ -357,7 +342,6 @@ public class ShipWarfareGUI extends Application {
return true;
} else if (exitValue == 3) {
System.out.printf("We made it out at %d%% ship status!\n", player.getHP());
- delayForSeconds(2);
return true;
}
return false;
@@ -371,11 +355,23 @@ public class ShipWarfareGUI extends Application {
* @throws Exception in case of errors due to the delay
*/
+ public void wipe(){
+ title.setVisible(false);
+ runAwayOrLeft.setVisible(false);
+ shipsRemaining.setVisible(false);
+ HPLeft.setVisible(false);
+ gunsLeftOrTaken.setVisible(false);
+ continueToFight.setVisible(false);
+
+
+ }
+
public boolean destroyPeasantShipsOrEscape() throws Exception {
int calculateLoot = 0;
int chanceOfEnemyRun = 0;
int hitCounter=0;
int missCounter=0;
+ boolean gunFrustration= false;
Scanner userInput = new Scanner(System.in);
@@ -396,10 +392,8 @@ public class ShipWarfareGUI extends Application {
break;
}
hitCounter++;
- delayForSeconds(1);
} else {
- missCounter++;
- delayForSeconds(1);
+
}
@@ -407,11 +401,10 @@ public class ShipWarfareGUI extends Application {
continue;
}
}
- label1.setText(String.format("Report:\nShips we hit: %d\nShots missed: %d", hitCounter,missCounter));
+ report.setText(String.format("Report: Ships we hit: %d Shots missed: %d", hitCounter,missCounter));
}
else{
- label1.setText("We don't have any guns!!!");
- delayForSeconds(1);
+ report.setText("We don't have any guns!!!");
}
@@ -429,23 +422,20 @@ public class ShipWarfareGUI extends Application {
setNumOfPeasantShips(numOfPeasantShips - howMuchRun);
if (userAttacks == true) {
- System.out.printf("Ahhh, %d ships ran away %s!\n", howMuchRun, player.getName());
+ runAwayOrLeft.setText(String.format("Ahhh, %d ships ran away %s!\n", howMuchRun, player.getName()));
} else {
- System.out.printf("Escaped %d of them!\n", howMuchRun);
+ runAwayOrLeft.setText(String.format("Escaped %d of them!\n", howMuchRun));
}
}
}
}
- System.out.printf("%d ships remaining\n", numOfPeasantShips);
- delayForSeconds(1);
- System.out.println("Oh no, they are taking the offensive!");
- delayForSeconds(1);
+ shipsRemaining.setText(String.format("%d ships remaining and they look angry!\n", numOfPeasantShips));
//Computer volley
int takeGunChance = randomValue.nextInt(4) + 1;
if (takeGunChance == 1 && player.getGuns() > 0) {
player.setGuns(player.getGuns() - 1);
- System.out.println("Dang it! They destroyed one of our guns");
+ gunFrustration=true;
} else {
player.setHP(player.getHP() - (1 + randomValue.nextInt(10)));
}
@@ -453,42 +443,53 @@ public class ShipWarfareGUI extends Application {
exitValue = 2;
break;
}
- System.out.printf("EEK, our current ship status is %d%% \n", player.getHP());
- delayForSeconds(1);
+ if(gunFrustration==true){
+ gunsLeftOrTaken.setText(String.format("Dang it! We only have %d guns left", player.getGuns()));
+ }
+ else{
+ gunsLeftOrTaken.setText(String.format("We still have %d guns left", player.getGuns()));
+ }
+
+ HPLeft.setText(String.format("EEK, our current ship status is %d%% \n", player.getHP()));
if (userAttacks == false) {
userAttacks = true;
}
- System.out.printf("Shall we continue to fight? Enter \"f\" to fight, and \"r\" to run (We have %d gun(s) left)\n", player.getGuns());
+ continueToFight.setText(String.format("Shall we continue to fight? (Click the fight button or the run button)\n", player.getGuns()));
+
+ if (runButton.isPressed()) {
- String response = userInput.nextLine();
- if (response.equalsIgnoreCase("r")) {
if (runFromShips() == false) {
- System.out.println("Couldn't run away");
+ wipe();
+ chooseFightOrRun.setText("Couldn't run away");
} else {
exitValue = 3;
break;
}
}
+ else if(fightButton.isPressed()){
+ title.setText("AYYYYYYYYYYY");
+ }
+ else{
+
+ }
+
}
if (exitValue == 1) {
System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d%% ship status\n", player.getHP());
- delayForSeconds(1);
calculateLoot = (randomValue.nextInt(startingPeasantShips) + startingPeasantShips) * 100;
player.setMoney(player.getMoney() + calculateLoot);
System.out.printf("We got $%,d!", calculateLoot);
- delayForSeconds(2);
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());
- delayForSeconds(2);
return true;
}
return false;
@@ -521,7 +522,7 @@ public class ShipWarfareGUI extends Application {
public void setLabel1(String sysOut) {
- label1.setText(sysOut);
+ report.setText(sysOut);
}
/*
@@ -533,7 +534,7 @@ public class ShipWarfareGUI extends Application {
*/
public void start(Stage stage) throws Exception {
- shipWarfare.setNumOfPeasantShips(shipWarfare.numOfShips());
+ setNumOfPeasantShips(numOfShips());
BorderPane BorderPane = new BorderPane();
@@ -543,13 +544,19 @@ public class ShipWarfareGUI extends Application {
gridPane.setVgap(5.0);
hBox = new HBox();
- button1 = new Button();
- button2 = new Button();
+ fightButton = new Button();
+ runButton = new Button();
vBox = new VBox();
- label1 = new Label();
- label = new Label();
- vBox0 = new VBox();
- label0 = new Label();
+ title = new Label();
+ chooseFightOrRun = new Label();
+ report = new Label();
+ runAwayOrLeft = new Label();
+ shipsRemaining = new Label();
+ HPLeft = new Label();
+ gunsLeftOrTaken = new Label();
+ continueToFight = new Label();
+
+
BorderPane.setPrefHeight(400.0);
BorderPane.setPrefWidth(600.0);
@@ -558,16 +565,22 @@ public class ShipWarfareGUI extends Application {
hBox.setPrefWidth(200.0);
hBox.setSpacing(10.0);
- button1.setAlignment(javafx.geometry.Pos.CENTER);
- button1.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
- button1.setId("Button1");
- button1.setMnemonicParsing(false);
- button1.setText("Fight");
+ title.setAlignment(javafx.geometry.Pos.TOP_CENTER);
+ title.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
+ title.setId("Label1");
+ 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));
- button2.setAlignment(javafx.geometry.Pos.CENTER);
- button2.setId("Button2");
- button2.setMnemonicParsing(false);
- button2.setText("Run");
+ fightButton.setAlignment(javafx.geometry.Pos.CENTER);
+ fightButton.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
+ fightButton.setId("Button1");
+ fightButton.setMnemonicParsing(false);
+ fightButton.setText("Fight");
+
+ runButton.setAlignment(javafx.geometry.Pos.CENTER);
+ runButton.setId("Button2");
+ runButton.setMnemonicParsing(false);
+ runButton.setText("Run");
BorderPane.setBottom(hBox);
BorderPane.setAlignment(vBox, javafx.geometry.Pos.CENTER);
@@ -576,76 +589,45 @@ public class ShipWarfareGUI extends Application {
vBox.setPrefWidth(100.0);
vBox.setSpacing(20.0);
- label1.setAlignment(javafx.geometry.Pos.TOP_CENTER);
- label1.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
- label1.setId("Label1");
- label1.setPadding(new Insets(6.0, 0.0, 0.0, 0.0));
+ report.setAlignment(javafx.geometry.Pos.TOP_CENTER);
+ report.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
+ report.setId("Label1");
+ report.setPadding(new Insets(6.0, 0.0, 0.0, 0.0));
vBox.setPadding(new Insets(0.0, 0.0, 10.0, 0.0));
BorderPane.setTop(vBox);
BorderPane.setPadding(new Insets(6.0, 0.0, 0.0, 0.0));
- vBox0.setAlignment(javafx.geometry.Pos.TOP_CENTER);
- vBox0.setPrefHeight(200.0);
- vBox0.setPrefWidth(100.0);
- vBox0.setSpacing(5.0);
- hBox.getChildren().add(button1);
- hBox.getChildren().add(button2);
- vBox.getChildren().add(label1);
- vBox.getChildren().add(label);
- vBox0.getChildren().add(label0);
- vBox.getChildren().add(vBox0);
- int calculateLoot = 0;
- int chanceOfEnemyRun = 0;
+ hBox.getChildren().add(fightButton);
+ hBox.getChildren().add(runButton);
+ vBox.getChildren().add(title);
+ vBox.getChildren().add(chooseFightOrRun);
+ vBox.getChildren().add(report);
+ vBox.getChildren().add(runAwayOrLeft);
+ vBox.getChildren().add(shipsRemaining);
+ vBox.getChildren().add(HPLeft);
+ vBox.getChildren().add(gunsLeftOrTaken);
+ vBox.getChildren().add(continueToFight);
- //label1.setText(String.format("By Golly! We have $%,d and are being attacked by %d Merchant ships\nCurrently our ship status is %d%%\n", player.getMoney(), shipWarfare.getNumOfPeasantShips(), player.getHP()));
- label.setText("What would you like to do?");
+
+
+
+ //report.setText(String.format("By Golly! We have $%,d and are being attacked by %d Merchant ships\nCurrently our ship status is %d%%\n", player.getMoney(), shipWarfare.getNumOfPeasantShips(), player.getHP()));
//Fight
- button1.setOnAction(new EventHandler() {
+ fightButton.setOnAction(new EventHandler() {
@Override
- public void handle(ActionEvent event) {
+ public void handle(ActionEvent event) {
counter++;
if (counter == 1) {
- label.setText("Ohh, Fight ehh?");
+ chooseFightOrRun.setText("Ohh, Fight ehh?");
+ try {
+ destroyPeasantShipsOrEscape();
+ }
+ catch(Exception e){
- int hitCounter=0;
- int missCounter=0;
-
- Random randomValue = new Random();
- int exitValue = 0;
- while (exitValue == 0) {
- if (player.getGuns() > 0) {
-
- for (int j = 0; j < player.getGuns(); j++) {
- if (userAttacks == true) {
- int hitOrMiss = randomValue.nextInt(2) + 1;
- if (hitOrMiss == 2) {
- numOfPeasantShips--;
- if (numOfPeasantShips <= 0) {
- exitValue = 1;
- break;
- }
- hitCounter++;
- delayForSeconds(1);
- } else {
- missCounter++;
- delayForSeconds(1);
- }
-
-
- } else {
- continue;
- }
- }
- label1.setText(String.format("Report:\nShips we hit: %d\nShots missed: %d", hitCounter, missCounter));
- } else {
- label1.setText("We don't have any guns!!!");
- delayForSeconds(1);
-
- }
}
@@ -653,30 +635,30 @@ public class ShipWarfareGUI extends Application {
}
if (counter == 2) {
System.out.println("You pressed the button twice.");
- button1.setVisible(false);
- button2.setVisible(false);
- button1.setDisable(true);
- button2.setDisable(true);
+ fightButton.setVisible(false);
+ runButton.setVisible(false);
+ fightButton.setDisable(true);
+ runButton.setDisable(true);
}
}
});
//Flee
- button2.setOnAction(new EventHandler() {
+ runButton.setOnAction(new EventHandler() {
@Override
public void handle(ActionEvent event) {
counter++;
if (counter == 1) {
- label1.setText("Ohh, Run ehh?");
+ chooseFightOrRun.setText("Ohh, Run ehh?");
}
if (counter == 2) {
System.out.println("You pressed the button twice.");
- button1.setVisible(false);
- button2.setVisible(false);
- button1.setDisable(true);
- button2.setDisable(true);
+ fightButton.setVisible(false);
+ runButton.setVisible(false);
+ fightButton.setDisable(true);
+ runButton.setDisable(true);
}
}
});
From 9feac6e90e7c382dbc126d9d462096ca379889cc Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sat, 9 Mar 2019 22:52:30 -0700
Subject: [PATCH 2/2] Forces you to fight in ShipWarfareGUI unfortunately
---
.idea/workspace.xml | 47 ++++++++++++++++++++++++-----------------
src/ShipWarfareGUI.java | 14 ++++++------
2 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 827b9ae..234d2ae 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,7 +3,6 @@
-
@@ -32,12 +31,12 @@
-
-
+
+
-
-
+
+
@@ -86,9 +85,6 @@
- shop
- being
- label0
hBox
<
winO
@@ -116,6 +112,9 @@
destr
destro
hitco
+ setNum
+ game
+ numOf
HP
@@ -157,6 +156,8 @@
+
+
@@ -173,15 +174,13 @@
-
-
-
+
@@ -283,6 +282,8 @@
+
+
1550458470138
@@ -410,17 +411,24 @@
1552187032139
-
+
+ 1552195966566
+
+
+
+ 1552195966566
+
+
-
+
-
+
@@ -536,7 +544,8 @@
-
+
+
@@ -634,12 +643,12 @@
-
-
+
+
-
-
+
+
diff --git a/src/ShipWarfareGUI.java b/src/ShipWarfareGUI.java
index 21cf3db..ac44710 100644
--- a/src/ShipWarfareGUI.java
+++ b/src/ShipWarfareGUI.java
@@ -422,15 +422,15 @@ public class ShipWarfareGUI extends Application {
setNumOfPeasantShips(numOfPeasantShips - howMuchRun);
if (userAttacks == true) {
- runAwayOrLeft.setText(String.format("Ahhh, %d ships ran away %s!\n", howMuchRun, player.getName()));
+ runAwayOrLeft.setText(String.format("Ahhh, %d ships ran away %s! ", howMuchRun, player.getName()));
} else {
- runAwayOrLeft.setText(String.format("Escaped %d of them!\n", howMuchRun));
+ runAwayOrLeft.setText(String.format("Escaped %d of them! ", howMuchRun));
}
}
}
}
- shipsRemaining.setText(String.format("%d ships remaining and they look angry!\n", numOfPeasantShips));
+ shipsRemaining.setText(String.format("%d ships remaining and they look angry!", numOfPeasantShips));
//Computer volley
int takeGunChance = randomValue.nextInt(4) + 1;
if (takeGunChance == 1 && player.getGuns() > 0) {
@@ -450,12 +450,12 @@ public class ShipWarfareGUI extends Application {
gunsLeftOrTaken.setText(String.format("We still have %d guns left", player.getGuns()));
}
- HPLeft.setText(String.format("EEK, our current ship status is %d%% \n", player.getHP()));
+ HPLeft.setText(String.format("EEK, our current ship status is %d%% ", player.getHP()));
if (userAttacks == false) {
userAttacks = true;
}
- continueToFight.setText(String.format("Shall we continue to fight? (Click the fight button or the run button)\n", player.getGuns()));
+ continueToFight.setText(String.format("Shall we continue to fight? (Click the fight button or the run button)", player.getGuns()));
if (runButton.isPressed()) {
@@ -480,10 +480,12 @@ public class ShipWarfareGUI extends Application {
if (exitValue == 1) {
+ wipe();
+ chooseFightOrRun.setText(String.format("Ayy We won! We survived at %d ship status!", player.getHP()));
System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d%% ship status\n", player.getHP());
calculateLoot = (randomValue.nextInt(startingPeasantShips) + startingPeasantShips) * 100;
player.setMoney(player.getMoney() + calculateLoot);
- System.out.printf("We got $%,d!", calculateLoot);
+ report.setText(String.format("We got $%,d! ",calculateLoot));
return true;
} else if (exitValue == 2) {
player.gameOver();