-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'client-server' of github.com:Cardshifter/Cardshifter in…
…to develop
- Loading branch information
Showing
10 changed files
with
585 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
cardshifter-api/src/main/java/com/cardshifter/server/outgoing/EntityRemoveMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.cardshifter.server.outgoing; | ||
|
||
import com.cardshifter.server.messages.Message; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class EntityRemoveMessage extends Message { | ||
|
||
private final int entity; | ||
|
||
@JsonCreator | ||
public EntityRemoveMessage(@JsonProperty("entity") int entity) { | ||
super("entityRemoved"); | ||
this.entity = entity; | ||
} | ||
|
||
public int getEntity() { | ||
return entity; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "EntityRemoveMessage [entity=" + entity + "]"; | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
cardshifter-api/src/main/java/com/cardshifter/server/outgoing/ZoneChangeMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.cardshifter.server.outgoing; | ||
|
||
import com.cardshifter.server.messages.Message; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class ZoneChangeMessage extends Message { | ||
|
||
private final int entity; | ||
private final int sourceZone; | ||
private final int destinationZone; | ||
|
||
@JsonCreator | ||
public ZoneChangeMessage(@JsonProperty("entity") int entity, | ||
@JsonProperty("sourceZone") int sourceZone, @JsonProperty("destinationZone") int destinationZone) { | ||
super("zoneChange"); | ||
this.entity = entity; | ||
this.sourceZone = sourceZone; | ||
this.destinationZone = destinationZone; | ||
} | ||
|
||
public int getEntity() { | ||
return entity; | ||
} | ||
|
||
public int getSourceZone() { | ||
return sourceZone; | ||
} | ||
|
||
public int getDestinationZone() { | ||
return destinationZone; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ZoneChangeMessage [entity=" + entity + ", sourceZone=" | ||
+ sourceZone + ", destinationZone=" + destinationZone + "]"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
cardshifter-fx/src/main/java/com/cardshifter/client/ActionButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
package com.cardshifter.client; | ||
|
||
import com.cardshifter.server.outgoing.UseableActionMessage; | ||
import javafx.scene.Group; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.input.MouseEvent; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.shape.Rectangle; | ||
|
||
public class ActionButton extends Group { | ||
|
||
private final UseableActionMessage message; | ||
private final GameClientController controller; | ||
private final double sizeX; | ||
private final double sizeY; | ||
|
||
public ActionButton(UseableActionMessage message, GameClientController controller, double sizeX, double sizeY) { | ||
this.message = message; | ||
this.controller = controller; | ||
this.sizeX = sizeX; | ||
this.sizeY = sizeY; | ||
this.setUpRectangle(); | ||
this.setUpLabel(); | ||
this.setOnMouseClicked(this::actionButtonClicked); | ||
} | ||
private void setUpRectangle() { | ||
Rectangle actionBack = new Rectangle(0, 0, this.sizeX, this.sizeY); | ||
actionBack.setFill(Color.BLUEVIOLET); | ||
this.getChildren().add(actionBack); | ||
} | ||
private void setUpLabel() { | ||
Label actionLabel = new Label(); | ||
actionLabel.setText(this.message.getAction()); | ||
actionLabel.relocate(this.sizeX/2.5, 0); | ||
this.getChildren().add(actionLabel); | ||
} | ||
|
||
private void actionButtonClicked(MouseEvent event) { | ||
this.controller.createAndSendMessage(this.message); | ||
} | ||
|
||
} |
123 changes: 123 additions & 0 deletions
123
cardshifter-fx/src/main/java/com/cardshifter/client/CardHandDocumentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package com.cardshifter.client; | ||
|
||
import com.cardshifter.server.outgoing.CardInfoMessage; | ||
import java.net.URL; | ||
import java.util.ResourceBundle; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.input.MouseEvent; | ||
import javafx.scene.layout.AnchorPane; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.shape.Rectangle; | ||
|
||
public class CardHandDocumentController implements Initializable { | ||
|
||
@FXML private Label strength; | ||
@FXML private Label health; | ||
@FXML private Label cardId; | ||
@FXML private Label manaCost; | ||
@FXML private Label scrapCost; | ||
@FXML private Label cardType; | ||
@FXML private Label creatureType; | ||
@FXML private Label enchStrength; | ||
@FXML private Label enchHealth; | ||
@FXML private Rectangle background; | ||
@FXML private AnchorPane anchorPane; | ||
|
||
//Initialization | ||
private AnchorPane root; | ||
private final CardInfoMessage card; | ||
public CardHandDocumentController(CardInfoMessage message, GameClientController controller) { | ||
try { | ||
FXMLLoader loader = new FXMLLoader(getClass().getResource("CardHandDocument.fxml")); | ||
loader.setController(this); | ||
root = loader.load(); | ||
} | ||
catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
this.card = message; | ||
this.setCardId(); | ||
this.setCardLabels(); | ||
this.setActionForRootPane(); | ||
} | ||
|
||
private void setActionForRootPane() { | ||
this.anchorPane.setOnMouseClicked(this::actionOnClick); | ||
} | ||
private void actionOnClick(MouseEvent event) { | ||
System.out.println("Action detected on card" + this.cardId.textProperty()); | ||
} | ||
|
||
public AnchorPane getRootPane() { | ||
return this.anchorPane; | ||
} | ||
|
||
public void setRectangleColorActive() { | ||
background.setFill(Color.YELLOW); | ||
} | ||
|
||
private void setCardId() { | ||
int newId = card.getId(); | ||
cardId.setText(String.format("CardId = %d", newId)); | ||
} | ||
|
||
private void setCardLabels() { | ||
for(String key : this.card.getProperties().keySet()) { | ||
if (key.equals("SICKNESS")) { | ||
|
||
} else if (key.equals("MANA_COST")) { | ||
manaCost.setText(String.format("Mana Cost = %d", this.card.getProperties().get(key))); | ||
} else if (key.equals("ATTACK")) { | ||
strength.setText(this.card.getProperties().get(key).toString()); | ||
} else if (key.equals("HEALTH")) { | ||
health.setText(this.card.getProperties().get(key).toString()); | ||
} else if (key.equals("ATTACK_AVAILABLE")) { | ||
|
||
} | ||
} | ||
|
||
/* | ||
List<ECSResourceData> keyList = new ArrayList<>(); | ||
Resources.processResources(card, data -> keyList.add(data)); | ||
for (ECSResourceData string : keyList) { | ||
ECSResource resource = string.getResource(); | ||
int value = string.get(); | ||
if (resource == PhrancisResources.HEALTH) { | ||
health.setText(String.valueOf(string.get())); | ||
} else if (resource == PhrancisResources.ATTACK) { | ||
strength.setText(String.valueOf(string.get())); | ||
} else if (resource == PhrancisResources.MANA_COST) { | ||
manaCost.setText(String.format("Mana Cost = %d", string.get())); | ||
} else if (resource == PhrancisResources.SCRAP_COST) { | ||
scrapCost.setText(String.format("Scrap Cost = %d", value)); | ||
} | ||
// } else if (resource == PhrancisResources.st string.equals("enchStrength")) { | ||
// enchStrength.setText(String.format("Enchantment Strength = %d", card.data.get("enchStrength").toint())); | ||
// } else if (string.equals("enchHealth")) { | ||
// enchHealth.setText(String.format("Enchantment Health = %d", card.data.get("enchHealth").toint())); | ||
// } | ||
} | ||
if (card.hasComponent(CreatureTypeComponent.class)) { | ||
creatureType.setText(card.getComponent(CreatureTypeComponent.class).getCreatureType()); | ||
} | ||
// } else if (string.equals("cardType")) { | ||
// cardType.setText(String.format(card.data.get("cardType").tojstring())); | ||
*/ | ||
} | ||
|
||
//Boilerplate code | ||
@Override | ||
public void initialize(URL url, ResourceBundle rb) { | ||
// TODO | ||
} | ||
|
||
} |
Oops, something went wrong.