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J5ku(F4Na6+}`QQi`)%wd&2)RD!`Jm{WBuqC*bV6axu
z<~+JOj}8iYtDxaLT6Y0Xi%-Dep^g=EyrK}%4U8pldxrOJrvoIAyBMrHv6lYcg55N?
zlTPizK05Xx5|<=&3pN(1lo0=3-Z6ewX)pSCmc+_|{xw!96Z^v93i4wG7g?SxvTSV9
zn2$mT|
z5-d@D`MlOprS_6_giWwo_0W3}R!EKNq7NfXWvRt>1aHuZrilZjv0IW}k<$YFY5^5$
zA%jL$b{&E1F#H`0=wxr@RHWKK`Jx7EGakc*G9fC@7@vcAY+|RnwVQ9vcW(B-!s~UF
lCCdiJM_AYwI%+B3h7n2@%{;`mqtGeO%C{|il=BkA{|gfmzzzTa
diff --git a/src/Player.java b/src/Player.java
index 18d8116..a82f6d3 100644
--- a/src/Player.java
+++ b/src/Player.java
@@ -2,13 +2,13 @@ public class Player {
private String name = "Taipan";
private int bank = 0;
- private int money = 1000;
+ private int money = 100000000;
private int opiumHeld = 0;
private int silkHeld = 0;
private int generalHeld = 0;
private int armsHeld = 0;
private int location = 1;
- private int guns = 3;
+ private int guns = 6;
private int HP = 100;
@@ -25,9 +25,9 @@ public class Player {
}
public void setHP(int HP) {
- if(HP>= 0){
- this.HP = HP;
- }
+
+ this.HP = HP;
+
}
public int getBank() {
@@ -35,7 +35,7 @@ public class Player {
}
public void setBank(int bank) {
- if(bank>= 0) {
+ if (bank >= 0) {
this.bank = bank;
}
}
@@ -45,7 +45,7 @@ public class Player {
}
public void setMoney(int money) {
- if(money>= 0) {
+ if (money >= 0) {
this.money = money;
}
}
@@ -55,7 +55,7 @@ public class Player {
}
public void setOpiumHeld(int opiumHeld) {
- if(opiumHeld>= 0) {
+ if (opiumHeld >= 0) {
this.opiumHeld = opiumHeld;
}
}
@@ -65,7 +65,7 @@ public class Player {
}
public void setSilkHeld(int silkHeld) {
- if(silkHeld>= 0) {
+ if (silkHeld >= 0) {
this.silkHeld = silkHeld;
}
}
@@ -75,7 +75,7 @@ public class Player {
}
public void setGeneralHeld(int generalHeld) {
- if(generalHeld>= 0) {
+ if (generalHeld >= 0) {
this.generalHeld = generalHeld;
}
}
@@ -85,7 +85,7 @@ public class Player {
}
public void setArmsHeld(int armsHeld) {
- if(armsHeld>= 0) {
+ if (armsHeld >= 0) {
this.armsHeld = armsHeld;
}
}
@@ -95,7 +95,7 @@ public class Player {
}
public void setLocation(int location) {
- if(location>= 0) {
+ if (location >= 0) {
this.location = location;
}
}
@@ -105,7 +105,7 @@ public class Player {
}
public void setGuns(int guns) {
- if(guns>= 0) {
+ if (guns >= 0) {
this.guns = guns;
}
}
@@ -115,7 +115,7 @@ public class Player {
System.out.println("Game over");
}
- public static void main(String[] args) throws Exception{
+ public static void main(String[] args) throws Exception {
ShipWarfare littyboi = new ShipWarfare();
TaipanShop littyShop = new TaipanShop();
littyShop.shop();
diff --git a/src/ShipWarfare.java b/src/ShipWarfare.java
index aec5b46..a4e80b9 100644
--- a/src/ShipWarfare.java
+++ b/src/ShipWarfare.java
@@ -5,34 +5,31 @@ import java.util.concurrent.TimeUnit;
public class ShipWarfare extends Player {
private int numOfPeasantShips = 0;
- private boolean userAttacks= true;
-
+ private boolean userAttacks = true;
public void peasantFleetAttack() throws Exception {
Scanner userResponse = new Scanner(System.in);
setNumOfPeasantShips(numOfShips());
System.out.printf("By Golly! We have $%,d \nwe are being attacked by %d ships\n", getMoney(), getNumOfPeasantShips());
- System.out.println("What do you want to do? Enter \"f\" to fight, and \"r\" to run ");
+ fightOrRunMessage();
while (true) {
String response = userResponse.nextLine();
if (response.equalsIgnoreCase("f")) {
- userAttacks=true;
+ userAttacks = true;
System.out.println("Ohh, fight ehh?");
- boolean winOrLose= destroyShipsOrEscape(getNumOfPeasantShips());
- if(winOrLose==true){
+ boolean winOrLose = destroyShipsOrEscape(getNumOfPeasantShips());
+ if (winOrLose == true) {
break;
}
-
} else if (response.equalsIgnoreCase("r")) {
runFromShips();
- if(runFromShips()==false) {
+ if (runFromShips() == false) {
System.out.println("Couldn't run away!");
destroyShipsOrEscape(getNumOfPeasantShips());
- }
- else{
+ } else {
break;
}
@@ -44,6 +41,11 @@ public class ShipWarfare extends Player {
}
+ public void fightOrRunMessage() {
+ System.out.printf("What do you want to do? Enter \"f\" to fight, and \"r\" to run (we have %d guns)", getGuns());
+
+ }
+
public int getNumOfPeasantShips() {
return numOfPeasantShips;
}
@@ -81,7 +83,7 @@ public class ShipWarfare extends Player {
}
public boolean runFromShips() {
- userAttacks=false;
+ userAttacks = false;
Random randomValue = new Random();
int runSuccessChance = randomValue.nextInt(2) + 1;
if (runSuccessChance == 2) {
@@ -95,21 +97,21 @@ public class ShipWarfare extends Player {
public boolean destroyShipsOrEscape(int typeOfShip) throws Exception {
Scanner userInput = new Scanner(System.in);
Random randomValue = new Random();
- int shipsRemaining = typeOfShip;
- int exitValue=0;
- int counter=0;
+ numOfPeasantShips = typeOfShip;
+ int exitValue = 0;
- //Player volley
+ //Player volley
+ if (exitValue == 0) {
while (exitValue == 0) {
- counter++;
- for (int i = 0; i < shipsRemaining; i++) {
- if (userAttacks==true) {
- for (int j = 0; j < getGuns(); j++) {
+ for (int i = 0; i < numOfPeasantShips; i++) {
+
+ for (int j = 0; j < getGuns(); j++) {
+ if (userAttacks == true) {
int hitOrMiss = randomValue.nextInt(2) + 1;
if (hitOrMiss == 2) {
- shipsRemaining--;
- if (shipsRemaining <= 0) {
- exitValue= 1;
+ numOfPeasantShips--;
+ if (numOfPeasantShips <= 0) {
+ exitValue = 1;
break;
}
System.out.println("Got eem");
@@ -120,30 +122,39 @@ public class ShipWarfare extends Player {
}
+ } else {
+ continue;
}
}
- if (shipsRemaining <= 0) {
+
+ if (numOfPeasantShips <= 0) {
exitValue = 1;
break;
}
- System.out.printf("%d ships remaining\n", shipsRemaining);
+ System.out.printf("%d ships remaining\n", getNumOfPeasantShips());
System.out.println("Oh no, they are taking the offensive!");
delayForASecond();
//Computer volley
- setHP(getHP() - (1+ randomValue.nextInt(10)));
+ int takeGunChance = randomValue.nextInt(4) + 1;
+ if (takeGunChance == 1 && getGuns() > 0) {
+ setGuns(getGuns() - 1);
+ System.out.println("Dang it! They destroyed one of our guns");
+ } else {
+ setHP(getHP() - (1 + randomValue.nextInt(10)));
+ }
if (getHP() <= 0) {
exitValue = 2;
break;
}
System.out.printf("EEK, we have %d health left\n", getHP());
delayForASecond();
- if(userAttacks==false){
- userAttacks=true;
+ if (userAttacks == false) {
+ userAttacks = true;
}
- System.out.println("Shall we continue to fight? Enter \"f\" to fight, and \"r\" to run");
+ System.out.printf("Shall we continue to fight? Enter \"f\" to fight, and \"r\" to run (We have %d guns left)", getGuns());
String response = userInput.nextLine();
if (response.equalsIgnoreCase("r")) {
@@ -162,27 +173,29 @@ public class ShipWarfare extends Player {
break;
}
}
- if (exitValue == 1) {
- System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d health\n", getHP());
- return true;
- } else if (exitValue == 2) {
- gameOver();
- return true;
- } else if (exitValue == 3) {
- System.out.printf("We made it out at %d health!\n", getHP());
- return true;
- }
- return false;
-
-
}
- //Type of ship implied to be Liu Yen fleet
+ if (exitValue == 1) {
+ System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d health\n", getHP());
+ return true;
+ } else if (exitValue == 2) {
+ gameOver();
+ return true;
+ } else if (exitValue == 3) {
+ System.out.printf("We made it out at %d health!\n", getHP());
+ return true;
+ }
+ return false;
+ }
+ //Type of ship implied to be Liu Yen fleet
+
public static void main(String[] args) throws Exception {
ShipWarfare littyObject = new ShipWarfare();
littyObject.peasantFleetAttack();
}
-}
\ No newline at end of file
+}
+
+