From 4db5b6e318f93548e48a129e2799514f3c96773e Mon Sep 17 00:00:00 2001
From: KahootChampion
Date: Sun, 7 Apr 2019 12:08:05 -0600
Subject: [PATCH] Fixed ShipWarfareGUI and ShipWarfareLogic
---
src/ShipWarfareGUI.java | 26 +++++++++++--------
...areGUILogic.java => ShipWarfareLogic.java} | 8 ++++--
2 files changed, 21 insertions(+), 13 deletions(-)
rename src/{ShipWarfareGUILogic.java => ShipWarfareLogic.java} (92%)
diff --git a/src/ShipWarfareGUI.java b/src/ShipWarfareGUI.java
index 4b8063c..78763ce 100644
--- a/src/ShipWarfareGUI.java
+++ b/src/ShipWarfareGUI.java
@@ -27,7 +27,7 @@ import java.util.Random;
public class ShipWarfareGUI extends Player {
- ShipWarfareGUILogic logic = new ShipWarfareGUILogic(getPlayer());
+ ShipWarfareLogic logic = new ShipWarfareLogic(getPlayer());
private ShipWarfareGUI ship;
private Circle cannon;
@@ -76,12 +76,12 @@ public class ShipWarfareGUI extends Player {
* Sets most of the labels invisible except for the "fight or run" label
*/
public void wipe() {
- wipewithTitle(title);
+ wipeWithTitle(title);
}
- public void wipewithTitle(Label title) {
+ public void wipeWithTitle(Label title) {
title.setVisible(false);
runAwayOrLeft.setVisible(false);
shipsRemaining.setVisible(false);
@@ -210,6 +210,7 @@ public class ShipWarfareGUI extends Player {
}
+ //The user defeats the enemy fleet
if (exitValue == 1) {
wipe();
calculateLoot = logic.calculateLoot();
@@ -221,6 +222,7 @@ public class ShipWarfareGUI extends Player {
runButton.setVisible(false);
continueButton.setDefaultButton(true);
return true;
+
} else if (exitValue == 2) {
GameEndGUI gameEndGUI = new GameEndGUI(getPlayer());
gameEndGUI.initializeGameEndGUI(stage);
@@ -244,7 +246,6 @@ public class ShipWarfareGUI extends Player {
* Player attacks enemy ships in an animation
*/
public void playerShoots(int amountOfShots) {
- userAttacks = true;
shotsFired.setFromX(0);
shotsFired.setFromY(0);
shotsFired.setToX(endX);
@@ -477,19 +478,21 @@ public class ShipWarfareGUI extends Player {
//Flee
runButton.setOnAction(new EventHandler() {
+
@Override
/**
* Run Button, engages in run logic and graphical interface
* @param event, once button is clicked, executes graphical information
*/
public void handle(ActionEvent event) {
+ userAttacks = false;
+
report.setVisible(true);
title.setVisible(true);
shipsRemaining.setVisible(true);
gunsLeftOrTaken.setVisible(true);
title.setText("Ayy captain we will try to run!");
- report.setText("Epic");
counter++;
if (logic.runFromShips(userAttacks) == false) {
@@ -500,10 +503,10 @@ public class ShipWarfareGUI extends Player {
e.printStackTrace();
}
if (winOrLose == true) {
- report.setVisible(true);
- title.setVisible(true);
- shipsRemaining.setVisible(true);
- gunsLeftOrTaken.setVisible(true);
+ report.setVisible(false);
+ title.setVisible(false);
+ shipsRemaining.setVisible(false);
+ gunsLeftOrTaken.setVisible(false);
}
} else {
@@ -519,14 +522,15 @@ public class ShipWarfareGUI extends Player {
//Fight
fightButton.setOnAction(new EventHandler() {
-
@Override
/**
* Fight Button, engages in fight logic and graphical interface
* @param event, once button is clicked, executes graphical information
*/
public void handle(ActionEvent event) {
- wipewithTitle(report);
+ userAttacks = true;
+
+ wipeWithTitle(report);
fightButton.setVisible(false);
runButton.setVisible(false);
diff --git a/src/ShipWarfareGUILogic.java b/src/ShipWarfareLogic.java
similarity index 92%
rename from src/ShipWarfareGUILogic.java
rename to src/ShipWarfareLogic.java
index 011806b..7fa2059 100644
--- a/src/ShipWarfareGUILogic.java
+++ b/src/ShipWarfareLogic.java
@@ -9,7 +9,7 @@ import java.util.Random;
*/
-public class ShipWarfareGUILogic extends Player {
+public class ShipWarfareLogic extends Player {
@@ -19,7 +19,7 @@ public class ShipWarfareGUILogic extends Player {
private int counter;
- public ShipWarfareGUILogic(Player player) {
+ public ShipWarfareLogic(Player player) {
Player playerDummy = new Player(player);
this.setPlayer(playerDummy);
}
@@ -87,6 +87,10 @@ public class ShipWarfareGUILogic extends Player {
}
+ /**
+ * Calculates the loot for defeating a fleet
+ * @return the loot for defeating the fleet
+ */
public int calculateLoot(){
Random randomValue = new Random();