From 5c41bf5b7ca508f9d5206c2bc9481a56074ec2fc Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Mon, 18 Feb 2019 18:32:56 -0700
Subject: [PATCH] Added retreat option (not perfected)
---
.idea/workspace.xml | 263 ++++---------------
out/production/TaipanClone/ShipWarfare.class | Bin 0 -> 4668 bytes
src/ShipWarfare.java | 150 ++++++-----
3 files changed, 145 insertions(+), 268 deletions(-)
create mode 100644 out/production/TaipanClone/ShipWarfare.class
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 89f9e3b..8594e1d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,7 +3,8 @@
-
+
+
@@ -14,31 +15,20 @@
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -47,8 +37,8 @@
-
-
+
+
@@ -56,64 +46,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -127,7 +62,9 @@
- Hp
+ couldn
+ could
+ runFromShips
@@ -137,27 +74,21 @@
-
-
-
-
-
-
-
+
+
+
+
+
-
-
@@ -174,15 +105,15 @@
+
+
-
-
-
-
+
+
@@ -230,7 +161,7 @@
- C:\Users\Harkamal Randhawa\AppData\Roaming\Subversion
+ $USER_HOME$/.subversion
125
@@ -241,43 +172,25 @@
1550454898506
-
-
-
-
-
- 1550458470138
+
+ 1550458807806
- 1550458470138
+ 1550458807807
-
- 1550540282400
-
-
-
- 1550540282400
-
-
- 1550540820542
-
-
-
- 1550540820542
-
-
+
-
+
-
+
-
+
@@ -286,17 +199,17 @@
-
+
-
+
-
-
+
+
@@ -316,23 +229,17 @@
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
-
+
+
@@ -341,77 +248,17 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/out/production/TaipanClone/ShipWarfare.class b/out/production/TaipanClone/ShipWarfare.class
new file mode 100644
index 0000000000000000000000000000000000000000..61073a43e19673ad2174b0260f22892dfd02124a
GIT binary patch
literal 4668
zcma)9TW}QD5k0f7SuG=Jk+cGgfB}Oogs>b3D~=H|LY8EKgowl=fFF!@XSIuWXXV*h
z!P>-6{C4bwBz|B!#@LShz;R5BaE$RQ&QGfHk>n#)$wxl(lT_s|6&DUUJu{XTWnGn0
z>CU}9x6keFd%An}xBvOzBLExln;2^0)NodkVM>NWG8|S>uECwSD~1S;#3=cm40ns{
zo+$2Bai6U3kKq9vmDz(aJcNg%ctoC$iq>OMJRZXn_dSf%^;__-
zq&ewiiLT;J9yMV)!(K?}C4-_;FyO`|%-Ky0O%tE=cYbujMelW}bx@)c<(X)Z*r
z`=joQjbsv|WS6XdyO8&x=pI8Gr*N#4Oq#`FZ^p2a)Ne|eMaM3b-F+i=UomM+QY?N^
zp(c}cM(p8ik(a3)>t)!8>&SGMP?cm+@s@^Dcw3Zyu3}P;mX0vOZAA<;pAd
zJ*J*9rc8bHn)Z|)J7ntQv_5XqQ{8Z>Y^L<_vc4vzyK#uousQa6hHDtX4i)ceIE`Ow
z7?Z_&8qQ!w!Nxrq!_iX(y<8~ihnR=DQ{eIjz0Yz?TVIu4C4zKzBIC5{yl8!u?Mis1
zx`wlOU&F8P0k0@cs%toh51FkanM}K$Img7>O@v9)|_E&6SxYmqhbgR&=I~lX=2G=oem*{e>7t(3dDrTq5l^RCn
zigsd`f|kC%ZS6X*!o3)RW=tdJWb~Ywb_m!zmN9ZUdCxp^vR28w6zl(qt%ChA->um0
zY|<&%<(08PM>i%}%k1Lp;VCn18V;QlYfa0{m-Vz%IrpmaM#|K)j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wk7?%C0K1b(?nRkb14whG@~q3<=BJXm|HK4k5#gQB
zTbX4j<5#S*3t2YA02-BHm&-vk^TdOE8^RK00Jn1{RS^7Tw(ueY7g3R8@@*4(vp`*d
zs$4)F|JNvWUtqx(2* 1000000){
+ } else if (getMoney() > 1000000) {
//Minimum 100 ships will attack, maximum 300 ships
numOfShipsAttacking = randomValue.nextInt(3) + 100;
}
@@ -110,35 +105,46 @@ public class ShipWarfare {
}
+ public boolean runFromShips() {
+ Random randomValue = new Random();
+ int runSuccessChance = randomValue.nextInt(2) + 1;
+ if (runSuccessChance == 2) {
+ return true;
+ } else if (runSuccessChance == 1) {
+ System.out.println("Couldn't run away");
+ return false;
+ }
+ return false;
+ }
-
-
- public void fightShips(int typeOfShip) throws Exception {
-
+ public boolean destroyShipsOrEscape(int typeOfShip) throws Exception {
+ Scanner userInput = new Scanner(System.in);
Random randomValue = new Random();
int shipsRemaining = typeOfShip;
int exitValue=0;
- if(typeOfShip==getNumOfPeasantShips()) {
+ if (exitValue == 0) {
//Player volley
- while (exitValue==0){
+ while (exitValue == 0) {
for (int i = 0; i < shipsRemaining; i++) {
- for (int j = 0; j < getGuns(); j++) {
- int hitOrMiss = randomValue.nextInt(2) + 1;
- if (hitOrMiss == 2) {
- shipsRemaining--;
- if (shipsRemaining <= 0) {
- exitValue = 1;
- break;
+ if (exitValue == 0) {
+ for (int j = 0; j < getGuns(); j++) {
+ int hitOrMiss = randomValue.nextInt(2) + 1;
+ if (hitOrMiss == 2) {
+ shipsRemaining--;
+ if (shipsRemaining <= 0) {
+ exitValue = 1;
+ break;
+ }
+ System.out.println("Got eem");
+ delayForASecond();
+ } else {
+ System.out.println("ARRG! We missed captain");
+ delayForASecond();
}
- System.out.println("Got eem");
- delayForASecond();
- } else {
- System.out.println("ARRG! We missed captain");
- delayForASecond();
+
+
}
-
-
}
if (shipsRemaining <= 0) {
@@ -151,31 +157,55 @@ public class ShipWarfare {
delayForASecond();
//Computer volley
setHp(getHp() - randomValue.nextInt(10));
- if(getHp()<=0){
- exitValue=2;
+ if (getHp() <= 0) {
+ exitValue = 2;
break;
}
System.out.printf("EEK, we have %d health left\n", getHp());
delayForASecond();
+ System.out.println("Shall we continue the offensive? Enter \"f\" to fight, and \"r\" to run");
+
+ String response = userInput.nextLine();
+ if (response.equalsIgnoreCase("r")) {
+ runFromShips();
+ if (runFromShips() == false) {
+ exitValue = 6;
+ } else {
+ exitValue = 3;
+ break;
+ }
+ }
+
+
+ }
+ if (runFromShips() == true) {
+ break;
}
}
- if(exitValue==1) {
- System.out.printf("Got eem!\nIt appears we have defeated the enemy fleet and made it out at %d health\n", hp);
- }
- else if(exitValue==2){
+ 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", hp);
+ return true;
+ } else if (exitValue == 2) {
gameOver();
+ return true;
+ } else if (exitValue == 3) {
+ System.out.println("We made it");
+ return true;
}
+ return false;
+
}
//Type of ship implied to be Liu Yen fleet
- else{
+ else {
}
+ return false;
}
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) throws Exception {
ShipWarfare littyObject = new ShipWarfare();
littyObject.peasantFleetAttack();
}