Skip to content

Commit

Permalink
added decks to the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
bazola committed Sep 19, 2014
1 parent 87d9ef2 commit 4bb39f5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ public class GameClientController {
@FXML private VBox playerStatBox;
@FXML private HBox opponentHandPane;
@FXML private HBox opponentBattlefieldPane;
@FXML private Pane opponentDeckPane;
@FXML private HBox playerHandPane;
@FXML private HBox playerBattlefieldPane;
@FXML private Pane playerDeckPane;
@FXML private HBox actionBox;

private final ObjectMapper mapper = new ObjectMapper();
Expand All @@ -70,8 +72,10 @@ public class GameClientController {
private int opponentId;
private int opponentHandId;
private int opponentBattlefieldId;
private int opponentDeckId;
private int playerHandId;
private int playerBattlefieldId;
private int playerDeckId;
private final Map<Integer, Pane> idMap = new HashMap<>();
private final Map<String, Integer> playerStatBoxMap = new HashMap<>();
private final Map<String, Integer> opponentStatBoxMap = new HashMap<>();
Expand Down Expand Up @@ -177,6 +181,7 @@ public void createAndSendMessage(Message message) {
System.out.println("Not a valid action");
}

//A new list of actions will be sent back from the server, so it is okay to clear them
this.actionBox.getChildren().clear();
}

Expand Down Expand Up @@ -234,14 +239,17 @@ private void processZoneMessage(ZoneMessage message) {
this.assignZoneIdForZoneMessage(message);
}

//Right now zone messages only come at the start, so these lines don't do anything
Pane targetPane = this.idMap.get(message.getId());
this.processZoneMessageForPane(targetPane, message);
}
private boolean allZonesAssigned() {
return (this.idMap.containsValue(playerBattlefieldPane)
&& this.idMap.containsValue(playerHandPane)
&& this.idMap.containsValue(opponentBattlefieldPane)
&& this.idMap.containsValue(opponentHandPane));
&& this.idMap.containsValue(opponentHandPane)
&& this.idMap.containsValue(playerDeckPane)
&& this.idMap.containsValue(opponentDeckPane));
}
private void assignZoneIdForZoneMessage(ZoneMessage message) {
if (!this.idMap.containsKey(message.getId())) {
Expand All @@ -254,7 +262,7 @@ private void assignZoneIdForZoneMessage(ZoneMessage message) {
this.idMap.put(this.opponentBattlefieldId, opponentBattlefieldPane);
}
} else if (message.getName().equals("Hand")) {
if(message.getOwner() == this.playerId) {
if (message.getOwner() == this.playerId) {
this.playerHandId = message.getId();
this.idMap.put(this.playerHandId, playerHandPane);
} else {
Expand All @@ -264,6 +272,14 @@ private void assignZoneIdForZoneMessage(ZoneMessage message) {

this.renderOpponentHand();
}
} else if (message.getName().equals("Deck")) {
if (message.getOwner() == this.playerId) {
this.playerDeckId = message.getId();
this.idMap.put(this.playerHandId, playerDeckPane);
} else {
this.opponentDeckId = message.getId();
this.idMap.put(this.opponentHandId, opponentDeckPane);
}
}
}
}
Expand Down Expand Up @@ -372,5 +388,11 @@ private void renderOpponentHand() {
com.cardshifter.server.outgoing.ResetAvailableActionsMessage@2d326c35
UpdateMessage [id=44, key=MANA_MAX, value=2]
UpdateMessage [id=44, key=MANA, value=2]
ZoneChangeMessage [entity=9, sourceZone=2, destinationZone=3]
ZoneChangeMessage [entity=48, sourceZone=45, destinationZone=46]
ZoneChangeMessage [entity=49, sourceZone=45, destinationZone=46]
ZoneChangeMessage [entity=50, sourceZone=45, destinationZone=46]
ZoneChangeMessage [entity=51, sourceZone=45, destinationZone=46]
ZoneChangeMessage [entity=52, sourceZone=45, destinationZone=46]
*/

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<children>

<!-- temporary action box -->
<HBox fx:id="actionBox" alignment="CENTER" spacing="10" layoutX="239.0" layoutY="343.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="44.0" prefWidth="810.0" scaleShape="false" />
<HBox fx:id="actionBox" alignment="CENTER" layoutX="239.0" layoutY="343.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="44.0" prefWidth="810.0" scaleShape="false" spacing="10" />

<!-- Buttons -->
<!-- <Button fx:id="button" layoutX="1098.0" layoutY="530.0" onAction="#startGameButtonAction" text="Start Game" /> -->
<Label fx:id="startGameLabel" layoutX="1098.0" layoutY="564.0" minHeight="16" minWidth="69" />
<!-- <Button layoutX="1105.0" layoutY="467.0" mnemonicParsing="false" onAction="#handleTurnButtonAction" text="End Turn" /> -->
<Label fx:id="turnLabel" layoutX="1075.0" layoutY="485.0" text="Turn Number" />
<Label fx:id="turnLabel" layoutX="1034.0" layoutY="556.0" text="Turn Number" />
<!-- <Button fx:id="newGameButton" layoutX="17.0" layoutY="24.0" mnemonicParsing="false" onAction="#newGameButtonAction" text="New Game" /> -->

<!-- Hands -->
Expand All @@ -38,6 +38,18 @@
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#f59782" height="99.0" stroke="BLACK" strokeType="INSIDE" width="810.0" />
</children></HBox>

<!-- Decks -->
<Pane fx:id="opponentDeckPane" layoutX="796.0" layoutY="15.0" prefHeight="61.0" prefWidth="46.0">
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#1aa9cc" height="61.0" stroke="BLACK" strokeType="INSIDE" width="46.0" />
</children>
</Pane>
<Pane fx:id="playerDeckPane" layoutX="1021.0" layoutY="473.0" prefHeight="61.0" prefWidth="46.0">
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#1aa9cc" height="61.0" stroke="BLACK" strokeType="INSIDE" width="46.0" />
</children>
</Pane>

<!-- Legend -->
<Pane layoutX="844.0" layoutY="7.0" prefHeight="98.0" prefWidth="232.0">
Expand Down

0 comments on commit 4bb39f5

Please sign in to comment.