Fixed ShipWarfareGUI and ShipWarfareLogic
This commit is contained in:
@@ -27,7 +27,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
public class ShipWarfareGUI extends Player {
|
public class ShipWarfareGUI extends Player {
|
||||||
|
|
||||||
ShipWarfareGUILogic logic = new ShipWarfareGUILogic(getPlayer());
|
ShipWarfareLogic logic = new ShipWarfareLogic(getPlayer());
|
||||||
|
|
||||||
private ShipWarfareGUI ship;
|
private ShipWarfareGUI ship;
|
||||||
private Circle cannon;
|
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
|
* Sets most of the labels invisible except for the "fight or run" label
|
||||||
*/
|
*/
|
||||||
public void wipe() {
|
public void wipe() {
|
||||||
wipewithTitle(title);
|
wipeWithTitle(title);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void wipewithTitle(Label title) {
|
public void wipeWithTitle(Label title) {
|
||||||
title.setVisible(false);
|
title.setVisible(false);
|
||||||
runAwayOrLeft.setVisible(false);
|
runAwayOrLeft.setVisible(false);
|
||||||
shipsRemaining.setVisible(false);
|
shipsRemaining.setVisible(false);
|
||||||
@@ -210,6 +210,7 @@ public class ShipWarfareGUI extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//The user defeats the enemy fleet
|
||||||
if (exitValue == 1) {
|
if (exitValue == 1) {
|
||||||
wipe();
|
wipe();
|
||||||
calculateLoot = logic.calculateLoot();
|
calculateLoot = logic.calculateLoot();
|
||||||
@@ -221,6 +222,7 @@ public class ShipWarfareGUI extends Player {
|
|||||||
runButton.setVisible(false);
|
runButton.setVisible(false);
|
||||||
continueButton.setDefaultButton(true);
|
continueButton.setDefaultButton(true);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (exitValue == 2) {
|
} else if (exitValue == 2) {
|
||||||
GameEndGUI gameEndGUI = new GameEndGUI(getPlayer());
|
GameEndGUI gameEndGUI = new GameEndGUI(getPlayer());
|
||||||
gameEndGUI.initializeGameEndGUI(stage);
|
gameEndGUI.initializeGameEndGUI(stage);
|
||||||
@@ -244,7 +246,6 @@ public class ShipWarfareGUI extends Player {
|
|||||||
* Player attacks enemy ships in an animation
|
* Player attacks enemy ships in an animation
|
||||||
*/
|
*/
|
||||||
public void playerShoots(int amountOfShots) {
|
public void playerShoots(int amountOfShots) {
|
||||||
userAttacks = true;
|
|
||||||
shotsFired.setFromX(0);
|
shotsFired.setFromX(0);
|
||||||
shotsFired.setFromY(0);
|
shotsFired.setFromY(0);
|
||||||
shotsFired.setToX(endX);
|
shotsFired.setToX(endX);
|
||||||
@@ -477,19 +478,21 @@ public class ShipWarfareGUI extends Player {
|
|||||||
|
|
||||||
//Flee
|
//Flee
|
||||||
runButton.setOnAction(new EventHandler<ActionEvent>() {
|
runButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
/**
|
/**
|
||||||
* Run Button, engages in run logic and graphical interface
|
* Run Button, engages in run logic and graphical interface
|
||||||
* @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) {
|
||||||
|
userAttacks = false;
|
||||||
|
|
||||||
report.setVisible(true);
|
report.setVisible(true);
|
||||||
title.setVisible(true);
|
title.setVisible(true);
|
||||||
shipsRemaining.setVisible(true);
|
shipsRemaining.setVisible(true);
|
||||||
gunsLeftOrTaken.setVisible(true);
|
gunsLeftOrTaken.setVisible(true);
|
||||||
|
|
||||||
title.setText("Ayy captain we will try to run!");
|
title.setText("Ayy captain we will try to run!");
|
||||||
report.setText("Epic");
|
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
if (logic.runFromShips(userAttacks) == false) {
|
if (logic.runFromShips(userAttacks) == false) {
|
||||||
@@ -500,10 +503,10 @@ public class ShipWarfareGUI extends Player {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (winOrLose == true) {
|
if (winOrLose == true) {
|
||||||
report.setVisible(true);
|
report.setVisible(false);
|
||||||
title.setVisible(true);
|
title.setVisible(false);
|
||||||
shipsRemaining.setVisible(true);
|
shipsRemaining.setVisible(false);
|
||||||
gunsLeftOrTaken.setVisible(true);
|
gunsLeftOrTaken.setVisible(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -519,14 +522,15 @@ public class ShipWarfareGUI extends Player {
|
|||||||
|
|
||||||
//Fight
|
//Fight
|
||||||
fightButton.setOnAction(new EventHandler<ActionEvent>() {
|
fightButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
/**
|
/**
|
||||||
* Fight Button, engages in fight logic and graphical interface
|
* Fight Button, engages in fight logic and graphical interface
|
||||||
* @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) {
|
||||||
wipewithTitle(report);
|
userAttacks = true;
|
||||||
|
|
||||||
|
wipeWithTitle(report);
|
||||||
fightButton.setVisible(false);
|
fightButton.setVisible(false);
|
||||||
runButton.setVisible(false);
|
runButton.setVisible(false);
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
private int counter;
|
||||||
|
|
||||||
public ShipWarfareGUILogic(Player player) {
|
public ShipWarfareLogic(Player player) {
|
||||||
Player playerDummy = new Player(player);
|
Player playerDummy = new Player(player);
|
||||||
this.setPlayer(playerDummy);
|
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(){
|
public int calculateLoot(){
|
||||||
|
|
||||||
Random randomValue = new Random();
|
Random randomValue = new Random();
|
||||||
Reference in New Issue
Block a user