I think I got the basic battling system down. Would appreciate i some of you guys beta tested it though and let me know the errors if there are any.
This commit is contained in:
Binary file not shown.
@@ -5,6 +5,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class ShipWarfare extends Player {
|
public class ShipWarfare extends Player {
|
||||||
|
|
||||||
private int numOfPeasantShips = 0;
|
private int numOfPeasantShips = 0;
|
||||||
|
private boolean userAttacks= true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void peasantFleetAttack() throws Exception {
|
public void peasantFleetAttack() throws Exception {
|
||||||
@@ -15,6 +17,7 @@ public class ShipWarfare extends Player {
|
|||||||
while (true) {
|
while (true) {
|
||||||
String response = userResponse.nextLine();
|
String response = userResponse.nextLine();
|
||||||
if (response.equalsIgnoreCase("f")) {
|
if (response.equalsIgnoreCase("f")) {
|
||||||
|
userAttacks=true;
|
||||||
System.out.println("Ohh, fight ehh?");
|
System.out.println("Ohh, fight ehh?");
|
||||||
boolean winOrLose= destroyShipsOrEscape(getNumOfPeasantShips());
|
boolean winOrLose= destroyShipsOrEscape(getNumOfPeasantShips());
|
||||||
if(winOrLose==true){
|
if(winOrLose==true){
|
||||||
@@ -25,7 +28,11 @@ public class ShipWarfare extends Player {
|
|||||||
|
|
||||||
} else if (response.equalsIgnoreCase("r")) {
|
} else if (response.equalsIgnoreCase("r")) {
|
||||||
runFromShips();
|
runFromShips();
|
||||||
if(runFromShips()==true){
|
if(runFromShips()==false) {
|
||||||
|
System.out.println("Couldn't run away!");
|
||||||
|
destroyShipsOrEscape(getNumOfPeasantShips());
|
||||||
|
}
|
||||||
|
else{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,12 +81,12 @@ public class ShipWarfare extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean runFromShips() {
|
public boolean runFromShips() {
|
||||||
|
userAttacks=false;
|
||||||
Random randomValue = new Random();
|
Random randomValue = new Random();
|
||||||
int runSuccessChance = randomValue.nextInt(2) + 1;
|
int runSuccessChance = randomValue.nextInt(2) + 1;
|
||||||
if (runSuccessChance == 2) {
|
if (runSuccessChance == 2) {
|
||||||
return true;
|
return true;
|
||||||
} else if (runSuccessChance == 1) {
|
} else if (runSuccessChance == 1) {
|
||||||
System.out.println("Couldn't run away");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -90,18 +97,19 @@ public class ShipWarfare extends Player {
|
|||||||
Random randomValue = new Random();
|
Random randomValue = new Random();
|
||||||
int shipsRemaining = typeOfShip;
|
int shipsRemaining = typeOfShip;
|
||||||
int exitValue=0;
|
int exitValue=0;
|
||||||
|
int counter=0;
|
||||||
|
|
||||||
if (exitValue == 0) {
|
|
||||||
//Player volley
|
//Player volley
|
||||||
while (exitValue == 0) {
|
while (exitValue == 0) {
|
||||||
|
counter++;
|
||||||
for (int i = 0; i < shipsRemaining; i++) {
|
for (int i = 0; i < shipsRemaining; i++) {
|
||||||
if (exitValue == 0) {
|
if (userAttacks==true) {
|
||||||
for (int j = 0; j < getGuns(); j++) {
|
for (int j = 0; j < getGuns(); j++) {
|
||||||
int hitOrMiss = randomValue.nextInt(2) + 1;
|
int hitOrMiss = randomValue.nextInt(2) + 1;
|
||||||
if (hitOrMiss == 2) {
|
if (hitOrMiss == 2) {
|
||||||
shipsRemaining--;
|
shipsRemaining--;
|
||||||
if (shipsRemaining <= 0) {
|
if (shipsRemaining <= 0) {
|
||||||
exitValue = 1;
|
exitValue= 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
System.out.println("Got eem");
|
System.out.println("Got eem");
|
||||||
@@ -138,7 +146,7 @@ public class ShipWarfare extends Player {
|
|||||||
if (response.equalsIgnoreCase("r")) {
|
if (response.equalsIgnoreCase("r")) {
|
||||||
runFromShips();
|
runFromShips();
|
||||||
if (runFromShips() == false) {
|
if (runFromShips() == false) {
|
||||||
exitValue = 6;
|
System.out.println("Couldn't run away");
|
||||||
} else {
|
} else {
|
||||||
exitValue = 3;
|
exitValue = 3;
|
||||||
break;
|
break;
|
||||||
@@ -167,11 +175,7 @@ public class ShipWarfare extends Player {
|
|||||||
}
|
}
|
||||||
//Type of ship implied to be Liu Yen fleet
|
//Type of ship implied to be Liu Yen fleet
|
||||||
|
|
||||||
else {
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ShipWarfare littyObject = new ShipWarfare();
|
ShipWarfare littyObject = new ShipWarfare();
|
||||||
|
|||||||
Reference in New Issue
Block a user