Mesed with ship and litterally accomplished nothing

This commit is contained in:
KahootChampion
2019-04-06 17:44:11 -06:00
parent 9959de99f6
commit 256706377d
2 changed files with 33 additions and 35 deletions

View File

@@ -158,7 +158,7 @@ public class ShipWarfareGUI extends Player {
public boolean winOrLose(Stage stage) { public boolean winOrLose(Stage stage) {
ShipWarfareGUILogic logic = new ShipWarfareGUILogic(getPlayer()); ShipWarfareGUILogic logic = new ShipWarfareGUILogic(getPlayer());
int commenceFire = logic.destroyLittyShipsOrEscape(); int commenceFire = logic.destroyLittyShipsOrEscape(logic.getNumOfLittyShips());
if (commenceFire == 1) { if (commenceFire == 1) {
wipe(); wipe();
report.setText(logic.getReportMessage()); report.setText(logic.getReportMessage());
@@ -221,7 +221,6 @@ public class ShipWarfareGUI extends Player {
HBox usAgainstEnemyDivisor = new HBox(); HBox usAgainstEnemyDivisor = new HBox();
Circle cannon = new Circle(); Circle cannon = new Circle();
cannon.setLayoutX(beginningX); cannon.setLayoutX(beginningX);
cannon.setLayoutY(beginningY); cannon.setLayoutY(beginningY);
@@ -393,7 +392,7 @@ public class ShipWarfareGUI extends Player {
if (logic.runFromShips() == false) { if (logic.runFromShips() == false) {
report.setText(("Couldn't run away")); report.setText(("Couldn't run away"));
try { try {
checkIfDone = logic.destroyLittyShipsOrEscape(); checkIfDone = logic.destroyLittyShipsOrEscape(logic.getNumOfLittyShips());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -404,7 +403,7 @@ public class ShipWarfareGUI extends Player {
gunsLeftOrTaken.setVisible(true); gunsLeftOrTaken.setVisible(true);
} else { } else {
gunsLeftOrTaken.setText("AYYYY");
} }
} else { } else {

View File

@@ -32,12 +32,12 @@ public class ShipWarfareGUILogic extends Player {
public ShipWarfareGUILogic(Player player) { public ShipWarfareGUILogic(Player player) {
Player playerDummy = new Player(player); Player playerDummy = new Player(player);
setPlayer(playerDummy); this.setPlayer(playerDummy);
} }
/** /**
* setter method that takes in an integer as an argument * this.setter method that takes in an integer as an argument
* *
* @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
*/ */
@@ -170,7 +170,7 @@ public class ShipWarfareGUILogic extends Player {
int missCounter = 0; int missCounter = 0;
boolean gunFrustration = false; boolean gunFrustration = false;
setRunAwayOrLeftMessage("No Ships ran away"); this.setRunAwayOrLeftMessage("No Ships ran away");
Random randomValue = new Random(); Random randomValue = new Random();
@@ -203,10 +203,10 @@ public class ShipWarfareGUILogic extends Player {
} }
} }
if (userAttacks == true) { if (userAttacks == true) {
setReportMessage(String.format("Report: Ships hit: %d, Shots missed: %d", hitCounter, missCounter)); this.setReportMessage(String.format("Report: Ships hit: %d, Shots missed: %d", hitCounter, missCounter));
} }
} else { } else {
setReportMessage(("We don't have any guns!!!")); this.setReportMessage(("We don't have any guns!!!"));
} }
@@ -221,31 +221,31 @@ public class ShipWarfareGUILogic extends Player {
if (howMuchRun != 0 && howMuchRun < numOfLittyShips) { if (howMuchRun != 0 && howMuchRun < numOfLittyShips) {
setNumOfLittyShips(numOfLittyShips - howMuchRun); this.setNumOfLittyShips(numOfLittyShips - howMuchRun);
if (userAttacks == true) { if (userAttacks == true) {
if (howMuchRun > 0) { if (howMuchRun > 0) {
setRunAwayOrLeftMessage(String.format("Cowards! %d ships ran away %s! ", howMuchRun, getName())); this.setRunAwayOrLeftMessage(String.format("Cowards! %d ships ran away %s! ", howMuchRun, getName()));
} }
} else { } else {
setReportMessage((String.format("Escaped %d of them %s!", howMuchRun, getName()))); this.setReportMessage((String.format("Escaped %d of them %s!", howMuchRun, getName())));
} }
} }
} }
} }
setShipsRemainingMessage(String.format("%d ships remaining and they look angry!", numOfLittyShips)); this.setShipsRemainingMessage(String.format("%d ships remaining and they look angry!", numOfLittyShips));
//Computer volley //Computer volley
int takeGunChance = randomValue.nextInt(4) + 1; int takeGunChance = randomValue.nextInt(4) + 1;
if (takeGunChance == 1 && getGuns() > 0) { if (takeGunChance == 1 && getGuns() > 0) {
setGuns(getGuns() - 1); this.setGuns(getGuns() - 1);
gunFrustration = true; gunFrustration = true;
} else { } else {
if (numOfLittyShips > 0) { if (numOfLittyShips > 0) {
int HPTaken = randomValue.nextInt(10); int HPTaken = randomValue.nextInt(10);
setHP(getHP() - (HPTaken)); this.setHP(getHP() - (HPTaken));
} }
@@ -255,14 +255,14 @@ public class ShipWarfareGUILogic extends Player {
//break; //break;
} }
if (gunFrustration == true) { if (gunFrustration == true) {
setGunsLeftOrTakenMessage(String.format("Dang it! We only have %d guns left", getGuns())); this.setGunsLeftOrTakenMessage(String.format("Dang it! We only have %d guns left", getGuns()));
//playerShoots(getGuns() + 1); //playerShoots(getGuns() + 1);
} else { } else {
setGunsLeftOrTakenMessage(String.format("We still have %d guns left", getGuns())); this.setGunsLeftOrTakenMessage(String.format("We still have %d guns left", getGuns()));
} }
setHPLeftMessage(String.format("EEK, our current ship status is %d%% ", getHP())); this.setHPLeftMessage(String.format("EEK, our current ship status is %d%% ", getHP()));
if (userAttacks == false) { if (userAttacks == false) {
userAttacks = true; userAttacks = true;
@@ -271,20 +271,19 @@ public class ShipWarfareGUILogic extends Player {
if (exitValue == 1) { if (exitValue == 1) {
setAvenue(1); setAvenue(1);
//calculateLoot = (startingLittyShips * 100) + randomValue.nextInt(startingLittyShips) * 200; calculateLoot = (startingLittyShips * 100) + randomValue.nextInt(startingLittyShips) * 200;
calculateLoot = 100; this.setMoney(getMoney() + calculateLoot);
setMoney(getMoney() + calculateLoot); this.setReportMessage(String.format("Our firm has earned $%,d in loot! ", calculateLoot));
setReportMessage(String.format("Our firm has earned $%,d in loot! ", calculateLoot));
return 1; return 1;
} else if (exitValue == 2) { } else if (exitValue == 2) {
setAvenue(2); this.setAvenue(2);
return 2; return 2;
} else if (exitValue == 3) { } else if (exitValue == 3) {
setAvenue(3); this.setAvenue(3);
setReportMessage(String.format("We made it out at %d%% ship status!", getHP())); this.setReportMessage(String.format("We made it out at %d%% ship status!", getHP()));
return 3; return 3;
} }
else{ else{
@@ -297,14 +296,14 @@ public class ShipWarfareGUILogic extends Player {
if (destroyLittyShipsOrEscape() == 1) { if (destroyLittyShipsOrEscape() == 1) {
wipe(); wipe();
calculateLoot = (startingLittyShips * 100) + randomValue.nextInt(startingLittyShips) * 200; calculateLoot = (startingLittyShips * 100) + randomValue.nextInt(startingLittyShips) * 200;
setMoney(getMoney() + calculateLoot); this.setMoney(getMoney() + calculateLoot);
reportMessage = String.format("Our firm has earned $%,d in loot! ", calculateLoot); reportMessage = String.format("Our firm has earned $%,d in loot! ", calculateLoot);
continueButton.setVisible(true); continueButton.this.setVisible(true);
completeWipe(); completeWipe();
fightButton.setVisible(false); fightButton.this.setVisible(false);
runButton.setVisible(false); runButton.this.setVisible(false);
continueButton.setDefaultButton(true); continueButton.this.setDefaultButton(true);
return true; return true;
@@ -315,13 +314,13 @@ public class ShipWarfareGUILogic extends Player {
return true; return true;
} else if (destroyLittyShipsOrEscape() == 3) { } else if (destroyLittyShipsOrEscape() == 3) {
report.setText(String.format("We made it out at %d%% ship status!", getHP())); report.this.setText(String.format("We made it out at %d%% ship status!", getHP()));
continueButton.setVisible(true); continueButton.this.setVisible(true);
completeWipe(); completeWipe();
fightButton.setVisible(false); fightButton.this.setVisible(false);
runButton.setVisible(false); runButton.this.setVisible(false);
continueButton.setDefaultButton(true); continueButton.this.setDefaultButton(true);
return true; return true;
} }
*/ */