Commit 47506859 authored by BVBra_000's avatar BVBra_000

label issues, test on previous versions of eclipse.

parent 17858211
......@@ -7,7 +7,7 @@
<Pane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="749.0" prefWidth="1054.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="BSMain">
<children>
<Pane accessibleRole="COMBO_BOX" layoutY="-14.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="749.0" prefWidth="1054.0">
<Pane fx:id="admiral" accessibleRole="COMBO_BOX" layoutY="-14.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="749.0" prefWidth="1054.0">
<children>
<ChoiceBox fx:id="DPx" layoutX="30.0" layoutY="651.0" prefHeight="28.0" prefWidth="184.0" />
<ChoiceBox fx:id="DPy" layoutX="214.0" layoutY="651.0" prefHeight="28.0" prefWidth="184.0" />
......@@ -15,9 +15,9 @@
<ChoiceBox fx:id="shipSelection" layoutX="30.0" layoutY="679.0" prefHeight="28.0" prefWidth="184.0" />
<Label fx:id="label" alignment="CENTER" contentDisplay="CENTER" layoutX="214.0" layoutY="680.0" prefHeight="28.0" prefWidth="184.0" text="Stage : Preperation" textAlignment="JUSTIFY" wrapText="true" />
<Button fx:id="fire" layoutX="582.0" layoutY="651.0" mnemonicParsing="false" onAction="#fireAction" prefHeight="28.0" prefWidth="184.0" text="*FIRE*" />
<Button fx:id="quit" layoutX="398.0" layoutY="681.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="184.0" text="*Quit*" />
<Button fx:id="battleStage" layoutX="582.0" layoutY="681.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="184.0" text="*Battle Stage*" />
<Label fx:id="admiral" layoutX="30.0" layoutY="634.0" prefHeight="17.0" prefWidth="734.0" text="Admiral Nutsey : &quot;Place your ships Captain!!!&quot;" />
<Button fx:id="quit" layoutX="398.0" layoutY="681.0" mnemonicParsing="false" onAction="#quitAction" prefHeight="25.0" prefWidth="184.0" text="*QUIT*" />
<Button fx:id="battleStage" layoutX="582.0" layoutY="681.0" mnemonicParsing="false" onAction="#stageAction" prefHeight="25.0" prefWidth="184.0" text="*BATTLE STAGE*" />
<Label layoutX="30.0" layoutY="634.0" prefHeight="17.0" prefWidth="734.0" text="Admiral Nutsey : &quot;Place your ships Captain!!!&quot;" />
</children>
</Pane>
</children>
......
......@@ -31,7 +31,8 @@ public class BSMain extends Application{
@FXML private Button quit;
@FXML private Label label;
@FXML private Label admiral;
@FXML
static Label admiral;
static ObservableList<String> numbrz = FXCollections.observableArrayList("0","1","2","3","4","5","6","7","8","9");
static ObservableList<String> ltrz = FXCollections.observableArrayList("A","B","C","D","E","F","G","H","I","J");
......@@ -47,12 +48,15 @@ public class BSMain extends Application{
static ShipClass playerS = new ShipClass();
static ShipClass computerS = new ShipClass();
Boolean stage0= true;
Boolean stage1=false;
@Override
public void start(Stage arg0) throws Exception {
// TODO Auto-generated method stub
Parent root = FXMLLoader.load(getClass().getResource("/BSGUI.fxml"));
//System.out.println(DPx);
......@@ -93,6 +97,7 @@ public class BSMain extends Application{
@FXML
void placeAction(ActionEvent event) {
if (stage0) {
playerS.ShipPlacer(ship, x, y);
......@@ -101,21 +106,18 @@ public class BSMain extends Application{
if (!playerG.MoveValidCheck(playerG, playerS.moves)){
label.setText("Cordinates are taken. not added to grid");
}
else {
admiral.setText("Your in Battle now son, try *FIRE*");
}
}
}
@FXML
void fireAction(ActionEvent event) {
void fireAction(ActionEvent event) {
// disable during placing stage
// enable once all ships are placed
// notify user in changing of stages
// figure out how to do all of the above
Boolean tempStage= false;
if (tempStage) {
if (stage1) {
String HmnMove = x + y;
String CmptrMove = (String) ComputerInput.CoOrdRandomiser().get(0)
......@@ -126,10 +128,24 @@ public class BSMain extends Application{
}
else {
label.setText("Place all ships before firing");
admiral.setText("Place all ships before firing");
}
}
@FXML
void stageAction(ActionEvent event) {
stage0 = false;
stage1 = true;
admiral.setText("Fire on the enemy");
}
@FXML
void quitAction(ActionEvent event) {
//Add save function
System.exit(0);
}
......
......@@ -2,12 +2,29 @@
public class BattleClass {
public static void fire (ShipClass opponent, String Cordinates) {
public static void fire (ShipClass opponent, String Cordinates) {
// loop through shipsHealth array and
// use .contains to see if any ships contain the fired upon coordinates
// then use Grid.sunk() to check if the the entire ship has gone.
for(int i=0; i< opponent.shipsHealth.size(); i++ ) {
for(int j=0; j< opponent.shipsHealth.get(i).size(); j++ ) {
if(opponent.shipsHealth.get(i).contains(Cordinates)) {
BSMain.admiral.setText("Hit on " + Cordinates);
opponent.shipsHealth.get(i).remove(Cordinates);
opponent.SunkCheck(opponent);
}
else {
BSMain.admiral.setText("Miss at " + Cordinates );
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment