Skip to content

Commit

Permalink
started working on zone change messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bazola committed Sep 19, 2014
1 parent 061050a commit 2a2489d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.cardshifter.server.outgoing.UseableActionMessage;
import com.cardshifter.server.outgoing.WaitMessage;
import com.cardshifter.server.outgoing.WelcomeMessage;
import com.cardshifter.server.outgoing.ZoneChangeMessage;
import com.cardshifter.server.outgoing.ZoneMessage;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
Expand Down Expand Up @@ -202,7 +203,9 @@ private void processMessageFromServer(Message message) {
this.processUseableActionMessage((UseableActionMessage)message);
} else if (message instanceof UpdateMessage) {
this.processUpdateMessage((UpdateMessage)message);
}
} else if (message instanceof ZoneChangeMessage) {
this.processZoneChangeMessage((ZoneChangeMessage)message);
}
}

private void processNewGameMessage(NewGameMessage message) {
Expand Down Expand Up @@ -321,6 +324,27 @@ private void processUpdateMessageForPlayer(Pane statBox, UpdateMessage message,
this.repaintStatBox(statBox, playerMap);
}

private void processZoneChangeMessage(ZoneChangeMessage message) {
int sourceZoneId = message.getSourceZone();
int destinationZoneId = message.getDestinationZone();
int cardId = message.getEntity();

if (this.zoneViewMap.containsKey(sourceZoneId) && this.zoneViewMap.containsKey(destinationZoneId)) {

if (sourceZoneId == opponentHandId) {

} else if (sourceZoneId == playerHandId) {
ZoneView sourceZone = this.zoneViewMap.get(sourceZoneId);
Pane cardPane = sourceZone.getPane(cardId);

ZoneView destinationZone = this.zoneViewMap.get(destinationZoneId);
destinationZone.addPane(cardId, cardPane);

sourceZone.removePane(cardId);
}
}
}

private void repaintStatBox(Pane statBox, Map<String, Integer> playerMap) {
statBox.getChildren().clear();
for (Map.Entry<String, Integer> entry : playerMap.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public void addPane(int paneId, Pane pane) {
this.rootPane.getChildren().add(pane);
}

public Pane getPane(int paneId) {
return this.zoneMap.get(paneId);
}

public void removePane(int paneId) {
Pane paneToRemove = this.zoneMap.get(paneId);
this.rootPane.getChildren().remove(paneToRemove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

<AnchorPane fx:id="rootPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.cardshifter.client.GameClientController">
<children>

<!-- temporary action box -->
<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" /> -->
Expand All @@ -28,16 +25,6 @@
</children>
</HBox>
<HBox fx:id="opponentHandPane" alignment="CENTER" layoutX="232.0" layoutY="15.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="61.0" prefWidth="564.0" scaleShape="false" spacing="10.0" />

<!-- Battlefields -->
<HBox fx:id="playerBattlefieldPane" layoutX="239.0" layoutY="237.0" prefHeight="98.0" prefWidth="809.0" spacing="10.0">
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#b0d9ff" height="99.0" stroke="BLACK" strokeType="INSIDE" width="810.0" />
</children></HBox>
<HBox fx:id="opponentBattlefieldPane" layoutX="239.0" layoutY="105.0" prefHeight="98.0" prefWidth="809.0" spacing="10.0">
<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">
Expand Down Expand Up @@ -92,6 +79,23 @@
<Font size="20.0" />
</font>
</Label>

<!-- temporary action box -->
<HBox fx:id="actionBox" alignment="CENTER" layoutX="14.0" layoutY="599.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="16.0" prefWidth="1107.0" scaleShape="false" spacing="10" />
<AnchorPane layoutX="239.0" layoutY="211.0" prefHeight="98.0" prefWidth="810.0">
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#b0d9ff" height="99.0" stroke="BLACK" strokeType="INSIDE" width="810.0" />

<!-- Battlefields -->
<HBox fx:id="playerBattlefieldPane" prefHeight="98.0" prefWidth="809.0" spacing="10.0" />
</children>
</AnchorPane>
<AnchorPane layoutX="239.0" layoutY="105.0" prefHeight="98.0" prefWidth="809.0">
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#f59782" height="99.0" stroke="BLACK" strokeType="INSIDE" width="810.0" />
<HBox fx:id="opponentBattlefieldPane" layoutX="1.0" layoutY="1.0" prefHeight="98.0" prefWidth="809.0" spacing="10.0" />
</children>
</AnchorPane>

</children>
</AnchorPane>

0 comments on commit 2a2489d

Please sign in to comment.