Perhaps done basic ship warfare? (still must add Liu yen difficulty, ships running away, and Loot)
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user