For some reason, the setHp method works only in shipwarfareGUI but does not transfer to TaipanShopGUI
This commit is contained in:
@@ -76,24 +76,24 @@ public class ShipWarfareGUI extends Player {
|
|||||||
* Sets most of the labels invisible except for the "fight or run" label
|
* Sets most of the labels invisible except for the "fight or run" label
|
||||||
*/
|
*/
|
||||||
public void wipe() {
|
public void wipe() {
|
||||||
|
wipewithTitle(title);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void wipewithTitle(Label title) {
|
||||||
title.setVisible(false);
|
title.setVisible(false);
|
||||||
runAwayOrLeft.setVisible(false);
|
runAwayOrLeft.setVisible(false);
|
||||||
shipsRemaining.setVisible(false);
|
shipsRemaining.setVisible(false);
|
||||||
HPLeft.setVisible(false);
|
HPLeft.setVisible(false);
|
||||||
gunsLeftOrTaken.setVisible(false);
|
gunsLeftOrTaken.setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets most of the labels invisible including the fight or run label
|
* Sets most of the labels invisible including the fight or run label
|
||||||
*/
|
*/
|
||||||
public void completeWipe() {
|
public void completeWipe() {
|
||||||
title.setVisible(false);
|
wipe();
|
||||||
runAwayOrLeft.setVisible(false);
|
|
||||||
shipsRemaining.setVisible(false);
|
|
||||||
HPLeft.setVisible(false);
|
|
||||||
gunsLeftOrTaken.setVisible(false);
|
|
||||||
report.setVisible(false);
|
report.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,6 @@ public class ShipWarfareGUI extends Player {
|
|||||||
Random randomValue = new Random();
|
Random randomValue = new Random();
|
||||||
int exitValue = 0;
|
int exitValue = 0;
|
||||||
//Player volley
|
//Player volley
|
||||||
//while (exitValue == 0) {
|
|
||||||
if (getGuns() > 0) {
|
if (getGuns() > 0) {
|
||||||
|
|
||||||
for (int j = 0; j < getGuns(); j++) {
|
for (int j = 0; j < getGuns(); j++) {
|
||||||
@@ -126,19 +125,10 @@ public class ShipWarfareGUI extends Player {
|
|||||||
|
|
||||||
int hitOrMiss = randomValue.nextInt(2) + 1;
|
int hitOrMiss = randomValue.nextInt(2) + 1;
|
||||||
if (hitOrMiss == 2) {
|
if (hitOrMiss == 2) {
|
||||||
//numOfLittyShips--;
|
|
||||||
logic.setNumOfLittyShips(logic.getNumOfLittyShips()-1);
|
logic.setNumOfLittyShips(logic.getNumOfLittyShips()-1);
|
||||||
|
|
||||||
/*if (numOfLittyShips <= 0) {
|
|
||||||
exitValue = 1;
|
|
||||||
//break;
|
|
||||||
}
|
|
||||||
hitCounter++;
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (logic.getNumOfLittyShips() <= 0) {
|
if (logic.getNumOfLittyShips() <= 0) {
|
||||||
exitValue = 1;
|
exitValue = 1;
|
||||||
//break;
|
|
||||||
}
|
}
|
||||||
hitCounter++;
|
hitCounter++;
|
||||||
|
|
||||||
@@ -150,8 +140,6 @@ public class ShipWarfareGUI extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (userAttacks == true) {
|
if (userAttacks == true) {
|
||||||
@@ -163,16 +151,10 @@ public class ShipWarfareGUI extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (numOfLittyShips <= 0) {
|
|
||||||
exitValue = 1;
|
|
||||||
//break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (logic.getNumOfLittyShips() <= 0) {
|
if (logic.getNumOfLittyShips() <= 0) {
|
||||||
exitValue = 1;
|
exitValue = 1;
|
||||||
//break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getGuns() > 0) {
|
if (getGuns() > 0) {
|
||||||
@@ -186,8 +168,6 @@ public class ShipWarfareGUI extends Player {
|
|||||||
if (userAttacks == true) {
|
if (userAttacks == true) {
|
||||||
if (howMuchRun > 0) {
|
if (howMuchRun > 0) {
|
||||||
runAwayOrLeft.setText(String.format("Cowards! %d ships ran away %s! ", howMuchRun, getName()));
|
runAwayOrLeft.setText(String.format("Cowards! %d ships ran away %s! ", howMuchRun, getName()));
|
||||||
|
|
||||||
//runAwayOrLeft.setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -206,7 +186,7 @@ public class ShipWarfareGUI extends Player {
|
|||||||
gunFrustration = true;
|
gunFrustration = true;
|
||||||
} else {
|
} else {
|
||||||
if (logic.getNumOfLittyShips() > 0) {
|
if (logic.getNumOfLittyShips() > 0) {
|
||||||
int HPTaken = randomValue.nextInt(10);
|
int HPTaken = randomValue.nextInt(10) + 1;
|
||||||
setHP(getHP() - (HPTaken));
|
setHP(getHP() - (HPTaken));
|
||||||
|
|
||||||
|
|
||||||
@@ -233,6 +213,7 @@ public class ShipWarfareGUI extends Player {
|
|||||||
if (exitValue == 1) {
|
if (exitValue == 1) {
|
||||||
wipe();
|
wipe();
|
||||||
calculateLoot = logic.calculateLoot();
|
calculateLoot = logic.calculateLoot();
|
||||||
|
setPlayer(logic.getPlayer());
|
||||||
report.setText(String.format("Our firm has earned $%,d in loot! ", calculateLoot));
|
report.setText(String.format("Our firm has earned $%,d in loot! ", calculateLoot));
|
||||||
continueButton.setVisible(true);
|
continueButton.setVisible(true);
|
||||||
completeWipe();
|
completeWipe();
|
||||||
@@ -545,11 +526,7 @@ public class ShipWarfareGUI extends Player {
|
|||||||
* @param event, once button is clicked, executes graphical information
|
* @param event, once button is clicked, executes graphical information
|
||||||
*/
|
*/
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
report.setVisible(false);
|
wipewithTitle(report);
|
||||||
runAwayOrLeft.setVisible(false);
|
|
||||||
shipsRemaining.setVisible(false);
|
|
||||||
HPLeft.setVisible(false);
|
|
||||||
gunsLeftOrTaken.setVisible(false);
|
|
||||||
fightButton.setVisible(false);
|
fightButton.setVisible(false);
|
||||||
runButton.setVisible(false);
|
runButton.setVisible(false);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class ShipWarfareGUILogic extends Player {
|
|||||||
private int startingLittyShips=0;
|
private int startingLittyShips=0;
|
||||||
|
|
||||||
|
|
||||||
private int counter1;
|
private int counter;
|
||||||
|
|
||||||
public ShipWarfareGUILogic(Player player) {
|
public ShipWarfareGUILogic(Player player) {
|
||||||
Player playerDummy = new Player(player);
|
Player playerDummy = new Player(player);
|
||||||
@@ -31,9 +31,9 @@ public class ShipWarfareGUILogic extends Player {
|
|||||||
* @param numOfLittyShips the number of ships to be used in the peasant fleet attack
|
* @param numOfLittyShips the number of ships to be used in the peasant fleet attack
|
||||||
*/
|
*/
|
||||||
public void setNumOfLittyShips(int numOfLittyShips) {
|
public void setNumOfLittyShips(int numOfLittyShips) {
|
||||||
counter1++;
|
counter++;
|
||||||
this.numOfLittyShips = numOfLittyShips;
|
this.numOfLittyShips = numOfLittyShips;
|
||||||
if (counter1 == 1) {
|
if (counter == 1) {
|
||||||
startingLittyShips = numOfLittyShips;
|
startingLittyShips = numOfLittyShips;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,6 +88,7 @@ public class ShipWarfareGUILogic extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int calculateLoot(){
|
public int calculateLoot(){
|
||||||
|
|
||||||
Random randomValue = new Random();
|
Random randomValue = new Random();
|
||||||
int calculateLoot;
|
int calculateLoot;
|
||||||
calculateLoot = (startingLittyShips * 100) + randomValue.nextInt(startingLittyShips) * 200;
|
calculateLoot = (startingLittyShips * 100) + randomValue.nextInt(startingLittyShips) * 200;
|
||||||
|
|||||||
Reference in New Issue
Block a user