I DON'T KNOW WHAT I DID, BUT IT WORKED A LITTLE BIT

This commit is contained in:
2019-04-06 18:09:04 -06:00
parent 256706377d
commit 5d0e349ffb
2 changed files with 11 additions and 9 deletions

View File

@@ -44,8 +44,8 @@ public class ShipWarfareGUI extends Player {
private Label report; private Label report;
private int counter; private int counter;
private int checkIfDone; private int checkIfDone;
private int numOfLittyShips;
private int timeCounter; private int timeCounter;
@@ -157,8 +157,8 @@ 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());
logic.setNumOfLittyShips(numOfLittyShips);
int commenceFire = logic.destroyLittyShipsOrEscape(logic.getNumOfLittyShips()); int commenceFire = logic.destroyLittyShipsOrEscape(numOfLittyShips);
if (commenceFire == 1) { if (commenceFire == 1) {
wipe(); wipe();
report.setText(logic.getReportMessage()); report.setText(logic.getReportMessage());
@@ -231,7 +231,8 @@ public class ShipWarfareGUI extends Player {
ShipWarfareGUILogic logic = new ShipWarfareGUILogic(getPlayer()); ShipWarfareGUILogic logic = new ShipWarfareGUILogic(getPlayer());
logic.setNumOfLittyShips(logic.numOfShips()); numOfLittyShips = logic.numOfShips();
logic.setNumOfLittyShips(numOfLittyShips);
title.setText(String.format("%d ships from Liu Yuen's Fleet are attacking, Would you like to fight or run?", logic.getNumOfLittyShips())); title.setText(String.format("%d ships from Liu Yuen's Fleet are attacking, Would you like to fight or run?", logic.getNumOfLittyShips()));
setPlayer(logic.getPlayer()); setPlayer(logic.getPlayer());
@@ -389,10 +390,11 @@ public class ShipWarfareGUI extends Player {
report.setText("Epic"); report.setText("Epic");
counter++; counter++;
ShipWarfareGUILogic logic = new ShipWarfareGUILogic(getPlayer()); ShipWarfareGUILogic logic = new ShipWarfareGUILogic(getPlayer());
logic.setNumOfLittyShips(numOfLittyShips);
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(logic.getNumOfLittyShips()); checkIfDone = logic.destroyLittyShipsOrEscape(numOfLittyShips);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -460,7 +462,7 @@ public class ShipWarfareGUI extends Player {
*/ */
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
shotsFired.stop(); shotsFired.stop();
if (checkIfDone == 4) { if (!winOrLose(primaryStage)) {
shipsRetaliate(); shipsRetaliate();
} else { } else {
report.setVisible(true); report.setVisible(true);

View File

@@ -37,7 +37,7 @@ public class ShipWarfareGUILogic extends Player {
/** /**
* this.setter method that takes in an integer as an argument * 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
*/ */
@@ -47,7 +47,6 @@ public class ShipWarfareGUILogic extends Player {
if (counter1 == 1) { if (counter1 == 1) {
startingLittyShips = numOfLittyShips; startingLittyShips = numOfLittyShips;
} }
} }
public int getNumOfLittyShips(){ public int getNumOfLittyShips(){
@@ -162,8 +161,9 @@ public class ShipWarfareGUILogic extends Player {
* *
* @return true if the user wins, loses, or flees, it returns false otherwise * @return true if the user wins, loses, or flees, it returns false otherwise
*/ */
public int destroyLittyShipsOrEscape() { public int destroyLittyShipsOrEscape(int tempLittyShips) {
this.numOfLittyShips = tempLittyShips;
int calculateLoot = 0; int calculateLoot = 0;
int chanceOfEnemyRun = 0; int chanceOfEnemyRun = 0;
int hitCounter = 0; int hitCounter = 0;