Perhaps done basic ship warfare? (still must add Liu yen difficulty, ships running away, and Loot)

This commit is contained in:
KahootChampion
2019-02-20 16:07:44 -07:00
parent 4598d219c7
commit 03b08e4de3
2 changed files with 70 additions and 72 deletions

View File

@@ -2,13 +2,13 @@ public class Player {
private String name = "Taipan";
private int bank = 0;
private int money = 100000000;
private int money = 1000;
private int opiumHeld = 0;
private int silkHeld = 0;
private int generalHeld = 0;
private int armsHeld = 0;
private int location = 1;
private int guns = 6;
private int guns = 3;
private int HP = 100;
@@ -116,8 +116,13 @@ public class Player {
}
public static void main(String[] args) throws Exception {
ShipWarfare littyboi = new ShipWarfare();
ShipWarfare littyWarfare = new ShipWarfare();
TaipanShop littyShop = new TaipanShop();
littyShop.shop();
littyWarfare.peasantFleetAttack();
littyShop.shop();
}

View File

@@ -11,7 +11,7 @@ public class ShipWarfare extends Player {
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.printf("By Golly! We have $%,d and are being attacked by %d ships\nCurrently our ship status is %d%%\n", getMoney(), getNumOfPeasantShips(),getHP());
fightOrRunMessage();
while (true) {
String response = userResponse.nextLine();
@@ -25,11 +25,12 @@ public class ShipWarfare extends Player {
} else if (response.equalsIgnoreCase("r")) {
runFromShips();
if (runFromShips() == false) {
System.out.println("Couldn't run away!");
destroyShipsOrEscape(getNumOfPeasantShips());
if(destroyShipsOrEscape(getNumOfPeasantShips()))
break;
} else {
System.out.println("Phew! Got away safely");
break;
}
@@ -101,10 +102,7 @@ public class ShipWarfare extends Player {
int exitValue = 0;
//Player volley
if (exitValue == 0) {
while (exitValue == 0) {
for (int i = 0; i < numOfPeasantShips; i++) {
for (int j = 0; j < getGuns(); j++) {
if (userAttacks == true) {
int hitOrMiss = randomValue.nextInt(2) + 1;
@@ -148,17 +146,16 @@ public class ShipWarfare extends Player {
exitValue = 2;
break;
}
System.out.printf("EEK, we have %d health left\n", getHP());
System.out.printf("EEK, our current ship status is %d%% \n", getHP());
delayForASecond();
if (userAttacks == false) {
userAttacks = true;
}
System.out.printf("Shall we continue to fight? Enter \"f\" to fight, and \"r\" to run (We have %d guns left)", getGuns());
System.out.printf("Shall we continue to fight? Enter \"f\" to fight, and \"r\" to run (We have %d gun(s) left)", getGuns());
String response = userInput.nextLine();
if (response.equalsIgnoreCase("r")) {
runFromShips();
if (runFromShips() == false) {
System.out.println("Couldn't run away");
} else {
@@ -169,19 +166,16 @@ public class ShipWarfare extends Player {
}
if (runFromShips() == true) {
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());
System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d%% ship status\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());
System.out.printf("We made it out at %d%% ship status!\n", getHP());
return true;
}
return false;
@@ -198,4 +192,3 @@ public class ShipWarfare extends Player {
}