Commit a1df916a authored by Darth Vernon's avatar Darth Vernon

general improvements

parent d2bd455e
...@@ -10,17 +10,18 @@ ...@@ -10,17 +10,18 @@
<children> <children>
<Pane accessibleRole="COMBO_BOX" layoutY="-6.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="761.0" prefWidth="1054.0"> <Pane accessibleRole="COMBO_BOX" layoutY="-6.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="761.0" prefWidth="1054.0">
<children> <children>
<AnchorPane layoutX="91.0" prefHeight="593.0" prefWidth="940.0"> <AnchorPane layoutY="6.0" prefHeight="749.0" prefWidth="1054.0">
<children> <children>
<ChoiceBox fx:id="DPx" layoutX="50.0" layoutY="495.0" prefHeight="28.0" prefWidth="184.0" /> <ChoiceBox fx:id="DPx" layoutY="575.0" prefHeight="28.0" prefWidth="184.0" />
<ChoiceBox fx:id="shipSelection" layoutX="50.0" layoutY="523.0" prefHeight="28.0" prefWidth="184.0" /> <ChoiceBox fx:id="shipSelection" layoutY="603.0" prefHeight="28.0" prefWidth="184.0" />
<Label fx:id="admiral" layoutX="50.0" layoutY="478.0" prefHeight="17.0" prefWidth="734.0" text="Admiral Nutsey : &quot;Place your ships Captain!!!&quot;" /> <Label fx:id="admiral" layoutX="8.0" layoutY="558.0" prefHeight="17.0" prefWidth="734.0" text="Admiral Nutsey : &quot;Place your ships Captain!!!&quot;" />
<ChoiceBox fx:id="DPy" layoutX="234.0" layoutY="495.0" prefHeight="28.0" prefWidth="184.0" /> <ChoiceBox fx:id="DPy" layoutX="184.0" layoutY="575.0" prefHeight="28.0" prefWidth="184.0" />
<Label fx:id="error" alignment="CENTER" contentDisplay="CENTER" layoutX="234.0" layoutY="523.0" prefHeight="28.0" prefWidth="184.0" text="Stage : Preperation" textAlignment="JUSTIFY" wrapText="true" /> <Label fx:id="error" alignment="CENTER" contentDisplay="CENTER" layoutX="552.0" layoutY="604.0" prefHeight="28.0" prefWidth="184.0" text="Stage : Preperation" textAlignment="JUSTIFY" wrapText="true" />
<Button fx:id="place" layoutX="417.0" layoutY="495.0" mnemonicParsing="false" onAction="#placeAction" prefHeight="28.0" prefWidth="184.0" text="*PLACE A SHIP*" textAlignment="CENTER" /> <Button fx:id="place" layoutX="368.0" layoutY="575.0" mnemonicParsing="false" onAction="#placeAction" prefHeight="28.0" prefWidth="184.0" text="*PLACE A SHIP*" textAlignment="CENTER" />
<Button fx:id="fire" layoutX="601.0" layoutY="495.0" mnemonicParsing="false" onAction="#fireAction" prefHeight="28.0" prefWidth="184.0" text="*FIRE*" /> <Button fx:id="fire" layoutX="552.0" layoutY="575.0" mnemonicParsing="false" onAction="#fireAction" prefHeight="28.0" prefWidth="184.0" text="*FIRE*" />
<Button fx:id="quit" layoutX="417.0" layoutY="519.0" mnemonicParsing="false" onAction="#quitAction" prefHeight="25.0" prefWidth="184.0" text="*QUIT*" /> <Button fx:id="quit" layoutX="184.0" layoutY="605.0" mnemonicParsing="false" onAction="#quitAction" prefHeight="25.0" prefWidth="184.0" text="*QUIT*" />
<Button fx:id="battleStage" layoutX="601.0" layoutY="519.0" mnemonicParsing="false" onAction="#stageAction" prefHeight="25.0" prefWidth="184.0" text="*BATTLE STAGE*" /> <Button fx:id="battleStage" layoutX="368.0" layoutY="605.0" mnemonicParsing="false" onAction="#stageAction" prefHeight="25.0" prefWidth="184.0" text="*BATTLE STAGE*" />
<Label fx:id="status" layoutX="8.0" layoutY="631.0" prefHeight="25.0" prefWidth="455.0" text="Status : NO HITS" />
</children> </children>
</AnchorPane> </AnchorPane>
</children> </children>
......
...@@ -32,6 +32,7 @@ public class BSMain extends Application{ ...@@ -32,6 +32,7 @@ public class BSMain extends Application{
@FXML public Label error; @FXML public Label error;
@FXML public Label admiral; @FXML public Label admiral;
@FXML public Label status;
ObservableList<String> numbrz = FXCollections.observableArrayList("0","1","2","3","4","5","6","7","8","9"); ObservableList<String> numbrz = FXCollections.observableArrayList("0","1","2","3","4","5","6","7","8","9");
ObservableList<String> ltrz = FXCollections.observableArrayList("A","B","C","D","E","F","G","H","I","J"); ObservableList<String> ltrz = FXCollections.observableArrayList("A","B","C","D","E","F","G","H","I","J");
...@@ -44,7 +45,7 @@ public class BSMain extends Application{ ...@@ -44,7 +45,7 @@ public class BSMain extends Application{
static Grid playerG = new Grid(); static Grid playerG = new Grid();
static Grid computerG = new Grid(); static Grid computerG = new Grid();
ShipClass playerS = new ShipClass(); static ShipClass playerS = new ShipClass();
static ShipClass computerS = new ShipClass(); static ShipClass computerS = new ShipClass();
static BattleClass playerB = new BattleClass(); static BattleClass playerB = new BattleClass();
static BattleClass computerB = new BattleClass(); static BattleClass computerB = new BattleClass();
...@@ -106,12 +107,12 @@ public class BSMain extends Application{ ...@@ -106,12 +107,12 @@ public class BSMain extends Application{
admiral.setText("Admiral Nutsey: Ship placed at " + x + y); admiral.setText("Admiral Nutsey: Ship placed at " + x + y);
if (!playerG.MoveValidCheck(playerG, playerS.moves, playerS, ship)){ if (!playerG.MoveValidCheck(playerG, playerS.moves, playerS, ship)){
admiral.setText("Cordinates are taken. not added to grid"); admiral.setText("Admiral Nutsey: Space occupied");
} }
} }
else if (stage1) { else if (stage1) {
admiral.setText("Your in Battle, try *FIRE*"); admiral.setText("Admiral Nutsey: Your in Battle, try *FIRE*");
} }
} }
...@@ -122,8 +123,16 @@ public class BSMain extends Application{ ...@@ -122,8 +123,16 @@ public class BSMain extends Application{
@FXML @FXML
void fireAction(ActionEvent event) { void fireAction(ActionEvent event) {
if(playerS.allMoves.isEmpty()) {
stage1 = false;
admiral.setText("Admiral Nutsey: You have lost :( ");
}
else if(computerS.allMoves.isEmpty()) {
stage1 = false;
admiral.setText("Admiral Nutsey: You have won!!! ");
}
if (stage1) { else if (stage1) {
String HmnMove = x + y; String HmnMove = x + y;
String CmptrMove = (String) ComputerInput.CoOrdRandomiser().get(0) String CmptrMove = (String) ComputerInput.CoOrdRandomiser().get(0)
...@@ -131,32 +140,20 @@ public class BSMain extends Application{ ...@@ -131,32 +140,20 @@ public class BSMain extends Application{
playerB.fire(computerS, HmnMove); playerB.fire(computerS, HmnMove);
computerB.fire(playerS, CmptrMove); computerB.fire(playerS, CmptrMove);
System.out.println(computerS.allMoves.size() + "Left of Computer ships" + playerS.allMoves.size() + "Left of Player ships"); status.setText("Computer status: " + computerS.allMoves.size() + " Player Status: " + playerS.allMoves.size());
} }
else if (stage0) { else if (stage0) {
admiral.setText("Place all ships before firing"); admiral.setText("Place all ships before firing");
} }
else if(playerS.allMoves.isEmpty()) {
stage1 = false;
admiral.setText("You have lost :( ");
}
else if(computerS.allMoves.isEmpty()) {
stage1 = false;
admiral.setText("You have lost won!!! ");
}
else {
error.setText("The Game has ended, press *QUIT*");
}
} }
@FXML @FXML
void stageAction(ActionEvent event) { void stageAction(ActionEvent event) {
stage0 = false; stage0 = false;
stage1 = true; stage1 = true;
admiral.setText("Fire on the enemy"); admiral.setText("Admiral Nutsey: Fire on the enemy");
} }
@FXML @FXML
......
...@@ -34,7 +34,7 @@ public class ShipClass { ...@@ -34,7 +34,7 @@ public class ShipClass {
public void ShipPlacer (ShipClass plyr ,String shipType, String x, String y) { public void ShipPlacer (ShipClass plyr ,String shipType, String x, String y) {
System.out.println("this one " + plyr.aC.toString() + plyr.dS.toString() + plyr.dS2.toString());
int xIndex = Grid.xCordL.indexOf(x); int xIndex = Grid.xCordL.indexOf(x);
//int yIndex = Grid.yCordL.indexOf(y); //int yIndex = Grid.yCordL.indexOf(y);
......
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