Compare commits

..

No commits in common. "26d82839309ac4e64e9f48da995bf87e4a9f377c" and "c3460586314572d611c027a4bf37ea76895bdd3a" have entirely different histories.

10 changed files with 185 additions and 210 deletions

View File

@ -10,16 +10,12 @@ import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture; import com.jme3.texture.Texture;
import pp.monopoly.client.MonopolyApp; import pp.monopoly.client.MonopolyApp;
import pp.monopoly.client.gui.popups.EventCard;
import pp.monopoly.notification.DiceRollEvent;
import pp.monopoly.notification.EventCardEvent;
import pp.monopoly.notification.GameEventListener;
/** /**
* TestWorld zeigt eine einfache Szene mit einem texturierten Quadrat. * TestWorld zeigt eine einfache Szene mit einem texturierten Quadrat.
* Die Kamera wird durch den CameraController gesteuert. * Die Kamera wird durch den CameraController gesteuert.
*/ */
public class TestWorld implements GameEventListener{ public class TestWorld {
private final MonopolyApp app; private final MonopolyApp app;
private CameraController cameraController; // Steuert die Kamera private CameraController cameraController; // Steuert die Kamera
@ -32,7 +28,6 @@ public class TestWorld implements GameEventListener{
*/ */
public TestWorld(MonopolyApp app) { public TestWorld(MonopolyApp app) {
this.app = app; this.app = app;
app.getGameLogic().addListener(this);
} }
/** /**
@ -96,9 +91,4 @@ public class TestWorld implements GameEventListener{
app.getRootNode().attachChild(geom); app.getRootNode().attachChild(geom);
} }
@Override
public void receivedEvent(EventCardEvent event) {
new EventCard(app, event.description()).open();
}
} }

View File

@ -1,12 +1,19 @@
package pp.monopoly.client.gui; package pp.monopoly.client.gui;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.simsilica.lemur.*; import com.simsilica.lemur.Axis;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.HAlignment;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.VAlignment;
import com.simsilica.lemur.component.IconComponent; import com.simsilica.lemur.component.IconComponent;
import com.simsilica.lemur.component.QuadBackgroundComponent; import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.component.SpringGridLayout; import com.simsilica.lemur.component.SpringGridLayout;
import com.simsilica.lemur.style.ElementId; import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog; import pp.dialog.Dialog;
@ -20,6 +27,10 @@ import pp.monopoly.notification.GameEventListener;
import pp.monopoly.notification.Sound; import pp.monopoly.notification.Sound;
import pp.monopoly.notification.UpdatePlayerView; import pp.monopoly.notification.UpdatePlayerView;
/**
* Toolbar Klasse, die am unteren Rand der Szene angezeigt wird.
* Die Buttons bewegen den Würfel auf dem Spielfeld.
*/
public class Toolbar extends Dialog implements GameEventListener{ public class Toolbar extends Dialog implements GameEventListener{
private final MonopolyApp app; private final MonopolyApp app;
@ -29,9 +40,13 @@ public class Toolbar extends Dialog implements GameEventListener {
private Container overviewContainer; private Container overviewContainer;
private Container accountContainer; private Container accountContainer;
private PlayerHandler playerHandler; private PlayerHandler playerHandler;
private volatile boolean animatingDice = false;
private volatile DiceRollEvent latestDiceRollEvent = null;
/**
* Konstruktor für die Toolbar.
*
* @param app Die Hauptanwendung (MonopolyApp)
*/
public Toolbar(MonopolyApp app) { public Toolbar(MonopolyApp app) {
super(app.getDialogManager()); super(app.getDialogManager());
this.app = app; this.app = app;
@ -41,80 +56,110 @@ public class Toolbar extends Dialog implements GameEventListener {
// Erstelle die Toolbar // Erstelle die Toolbar
toolbarContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y), "toolbar"); toolbarContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y), "toolbar");
toolbarContainer.setLocalTranslation(0, 200, 0);
toolbarContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), 200, 0));
// Account- und Übersichtskontainer // Setze die Position am unteren Rand und die Breite
toolbarContainer.setLocalTranslation(
0, // Links bündig
200, // Höhe über dem unteren Rand
0 // Z-Ebene
);
toolbarContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), 200, 0)); // Volle Breite
// Menü-Container: Ein Nested-Container für Kontostand und "Meine Gulag Frei Karten"
accountContainer = toolbarContainer.addChild(new Container()); accountContainer = toolbarContainer.addChild(new Container());
// Menü-Container: Ein Container für Übersicht
overviewContainer = toolbarContainer.addChild(new Container()); overviewContainer = toolbarContainer.addChild(new Container());
receivedEvent(new UpdatePlayerView()); receivedEvent(new UpdatePlayerView());
overviewContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); overviewContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
// Würfelbereich // Menü-Container: Ein Container für Würfel
Container diceContainer = toolbarContainer.addChild(new Container()); Container diceContainer = toolbarContainer.addChild(new Container());
diceContainer.setLayout(new SpringGridLayout(Axis.X, Axis.Y)); diceContainer.setLayout(new SpringGridLayout(Axis.X, Axis.Y));
// Create a horizontal container to align leftContainer and rightContainer side by side
Container horizontalContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y)); Container horizontalContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
horizontalContainer.setPreferredSize(new Vector3f(200, 150, 0)); horizontalContainer.setPreferredSize(new Vector3f(200, 150, 0)); // Adjust size as needed
// Linker Würfel // Create the first container (leftContainer)
Container leftContainer = new Container(); Container leftContainer = new Container();
leftContainer.setPreferredSize(new Vector3f(100, 150, 0)); leftContainer.setPreferredSize(new Vector3f(100, 150, 0)); // Adjust size as needed
imageLabel = new Label(""); imageLabel = new Label("");
IconComponent icon = new IconComponent("Pictures/dice/one.png"); IconComponent icon = new IconComponent("Pictures/dice/one.png"); // Icon mit Textur erstellen
icon.setIconSize(new Vector2f(100, 100)); icon.setIconSize(new Vector2f(100,100)); // Skalierung des Bildes
imageLabel.setIcon(icon); imageLabel.setIcon(icon);
// Rechter Würfel
Container rightContainer = new Container();
rightContainer.setPreferredSize(new Vector3f(100, 150, 0));
imageLabel2 = new Label(""); imageLabel2 = new Label("");
IconComponent icon2 = new IconComponent("Pictures/dice/two.png"); IconComponent icon2 = new IconComponent("Pictures/dice/two.png"); // Icon mit Textur erstellen
icon2.setIconSize(new Vector2f(100, 100)); icon2.setIconSize(new Vector2f(100,100)); // Skalierung des Bildes
imageLabel2.setIcon(icon2); imageLabel2.setIcon(icon2);
// Create the second container (rightContainer)
Container rightContainer = new Container();
rightContainer.setPreferredSize(new Vector3f(100, 150, 0)); // Adjust size as needed
leftContainer.setBackground(null);
rightContainer.setBackground(null);
diceContainer.setBackground(null);
horizontalContainer.setBackground(null);
imageLabel.setTextVAlignment(VAlignment.Center);
imageLabel.setTextHAlignment(HAlignment.Center);
imageLabel2.setTextVAlignment(VAlignment.Center);
imageLabel2.setTextHAlignment(HAlignment.Center);
leftContainer.addChild(imageLabel); leftContainer.addChild(imageLabel);
rightContainer.addChild(imageLabel2); rightContainer.addChild(imageLabel2);
// Add leftContainer and rightContainer to the horizontal container
horizontalContainer.addChild(leftContainer); horizontalContainer.addChild(leftContainer);
horizontalContainer.addChild(rightContainer); horizontalContainer.addChild(rightContainer);
// Add the horizontalContainer to the diceContainer (top section)
diceContainer.addChild(horizontalContainer); diceContainer.addChild(horizontalContainer);
// Würfeln-Button // Add the Würfeln button directly below the horizontalContainer
Button diceButton = new Button("Würfeln"); Button diceButton = new Button("Würfeln");
diceButton.setPreferredSize(new Vector3f(200, 50, 0)); diceButton.setPreferredSize(new Vector3f(200, 50, 0)); // Full width for Würfeln button
diceButton.addClickCommands(s -> ifTopDialog(() -> { diceButton.addClickCommands(s -> ifTopDialog(() -> {
startDiceAnimation();
app.getGameLogic().send(new RollDice()); app.getGameLogic().send(new RollDice());
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
})); }));
diceContainer.addChild(diceButton); diceContainer.addChild(diceButton);
// Menü-Container für weitere Aktionen
// Menü-Container: Ein Nested-Container für Handeln, Grundstücke und Zug beenden
Container menuContainer = toolbarContainer.addChild(new Container()); Container menuContainer = toolbarContainer.addChild(new Container());
menuContainer.addChild(addTradeMenuButton()); menuContainer.addChild(addTradeMenuButton());
menuContainer.addChild(addPropertyMenuButton()); menuContainer.addChild(addPropertyMenuButton());
menuContainer.addChild(addEndTurnButton()); menuContainer.addChild(addEndTurnButton());
menuContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); menuContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
// Füge die Toolbar zur GUI hinzu
app.getGuiNode().attachChild(toolbarContainer); app.getGuiNode().attachChild(toolbarContainer);
} }
private Button addTradeMenuButton() { private Button addTradeMenuButton() {
Button tradeButton = new Button("Handeln"); Button tradebutton = new Button("Handeln");
tradeButton.setPreferredSize(new Vector3f(150, 50, 0)); tradebutton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
tradeButton.addClickCommands(s -> ifTopDialog(() -> { tradebutton.addClickCommands(s -> ifTopDialog( () -> {
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
new ChoosePartner(app).open(); new ChoosePartner(app).open();
})); }));
return tradeButton; return tradebutton;
} }
private Button addPropertyMenuButton() { private Button addPropertyMenuButton() {
Button propertyMenuButton = new Button("Grundstücke"); Button propertyMenuButton = new Button("Grundstücke");
propertyMenuButton.setPreferredSize(new Vector3f(150, 50, 0)); propertyMenuButton.setFontSize(30.0f);
propertyMenuButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> { propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
new BuildingAdminMenu(app).open(); new BuildingAdminMenu(app).open();
@ -124,7 +169,7 @@ public class Toolbar extends Dialog implements GameEventListener {
private Button addEndTurnButton() { private Button addEndTurnButton() {
Button endTurnButton = new Button("Zug beenden"); Button endTurnButton = new Button("Zug beenden");
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0)); endTurnButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
endTurnButton.addClickCommands(s -> ifTopDialog(() -> { endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON); app.getGameLogic().playSound(Sound.BUTTON);
app.getGameLogic().send(new EndTurn()); app.getGameLogic().send(new EndTurn());
@ -132,123 +177,6 @@ public class Toolbar extends Dialog implements GameEventListener {
return endTurnButton; return endTurnButton;
} }
private void startDiceAnimation() {
animatingDice = true;
// Starte die Animation und speichere die Startzeit
long startTime = System.currentTimeMillis();
Thread diceAnimation = new Thread(() -> {
int[] currentFace = {1};
try {
while (System.currentTimeMillis() - startTime < 2500) { // Animation läuft für 4 Sekunden
currentFace[0] = (currentFace[0] % 6) + 1;
String rotatingImage1 = diceToString(currentFace[0]);
String rotatingImage2 = diceToString((currentFace[0] % 6) + 1);
IconComponent newIcon1 = new IconComponent(rotatingImage1);
newIcon1.setIconSize(new Vector2f(100, 100));
app.enqueue(() -> imageLabel.setIcon(newIcon1));
IconComponent newIcon2 = new IconComponent(rotatingImage2);
newIcon2.setIconSize(new Vector2f(100, 100));
app.enqueue(() -> imageLabel2.setIcon(newIcon2));
// Warte 100 ms, bevor die Bilder wechseln
Thread.sleep(100);
}
// Animation beenden
animatingDice = false;
// Zeige das finale Ergebnis
if (latestDiceRollEvent != null) {
showFinalDiceResult(latestDiceRollEvent);
}
} catch (InterruptedException e) {
System.err.println("Würfelanimation unterbrochen: " + e.getMessage());
}
});
diceAnimation.start();
}
private void showFinalDiceResult(DiceRollEvent event) {
int diceRoll1 = event.a();
int diceRoll2 = event.b();
String finalImage1 = diceToString(diceRoll1);
String finalImage2 = diceToString(diceRoll2);
IconComponent finalIcon1 = new IconComponent(finalImage1);
finalIcon1.setIconSize(new Vector2f(100, 100));
app.enqueue(() -> imageLabel.setIcon(finalIcon1));
IconComponent finalIcon2 = new IconComponent(finalImage2);
finalIcon2.setIconSize(new Vector2f(100, 100));
app.enqueue(() -> imageLabel2.setIcon(finalIcon2));
app.getGameLogic().playSound(Sound.BUTTON);
}
@Override
public void receivedEvent(DiceRollEvent event) {
latestDiceRollEvent = event; // Speichere das Event
}
@Override
public void receivedEvent(UpdatePlayerView event) {
playerHandler = app.getGameLogic().getPlayerHandler();
System.err.println("Update Player View");
// Clear existing accountContainer and overviewContainer content
accountContainer.clearChildren();
overviewContainer.clearChildren();
accountContainer.addChild(new Label("Kontostand", new ElementId("label-Bold")));
accountContainer.addChild(new Label(
playerHandler.getPlayerById(app.getId()).getAccountBalance() + " EUR",
new ElementId("label-Text")
));
accountContainer.addChild(new Label("Gulag Karten", new ElementId("label-Bold")));
accountContainer.addChild(new Label(
playerHandler.getPlayerById(app.getId()).getNumJailCard() + "",
new ElementId("label-Text")
));
accountContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
overviewContainer.addChild(new Label("Übersicht", new ElementId("label-Bold")));
for (Player player : playerHandler.getPlayers()) {
if (player.getId() != app.getId()) {
overviewContainer.addChild(new Label(
player.getName() + ": " + player.getAccountBalance() + " EUR",
new ElementId("label-Text")
));
}
}
overviewContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
}
private String diceToString(int i) {
switch (i) {
case 1:
return "Pictures/dice/one.png";
case 2:
return "Pictures/dice/two.png";
case 3:
return "Pictures/dice/three.png";
case 4:
return "Pictures/dice/four.png";
case 5:
return "Pictures/dice/five.png";
case 6:
return "Pictures/dice/six.png";
default:
throw new IllegalArgumentException("Invalid dice number: " + i);
}
}
@Override @Override
public void close() { public void close() {
app.getGuiNode().detachChild(toolbarContainer); app.getGuiNode().detachChild(toolbarContainer);
@ -259,4 +187,79 @@ public class Toolbar extends Dialog implements GameEventListener {
public void escape() { public void escape() {
new SettingsMenu(app).open(); new SettingsMenu(app).open();
} }
@Override
public void receivedEvent(DiceRollEvent event) {
updateDiceImages(event.a(), event.b());
}
@Override
public void receivedEvent(UpdatePlayerView event) {
// Clear existing accountContainer and overviewContainer content
accountContainer.clearChildren();
overviewContainer.clearChildren();
// Update accountContainer
accountContainer.addChild(new Label("Kontostand", new ElementId("label-Bold")));
accountContainer.addChild(new Label(
playerHandler.getPlayerById(app.getId()).getAccountBalance() + " EUR",
new ElementId("label-Text")
));
accountContainer.addChild(new Label("Gulag Karten", new ElementId("label-Bold")));
accountContainer.addChild(new Label(
playerHandler.getPlayerById(app.getId()).getNumJailCard() + "",
new ElementId("label-Text")
));
accountContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
// Update overviewContainer
overviewContainer.addChild(new Label("Übersicht", new ElementId("label-Bold")));
for (Player player : playerHandler.getPlayers()) {
if (player.getId() != app.getId()) { // Skip the current player
overviewContainer.addChild(new Label(
player.getName() + ": " + player.getAccountBalance() + " EUR",
new ElementId("label-Text")
));
}
}
overviewContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
}
private void updateDiceImages(int a, int b) {
//TODO dice toll animation
IconComponent icon1 = new IconComponent(diceToString(a));
IconComponent icon2 = new IconComponent(diceToString(b));
icon1.setIconSize(new Vector2f(100, 100));
icon2.setIconSize(new Vector2f(100, 100));
imageLabel.setIcon(icon1);
imageLabel2.setIcon(icon2);
}
private String diceToString(int i) {
switch (i) {
case 1:
return "Pictures/dice/one.png";
case 2:
return "Pictures/dice/two.png";
case 3:
return "Pictures/dice/three.png";
case 4:
return "Pictures/dice/four.png";
case 5:
return "Pictures/dice/five.png";
case 6:
return "Pictures/dice/six.png";
default:
throw new IllegalArgumentException("Invalid dice number: " + i);
}
}
} }

View File

@ -14,6 +14,8 @@ import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog; import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp; import pp.monopoly.client.MonopolyApp;
import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.client.gui.SettingsMenu;
import pp.monopoly.model.card.Card; // TODO für den Import der Queue notwendig
import pp.monopoly.model.card.DeckHelper;
/** /**
* SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann. * SettingsMenu ist ein Overlay-Menü, das durch ESC aufgerufen werden kann.
*/ */
@ -22,13 +24,14 @@ public class EventCard extends Dialog {
private final Geometry overlayBackground; private final Geometry overlayBackground;
private final Container eventCardContainer; private final Container eventCardContainer;
private final Container backgroundContainer; private final Container backgroundContainer;
private final String description;
public EventCard(MonopolyApp app, String description) { public EventCard(MonopolyApp app) {
super(app.getDialogManager()); super(app.getDialogManager());
this.app = app; this.app = app;
this.description = description;
//Generate the corresponfing field
Card card = new DeckHelper().drawCard(); // TODO nimmt die Karten gerade unabhängig aus dem DeckHelper
// Halbtransparentes Overlay hinzufügen // Halbtransparentes Overlay hinzufügen
overlayBackground = createOverlayBackground(); overlayBackground = createOverlayBackground();
@ -53,7 +56,7 @@ public class EventCard extends Dialog {
// Text, der auf der Karte steht // Text, der auf der Karte steht
// Die Preise werden dynamisch dem BoardManager entnommen // Die Preise werden dynamisch dem BoardManager entnommen
Container propertyValuesContainer = eventCardContainer.addChild(new Container()); Container propertyValuesContainer = eventCardContainer.addChild(new Container());
propertyValuesContainer.addChild(new Label(description, new ElementId("label-Text"))); propertyValuesContainer.addChild(new Label(card.getDescription(), new ElementId("label-Text")));
propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f))); propertyValuesContainer.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f)));
propertyValuesContainer.setPreferredSize(new Vector3f(300,200,10)); propertyValuesContainer.setPreferredSize(new Vector3f(300,200,10));
@ -111,6 +114,6 @@ public class EventCard extends Dialog {
@Override @Override
public void escape() { public void escape() {
close(); new SettingsMenu(app).open();
} }
} }

View File

@ -26,14 +26,12 @@ import pp.monopoly.model.IntPoint;
import pp.monopoly.model.fields.BoardManager; import pp.monopoly.model.fields.BoardManager;
import pp.monopoly.notification.ClientStateEvent; import pp.monopoly.notification.ClientStateEvent;
import pp.monopoly.notification.DiceRollEvent; import pp.monopoly.notification.DiceRollEvent;
import pp.monopoly.notification.EventCardEvent;
import pp.monopoly.notification.GameEvent; import pp.monopoly.notification.GameEvent;
import pp.monopoly.notification.GameEventBroker; import pp.monopoly.notification.GameEventBroker;
import pp.monopoly.notification.GameEventListener; import pp.monopoly.notification.GameEventListener;
import pp.monopoly.notification.InfoTextEvent; import pp.monopoly.notification.InfoTextEvent;
import pp.monopoly.notification.Sound; import pp.monopoly.notification.Sound;
import pp.monopoly.notification.SoundEvent; import pp.monopoly.notification.SoundEvent;
import pp.monopoly.notification.UpdatePlayerView;
/** /**
* Controls the client-side game logic for Monopoly. * Controls the client-side game logic for Monopoly.
@ -227,8 +225,9 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
*/ */
@Override @Override
public void received(EventDrawCard msg) { public void received(EventDrawCard msg) {
// Kartenlogik
playSound(Sound.EVENT_CARD); playSound(Sound.EVENT_CARD);
notifyListeners(new EventCardEvent(msg.getCardDescription()));
} }
/** /**
@ -283,8 +282,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
*/ */
@Override @Override
public void received(PlayerStatusUpdate msg) { public void received(PlayerStatusUpdate msg) {
playerHandler = msg.getPlayerHandler();
notifyListeners(new UpdatePlayerView());
} }
/** /**

View File

@ -7,15 +7,12 @@
package pp.monopoly.game.server; package pp.monopoly.game.server;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializable;
import pp.monopoly.message.server.DiceResult; import pp.monopoly.message.server.DiceResult;
import pp.monopoly.message.server.EventDrawCard;
import pp.monopoly.message.server.PlayerStatusUpdate;
import pp.monopoly.model.FieldVisitor; import pp.monopoly.model.FieldVisitor;
import pp.monopoly.model.Figure; import pp.monopoly.model.Figure;
import pp.monopoly.model.card.Card; import pp.monopoly.model.card.Card;
@ -39,7 +36,7 @@ public class Player implements FieldVisitor<Void>{
private String name; private String name;
private int accountBalance = 15000; private int accountBalance = 15000;
private Figure figure; private Figure figure;
private List<PropertyField> properties = new ArrayList<>(); private List<PropertyField> properties;
private int getOutOfJailCard; private int getOutOfJailCard;
private int fieldID; private int fieldID;
private DiceResult rollResult; private DiceResult rollResult;
@ -322,9 +319,7 @@ public class Player implements FieldVisitor<Void>{
@Override @Override
public Void visit(EventField field) { public Void visit(EventField field) {
Card c = getHandler().getLogic().getDeckHelper().drawCard(); Card c = getHandler().getLogic().getDeckHelper().drawCard();
getHandler().getLogic().getDeckHelper().visit(c, this); //Logic getHandler().getLogic().getDeckHelper().visit(c, this);
getHandler().getLogic().send(this, new EventDrawCard(c.getDescription())); // Card notification
getHandler().getLogic().send(this, new PlayerStatusUpdate(getHandler())); //update view
return null; return null;
} }
@ -413,10 +408,6 @@ public class Player implements FieldVisitor<Void>{
return state.rollDice(); return state.rollDice();
} }
private void visitEvent() {
getHandler().getLogic().getBoardManager().getFieldAtIndex(36).accept(this);
}
/** /**
* A interface representing the PlayerStates * A interface representing the PlayerStates
*/ */
@ -528,7 +519,7 @@ public class Player implements FieldVisitor<Void>{
@Override @Override
public DiceResult rollDice() { public DiceResult rollDice() {
return null; throw new UnsupportedOperationException("not allowed");
} }
@Override @Override

View File

@ -2,24 +2,36 @@ package pp.monopoly.message.server;
import com.jme3.network.serializing.Serializable; import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.PlayerHandler; import pp.monopoly.game.server.PlayerColor;
@Serializable @Serializable
public class PlayerStatusUpdate extends ServerMessage{ public class PlayerStatusUpdate extends ServerMessage{
private PlayerHandler playerHandler; private String playerName;
private String status;
private PlayerColor color;
/** /**
* Default constructor for serialization purposes. * Default constructor for serialization purposes.
*/ */
private PlayerStatusUpdate() { /* empty */ } private PlayerStatusUpdate() { /* empty */ }
public PlayerStatusUpdate(PlayerHandler playerHandler) { public PlayerStatusUpdate(String playerName, String status, PlayerColor color) {
this.playerHandler = playerHandler; this.playerName = playerName;
this.status = status;
this.color = color;
} }
public PlayerHandler getPlayerHandler() { public String getPlayerName() {
return playerHandler; return playerName;
}
public String getStatus() {
return status;
}
public PlayerColor getColor() {
return color;
} }
@Override @Override

View File

@ -48,8 +48,6 @@ public class DeckHelper{
cards.add(new Card("Du hast eine Party veranstaltet und dick Gewinn gemacht. Ziehe ein: 1500 EUR", "party-gewinn")); cards.add(new Card("Du hast eine Party veranstaltet und dick Gewinn gemacht. Ziehe ein: 1500 EUR", "party-gewinn"));
cards.add(new Card("Zur falschen Zeit am falschen Ort. Du musst einen Bergmarsch planen und setzt eine Runde aus.", "bergmarsch")); cards.add(new Card("Zur falschen Zeit am falschen Ort. Du musst einen Bergmarsch planen und setzt eine Runde aus.", "bergmarsch"));
cards.add(new Card("Dein Jodel eines Eispenis mit Unterhodenbeleuchtung geht viral. Ziehe ein: 1000 EUR", "jodel-eispenis")); cards.add(new Card("Dein Jodel eines Eispenis mit Unterhodenbeleuchtung geht viral. Ziehe ein: 1000 EUR", "jodel-eispenis"));
shuffle();
} }
public void visit(Card card, Player player) { public void visit(Card card, Player player) {
@ -205,7 +203,7 @@ public class DeckHelper{
} }
private void namensschildTruppenkueche(Player player) { private void namensschildTruppenkueche(Player player) {
//TODO 10 existiert nicht mehr //TODO
} }
private void spendierhosenUnibar(Player player) { private void spendierhosenUnibar(Player player) {

View File

@ -1,10 +0,0 @@
package pp.monopoly.notification;
public record EventCardEvent(String description) implements GameEvent{
@Override
public void notifyListener(GameEventListener listener) {
listener.receivedEvent(this);
}
}

View File

@ -59,11 +59,4 @@ public interface GameEventListener {
* @param event the received event * @param event the received event
*/ */
default void receivedEvent(UpdatePlayerView event) { /*Do nothing */} default void receivedEvent(UpdatePlayerView event) { /*Do nothing */}
/**
* Indicates that an event card has been drawn
*
* @param event the received event
*/
default void receivedEvent(EventCardEvent event) { /*Do nothing */}
} }

View File

@ -38,10 +38,8 @@ import pp.monopoly.message.client.TradeOffer;
import pp.monopoly.message.client.TradeResponse; import pp.monopoly.message.client.TradeResponse;
import pp.monopoly.message.client.ViewAssetsRequest; import pp.monopoly.message.client.ViewAssetsRequest;
import pp.monopoly.message.server.DiceResult; import pp.monopoly.message.server.DiceResult;
import pp.monopoly.message.server.EventDrawCard;
import pp.monopoly.message.server.GameStart; import pp.monopoly.message.server.GameStart;
import pp.monopoly.message.server.NextPlayerTurn; import pp.monopoly.message.server.NextPlayerTurn;
import pp.monopoly.message.server.PlayerStatusUpdate;
import pp.monopoly.message.server.ServerMessage; import pp.monopoly.message.server.ServerMessage;
import pp.monopoly.model.Figure; import pp.monopoly.model.Figure;
import pp.monopoly.model.IntPoint; import pp.monopoly.model.IntPoint;
@ -134,8 +132,6 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
Serializer.registerClass(Figure.class); Serializer.registerClass(Figure.class);
Serializer.registerClass(PlayerHandler.class); Serializer.registerClass(PlayerHandler.class);
Serializer.registerClass(DiceResult.class); Serializer.registerClass(DiceResult.class);
Serializer.registerClass(EventDrawCard.class);
Serializer.registerClass(PlayerStatusUpdate.class);
} }
private void registerListeners() { private void registerListeners() {