mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-04-17 12:40:59 +02:00
Compare commits
No commits in common. "5f4c6be7b8df94f43f35fe0a9b1e962f05c1d78c" and "551786bf3075c311de0cc588850c420f0f0c54eb" have entirely different histories.
5f4c6be7b8
...
551786bf30
@ -8,13 +8,14 @@
|
|||||||
package pp.monopoly.client;
|
package pp.monopoly.client;
|
||||||
|
|
||||||
import java.lang.System.Logger;
|
import java.lang.System.Logger;
|
||||||
|
import java.util.List;
|
||||||
import java.lang.System.Logger.Level;
|
|
||||||
|
|
||||||
import com.jme3.input.controls.ActionListener;
|
import com.jme3.input.controls.ActionListener;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
|
import com.jme3.system.AppSettings;
|
||||||
|
|
||||||
import pp.monopoly.client.gui.TestWorld;
|
import pp.monopoly.client.gui.TestWorld;
|
||||||
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the state responsible for managing the battle interface within the Battleship game.
|
* Represents the state responsible for managing the battle interface within the Battleship game.
|
||||||
@ -23,6 +24,8 @@ import pp.monopoly.client.gui.TestWorld;
|
|||||||
*/
|
*/
|
||||||
public class GameAppState extends MonopolyAppState {
|
public class GameAppState extends MonopolyAppState {
|
||||||
private static final Logger LOGGER = System.getLogger(MonopolyAppState.class.getName());
|
private static final Logger LOGGER = System.getLogger(MonopolyAppState.class.getName());
|
||||||
|
private static final float DEPTH = 0f;
|
||||||
|
private static final float GAP = 20f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A listener for handling click events in the battle interface.
|
* A listener for handling click events in the battle interface.
|
||||||
@ -46,9 +49,9 @@ public class GameAppState extends MonopolyAppState {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void enableState() {
|
protected void enableState() {
|
||||||
LOGGER.log(Level.DEBUG, "Enabling game state");
|
|
||||||
battleNode.detachAllChildren();
|
battleNode.detachAllChildren();
|
||||||
initializeGuiComponents();
|
initializeGuiComponents();
|
||||||
|
layoutGuiComponents();
|
||||||
addGuiComponents();
|
addGuiComponents();
|
||||||
getApp().getGuiNode().attachChild(battleNode);
|
getApp().getGuiNode().attachChild(battleNode);
|
||||||
}
|
}
|
||||||
@ -82,6 +85,16 @@ public class GameAppState extends MonopolyAppState {
|
|||||||
private void addGuiComponents() {
|
private void addGuiComponents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lays out the GUI components within the window, positioning them appropriately.
|
||||||
|
* The opponent's map view is positioned based on the window's dimensions and a specified gap.
|
||||||
|
*/
|
||||||
|
private void layoutGuiComponents() {
|
||||||
|
final AppSettings s = getApp().getContext().getSettings();
|
||||||
|
final float windowWidth = s.getWidth();
|
||||||
|
final float windowHeight = s.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles click events in the battle interface. If the event indicates a click (not a release),
|
* Handles click events in the battle interface. If the event indicates a click (not a release),
|
||||||
* it translates the cursor position to the model's coordinate system and triggers the game logic
|
* it translates the cursor position to the model's coordinate system and triggers the game logic
|
||||||
@ -94,6 +107,7 @@ public class GameAppState extends MonopolyAppState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float tpf) {
|
public void update(float tpf) {
|
||||||
|
// testWorld.update(tpf);
|
||||||
super.update(tpf);
|
super.update(tpf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ class GameBoardSynchronizer extends BoardSynchronizer {
|
|||||||
private static final String FIGURE = "figure"; //NON-NLS
|
private static final String FIGURE = "figure"; //NON-NLS
|
||||||
|
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
|
private final ParticleEffectFactory particleFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a {@code GameBoardSynchronizer} object with the specified application, root node, and ship map.
|
* Constructs a {@code GameBoardSynchronizer} object with the specified application, root node, and ship map.
|
||||||
@ -48,6 +49,7 @@ class GameBoardSynchronizer extends BoardSynchronizer {
|
|||||||
public GameBoardSynchronizer(MonopolyApp app, Node root, Board board) {
|
public GameBoardSynchronizer(MonopolyApp app, Node root, Board board) {
|
||||||
super(board, root);
|
super(board, root);
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
this.particleFactory = new ParticleEffectFactory(app);
|
||||||
addExisting();
|
addExisting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package pp.monopoly.client.gui;
|
||||||
|
|
||||||
|
import com.jme3.effect.ParticleMesh.Type;
|
||||||
|
|
||||||
|
import pp.monopoly.client.MonopolyApp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory class responsible for creating particle effects used in the game.
|
||||||
|
* This centralizes the creation of various types of particle emitters.
|
||||||
|
*/
|
||||||
|
public class ParticleEffectFactory {
|
||||||
|
private static final int COUNT_FACTOR = 1;
|
||||||
|
private static final float COUNT_FACTOR_F = 1f;
|
||||||
|
private static final boolean POINT_SPRITE = true;
|
||||||
|
private static final Type EMITTER_TYPE = POINT_SPRITE ? Type.Point : Type.Triangle;
|
||||||
|
|
||||||
|
private final MonopolyApp app;
|
||||||
|
|
||||||
|
ParticleEffectFactory(MonopolyApp app) {
|
||||||
|
this.app = app;
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@ import pp.monopoly.model.fields.GateField;
|
|||||||
import pp.monopoly.model.fields.PropertyField;
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
|
import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -96,12 +96,16 @@ public class Toolbar extends Dialog implements GameEventListener {
|
|||||||
*/
|
*/
|
||||||
private Button endTurnButton;
|
private Button endTurnButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag indicating if dice animation is ongoing.
|
||||||
|
*/
|
||||||
|
private volatile boolean animatingDice = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the most recent dice roll event.
|
* Stores the most recent dice roll event.
|
||||||
*/
|
*/
|
||||||
private DiceRollEvent latestDiceRollEvent = null;
|
private volatile DiceRollEvent latestDiceRollEvent = null;
|
||||||
|
|
||||||
/**Indicates if the bankrupt PopUp has already been shown */
|
|
||||||
private boolean bankruptPopUp = false;
|
private boolean bankruptPopUp = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,12 +305,18 @@ public class Toolbar extends Dialog implements GameEventListener {
|
|||||||
return endTurnButton;
|
return endTurnButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private QuadBackgroundComponent createBackground() {
|
||||||
|
return new QuadBackgroundComponent(new ColorRGBA(0.4657f, 0.4735f, 0.4892f, 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
private void startDiceAnimation() {
|
private void startDiceAnimation() {
|
||||||
|
animatingDice = true;
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
animateDice(startTime);
|
animateDice(startTime);
|
||||||
|
animatingDice = false;
|
||||||
if (latestDiceRollEvent != null) {
|
if (latestDiceRollEvent != null) {
|
||||||
showFinalDiceResult(latestDiceRollEvent);
|
showFinalDiceResult(latestDiceRollEvent);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,168 @@
|
|||||||
|
package pp.monopoly.client.gui;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.jme3.font.BitmapText;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.scene.Geometry;
|
||||||
|
import com.simsilica.lemur.Axis;
|
||||||
|
import com.simsilica.lemur.Button;
|
||||||
|
import com.simsilica.lemur.Container;
|
||||||
|
import com.simsilica.lemur.component.SpringGridLayout;
|
||||||
|
|
||||||
|
import pp.monopoly.client.MonopolyApp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toolbar Klasse, die am unteren Rand der Szene angezeigt wird.
|
||||||
|
* Die Buttons bewegen den Würfel auf dem Spielfeld.
|
||||||
|
*/
|
||||||
|
public class Toolbar2 {
|
||||||
|
|
||||||
|
private final MonopolyApp app;
|
||||||
|
private final Container toolbarContainer;
|
||||||
|
private final Geometry cube; // Referenz auf den Würfel
|
||||||
|
private final BitmapText positionText; // Anzeige für die aktuelle Position
|
||||||
|
private final float boardLimit = 0.95f; // Grenzen des Bretts
|
||||||
|
private final float stepSize = 0.18f; // Schrittgröße pro Bewegung
|
||||||
|
private int currentPosition = 0; // Aktuelle Position auf dem Spielfeld
|
||||||
|
private final int positionsPerSide = 10; // Anzahl der Positionen pro Seite
|
||||||
|
private final Random random = new Random(); // Zufallsgenerator für den Würfelwurf
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Konstruktor für die Toolbar.
|
||||||
|
*
|
||||||
|
* @param app Die Hauptanwendung (MonopolyApp)
|
||||||
|
* @param cube Der Würfel, der bewegt werden soll
|
||||||
|
*/
|
||||||
|
public Toolbar2(MonopolyApp app, Geometry cube) {
|
||||||
|
this.app = app;
|
||||||
|
this.cube = cube;
|
||||||
|
|
||||||
|
// Erstelle die Toolbar
|
||||||
|
toolbarContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
||||||
|
|
||||||
|
// Setze die Position am unteren Rand und die Breite
|
||||||
|
toolbarContainer.setLocalTranslation(
|
||||||
|
0, // Links bündig
|
||||||
|
100, // Höhe über dem unteren Rand
|
||||||
|
0 // Z-Ebene
|
||||||
|
);
|
||||||
|
toolbarContainer.setPreferredSize(new Vector3f(app.getCamera().getWidth(), 100, 0)); // Volle Breite
|
||||||
|
|
||||||
|
// Füge Buttons zur Toolbar hinzu
|
||||||
|
initializeButtons();
|
||||||
|
|
||||||
|
// Füge die Toolbar zur GUI hinzu
|
||||||
|
app.getGuiNode().attachChild(toolbarContainer);
|
||||||
|
|
||||||
|
// Erstelle die Position-Anzeige
|
||||||
|
positionText = createPositionDisplay();
|
||||||
|
updatePositionDisplay(); // Initialisiere die Anzeige mit der Startposition
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialisiert die Buttons in der Toolbar.
|
||||||
|
*/
|
||||||
|
private void initializeButtons() {
|
||||||
|
addButton("Vorwärts", 1); // Bewegung nach vorne
|
||||||
|
addButton("Rückwärts", -1); // Bewegung nach hinten
|
||||||
|
addDiceRollButton(); // Würfel-Button
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fügt einen Button mit einer Bewegung hinzu.
|
||||||
|
*
|
||||||
|
* @param label Der Text des Buttons
|
||||||
|
* @param step Schrittweite (+1 für vorwärts, -1 für rückwärts)
|
||||||
|
*/
|
||||||
|
private void addButton(String label, int step) {
|
||||||
|
Button button = new Button(label);
|
||||||
|
button.setPreferredSize(new Vector3f(150, 50, 0)); // Größe der Buttons
|
||||||
|
button.addClickCommands(source -> moveCube(step));
|
||||||
|
toolbarContainer.addChild(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fügt den Würfel-Button hinzu, der die Figur entsprechend der gewürfelten Zahl bewegt.
|
||||||
|
*/
|
||||||
|
private void addDiceRollButton() {
|
||||||
|
Button diceButton = new Button("Würfeln");
|
||||||
|
diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons
|
||||||
|
diceButton.addClickCommands(source -> rollDice());
|
||||||
|
toolbarContainer.addChild(diceButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simuliert einen Würfelwurf und bewegt die Figur entsprechend.
|
||||||
|
*/
|
||||||
|
private void rollDice() {
|
||||||
|
int diceRoll = random.nextInt(6) + 1; // Zahl zwischen 1 und 6
|
||||||
|
System.out.println("Gewürfelt: " + diceRoll);
|
||||||
|
moveCube(diceRoll); // Bewege die Figur um die gewürfelte Zahl
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bewegt den Würfel basierend auf der aktuellen Position auf dem Brett.
|
||||||
|
*
|
||||||
|
* @param step Schrittweite (+1 für vorwärts, -1 für rückwärts oder andere Werte)
|
||||||
|
*/
|
||||||
|
private void moveCube(int step) {
|
||||||
|
currentPosition = (currentPosition + step + 4 * positionsPerSide) % (4 * positionsPerSide);
|
||||||
|
Vector3f newPosition = calculatePosition(currentPosition);
|
||||||
|
cube.setLocalTranslation(newPosition);
|
||||||
|
updatePositionDisplay(); // Aktualisiere die Positionsanzeige
|
||||||
|
System.out.println("Würfelposition: " + newPosition + " (Feld-ID: " + currentPosition + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Berechnet die neue Position des Würfels basierend auf der aktuellen Brettseite und Position.
|
||||||
|
*
|
||||||
|
* @param position Aktuelle Position auf dem Spielfeld
|
||||||
|
* @return Die berechnete Position als Vector3f
|
||||||
|
*/
|
||||||
|
private Vector3f calculatePosition(int position) {
|
||||||
|
int side = position / positionsPerSide; // Seite des Bretts (0 = unten, 1 = rechts, 2 = oben, 3 = links)
|
||||||
|
int offset = position % positionsPerSide; // Position auf der aktuellen Seite
|
||||||
|
|
||||||
|
switch (side) {
|
||||||
|
case 0: // Unten (positive x-Achse)
|
||||||
|
return new Vector3f(-boardLimit + offset * stepSize, 0.1f, -boardLimit + 0.05f);
|
||||||
|
case 1: // Rechts (positive z-Achse)
|
||||||
|
return new Vector3f(boardLimit - 0.05f, 0.1f, -boardLimit + offset * stepSize);
|
||||||
|
case 2: // Oben (negative x-Achse)
|
||||||
|
return new Vector3f(boardLimit - offset * stepSize, 0.1f, boardLimit - 0.05f);
|
||||||
|
case 3: // Links (negative z-Achse)
|
||||||
|
return new Vector3f(-boardLimit + 0.05f, 0.1f, boardLimit - offset * stepSize);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Ungültige Position: " + position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erstellt die Anzeige für die aktuelle Position.
|
||||||
|
*
|
||||||
|
* @return Das BitmapText-Objekt für die Anzeige
|
||||||
|
*/
|
||||||
|
private BitmapText createPositionDisplay() {
|
||||||
|
BitmapText text = new BitmapText(app.getAssetManager().loadFont("Interface/Fonts/Default.fnt"), false);
|
||||||
|
text.setSize(20); // Schriftgröße
|
||||||
|
text.setLocalTranslation(10, app.getCamera().getHeight() - 10, 0); // Oben links
|
||||||
|
app.getGuiNode().attachChild(text);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualisiert die Anzeige für die aktuelle Position.
|
||||||
|
*/
|
||||||
|
private void updatePositionDisplay() {
|
||||||
|
positionText.setText("Feld-ID: " + currentPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entfernt die Toolbar.
|
||||||
|
*/
|
||||||
|
public void remove() {
|
||||||
|
app.getGuiNode().detachChild(toolbarContainer);
|
||||||
|
app.getGuiNode().detachChild(positionText);
|
||||||
|
}
|
||||||
|
}
|
@ -12,21 +12,17 @@ import com.simsilica.lemur.component.SpringGridLayout;
|
|||||||
import com.simsilica.lemur.core.VersionedList;
|
import com.simsilica.lemur.core.VersionedList;
|
||||||
import com.simsilica.lemur.core.VersionedReference;
|
import com.simsilica.lemur.core.VersionedReference;
|
||||||
import com.simsilica.lemur.style.ElementId;
|
import com.simsilica.lemur.style.ElementId;
|
||||||
|
import com.simsilica.lemur.text.DocumentModel;
|
||||||
|
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.message.client.TradeOffer;
|
import pp.monopoly.message.client.TradeOffer;
|
||||||
import pp.monopoly.model.TradeHandler;
|
import pp.monopoly.model.TradeHandler;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
|
||||||
import pp.monopoly.model.fields.PropertyField;
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the trade menu dialog in the Monopoly application.
|
* Represents the trade menu dialog in the Monopoly application.
|
||||||
@ -54,6 +50,7 @@ public class TradeMenu extends Dialog {
|
|||||||
private TextField leftCurrencyInput, rightCurrencyInput;
|
private TextField leftCurrencyInput, rightCurrencyInput;
|
||||||
|
|
||||||
private VersionedReference<Set<Integer>> leftBuildingRef, rightBuildingRef;
|
private VersionedReference<Set<Integer>> leftBuildingRef, rightBuildingRef;
|
||||||
|
private VersionedReference<DocumentModel> leftCurrencyRef, rightCurrencyRef;
|
||||||
private VersionedReference<Set<Integer>> leftCardRef, rightCardRef;
|
private VersionedReference<Set<Integer>> leftCardRef, rightCardRef;
|
||||||
|
|
||||||
private Set<String> rightselBuildings = new HashSet<>();
|
private Set<String> rightselBuildings = new HashSet<>();
|
||||||
@ -203,34 +200,12 @@ public class TradeMenu extends Dialog {
|
|||||||
* @return an iterable of property fields
|
* @return an iterable of property fields
|
||||||
*/
|
*/
|
||||||
private Iterable<PropertyField> getPropertyFields(boolean isLeft) {
|
private Iterable<PropertyField> getPropertyFields(boolean isLeft) {
|
||||||
Set<PropertyField> building = app.getGameLogic()
|
return app.getGameLogic()
|
||||||
.getBoardManager()
|
.getBoardManager()
|
||||||
.getPropertyFields(app.getGameLogic()
|
.getPropertyFields(app.getGameLogic()
|
||||||
.getPlayerHandler()
|
.getPlayerHandler()
|
||||||
.getPlayerById(isLeft ? tradeHandler.getSender().getId() : tradeHandler.getReceiver().getId())
|
.getPlayerById(isLeft ? tradeHandler.getSender().getId() : tradeHandler.getReceiver().getId())
|
||||||
.getProperties())
|
.getProperties());
|
||||||
.stream()
|
|
||||||
.filter(p -> p instanceof BuildingProperty)
|
|
||||||
.map(p -> (BuildingProperty) p)
|
|
||||||
.filter(p -> p.getHouses() == 0)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
Set<PropertyField> rest = app.getGameLogic()
|
|
||||||
.getBoardManager()
|
|
||||||
.getPropertyFields(app.getGameLogic()
|
|
||||||
.getPlayerHandler()
|
|
||||||
.getPlayerById(isLeft ? tradeHandler.getSender().getId() : tradeHandler.getReceiver().getId())
|
|
||||||
.getProperties())
|
|
||||||
.stream()
|
|
||||||
.filter(p -> !(p instanceof BuildingProperty))
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
|
|
||||||
List<PropertyField> combinedProperties = new ArrayList<>();
|
|
||||||
combinedProperties.addAll(building);
|
|
||||||
combinedProperties.addAll(rest);
|
|
||||||
combinedProperties = combinedProperties.stream().sorted(Comparator.comparingInt(PropertyField::getId)).collect(Collectors.toList());
|
|
||||||
return combinedProperties;
|
|
||||||
}
|
}
|
||||||
/** Creates a text field for currency input. */
|
/** Creates a text field for currency input. */
|
||||||
private TextField createCurrencyInput() {
|
private TextField createCurrencyInput() {
|
||||||
@ -337,9 +312,11 @@ public class TradeMenu extends Dialog {
|
|||||||
private void initializeReferences() {
|
private void initializeReferences() {
|
||||||
leftBuildingRef = leftBuildingSelector.getSelectionModel().createReference();
|
leftBuildingRef = leftBuildingSelector.getSelectionModel().createReference();
|
||||||
leftCardRef = leftSpecialCardSelector.getSelectionModel().createReference();
|
leftCardRef = leftSpecialCardSelector.getSelectionModel().createReference();
|
||||||
|
leftCurrencyRef = leftCurrencyInput.getDocumentModel().createReference();
|
||||||
|
|
||||||
rightBuildingRef = rightBuildingSelector.getSelectionModel().createReference();
|
rightBuildingRef = rightBuildingSelector.getSelectionModel().createReference();
|
||||||
rightCardRef = rightSpecialCardSelector.getSelectionModel().createReference();
|
rightCardRef = rightSpecialCardSelector.getSelectionModel().createReference();
|
||||||
|
rightCurrencyRef = rightCurrencyInput.getDocumentModel().createReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +11,7 @@ import pp.monopoly.client.MonopolyApp;
|
|||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
import pp.monopoly.client.gui.TradeMenu;
|
import pp.monopoly.client.gui.TradeMenu;
|
||||||
import pp.monopoly.message.client.TradeResponse;
|
import pp.monopoly.message.client.TradeResponse;
|
||||||
|
import pp.monopoly.message.server.TradeReply;
|
||||||
import pp.monopoly.model.TradeHandler;
|
import pp.monopoly.model.TradeHandler;
|
||||||
import pp.monopoly.model.fields.PropertyField;
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
@ -31,6 +31,8 @@ public class EventCardPopup extends Dialog {
|
|||||||
/** Background container providing a border for the popup. */
|
/** Background container providing a border for the popup. */
|
||||||
private final Container backgroundContainer;
|
private final Container backgroundContainer;
|
||||||
|
|
||||||
|
/** The description of the event card. */
|
||||||
|
private final String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the EventCardPopup to display the details of a triggered event card.
|
* Constructs the EventCardPopup to display the details of a triggered event card.
|
||||||
@ -41,6 +43,7 @@ public class EventCardPopup extends Dialog {
|
|||||||
public EventCardPopup(MonopolyApp app, String description) {
|
public EventCardPopup(MonopolyApp app, String description) {
|
||||||
super(app.getDialogManager());
|
super(app.getDialogManager());
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
this.description = description;
|
||||||
|
|
||||||
// Halbtransparentes Overlay hinzufügen
|
// Halbtransparentes Overlay hinzufügen
|
||||||
overlayBackground = createOverlayBackground();
|
overlayBackground = createOverlayBackground();
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package pp.monopoly.client.gui.popups;
|
package pp.monopoly.client.gui.popups;
|
||||||
|
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.material.RenderState.BlendMode;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.scene.Geometry;
|
||||||
|
import com.jme3.scene.shape.Quad;
|
||||||
import com.simsilica.lemur.Button;
|
import com.simsilica.lemur.Button;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.Label;
|
import com.simsilica.lemur.Label;
|
||||||
@ -105,6 +109,22 @@ public class GateFieldCard extends Dialog {
|
|||||||
app.getGuiNode().attachChild(gateFieldContainer);
|
app.getGuiNode().attachChild(gateFieldContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a semi-transparent background overlay for the popup.
|
||||||
|
*
|
||||||
|
* @return the geometry of the overlay
|
||||||
|
*/
|
||||||
|
private Geometry createOverlayBackground() {
|
||||||
|
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
|
||||||
|
Geometry overlay = new Geometry("Overlay", quad);
|
||||||
|
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
material.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); // Halbtransparent
|
||||||
|
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
|
||||||
|
overlay.setMaterial(material);
|
||||||
|
overlay.setLocalTranslation(0, 0, 0);
|
||||||
|
return overlay;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the popup and removes its associated GUI elements.
|
* Closes the popup and removes its associated GUI elements.
|
||||||
*/
|
*/
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
package pp.monopoly.client.gui.popups;
|
package pp.monopoly.client.gui.popups;
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.simsilica.lemur.Axis;
|
import com.simsilica.lemur.Axis;
|
||||||
import com.simsilica.lemur.Button;
|
import com.simsilica.lemur.Button;
|
||||||
|
import com.simsilica.lemur.Checkbox;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.Label;
|
import com.simsilica.lemur.Label;
|
||||||
|
import com.simsilica.lemur.ListBox;
|
||||||
import com.simsilica.lemur.Selector;
|
import com.simsilica.lemur.Selector;
|
||||||
import com.simsilica.lemur.TextField;
|
import com.simsilica.lemur.TextField;
|
||||||
|
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.core.VersionedList;
|
import com.simsilica.lemur.core.VersionedList;
|
||||||
|
@ -21,6 +21,7 @@ import pp.monopoly.message.client.AlterProperty;
|
|||||||
import pp.monopoly.model.fields.BoardManager;
|
import pp.monopoly.model.fields.BoardManager;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
import pp.monopoly.model.fields.PropertyField;
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
import pp.monopoly.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -14,6 +14,7 @@ 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.notification.Sound;
|
import pp.monopoly.notification.Sound;
|
||||||
|
import static pp.monopoly.Resources.lookup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TimeOut is a warning popup triggered when the connection to the server is interrupted.
|
* TimeOut is a warning popup triggered when the connection to the server is interrupted.
|
||||||
|
@ -246,7 +246,7 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
*/
|
*/
|
||||||
public void sellProperty(PropertyField property) {
|
public void sellProperty(PropertyField property) {
|
||||||
if (property.getOwner() == this) {
|
if (property.getOwner() == this) {
|
||||||
properties.remove(property.getId());
|
properties.remove(property);
|
||||||
property.setOwner(null);
|
property.setOwner(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ import java.lang.System.Logger;
|
|||||||
import java.lang.System.Logger.Level;
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collector;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import pp.monopoly.MonopolyConfig;
|
import pp.monopoly.MonopolyConfig;
|
||||||
@ -210,6 +212,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
String truc = name.length() > 10 ? name.substring(0, 15) : name;
|
String truc = name.length() > 10 ? name.substring(0, 15) : name;
|
||||||
player.setName(truc);
|
player.setName(truc);
|
||||||
player.setFigure(new Figure(1, -10, -10, Rotation.LEFT, msg.getFigure()));
|
player.setFigure(new Figure(1, -10, -10, Rotation.LEFT, msg.getFigure()));
|
||||||
|
//TODO add figure to the map
|
||||||
playerHandler.setPlayerReady(player, true);
|
playerHandler.setPlayerReady(player, true);
|
||||||
LOGGER.log(Level.DEBUG, "Player {0} is ready", player.getName());
|
LOGGER.log(Level.DEBUG, "Player {0} is ready", player.getName());
|
||||||
}
|
}
|
||||||
@ -424,14 +427,15 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(NotificationAnswer msg, int from) {
|
public void received(NotificationAnswer msg, int from) {
|
||||||
if(msg.getKeyword().equals("UseJailCard")) {
|
if(msg.getA().equals("UseJailCard")) {
|
||||||
playerHandler.getPlayerById(from).useJailCard();
|
playerHandler.getPlayerById(from).useJailCard();
|
||||||
} else if (msg.getKeyword().equals("PayJail")) {
|
} else if (msg.getA().equals("PayJail")) {
|
||||||
playerHandler.getPlayerById(from).payBail();
|
playerHandler.getPlayerById(from).payBail();
|
||||||
} else if(msg.getKeyword().equals("hack")) {
|
} else if(msg.getA().equals("hack")) {
|
||||||
for (BuildingProperty bp : boardManager.getPropertyFields( List.of(1,3)).stream().filter(p -> p instanceof BuildingProperty).map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
// for (BuildingProperty bp : boardManager.getPropertyFields( List.of(1,3)).stream().filter(p -> p instanceof BuildingProperty).map(p -> (BuildingProperty) p).collect(Collectors.toList())) {
|
||||||
bp.build();
|
// bp.setOwner(playerHandler.getPlayerById(0));
|
||||||
}
|
// playerHandler.getPlayerById(0).addProperty(bp.getId());
|
||||||
|
// }
|
||||||
for(PropertyField field : boardManager.getBoard().stream().filter(p -> p instanceof PropertyField).map(p -> (PropertyField) p).collect(Collectors.toList())) {
|
for(PropertyField field : boardManager.getBoard().stream().filter(p -> p instanceof PropertyField).map(p -> (PropertyField) p).collect(Collectors.toList())) {
|
||||||
field.setOwner(playerHandler.getPlayerById(0));
|
field.setOwner(playerHandler.getPlayerById(0));
|
||||||
playerHandler.getPlayerById(0).addProperty(field.getId());
|
playerHandler.getPlayerById(0).addProperty(field.getId());
|
||||||
|
@ -5,16 +5,16 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
@Serializable
|
@Serializable
|
||||||
public class NotificationAnswer extends ClientMessage{
|
public class NotificationAnswer extends ClientMessage{
|
||||||
|
|
||||||
private String keyword;
|
private String A;
|
||||||
|
|
||||||
private NotificationAnswer() {}
|
private NotificationAnswer() {}
|
||||||
|
|
||||||
public NotificationAnswer(String keyword) {
|
public NotificationAnswer(String A) {
|
||||||
this.keyword = keyword;
|
this.A = A;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKeyword() {
|
public String getA() {
|
||||||
return keyword;
|
return A;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,4 +11,11 @@ public class BuyPropertyRequest extends ServerMessage{
|
|||||||
public void accept(ServerInterpreter interpreter) {
|
public void accept(ServerInterpreter interpreter) {
|
||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,12 @@ public class DiceResult extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDoublets() {
|
public boolean isDoublets() {
|
||||||
return a == b;
|
return a == b;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,12 @@ public class EventDrawCard extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
public String getCardDescription() {
|
public String getCardDescription() {
|
||||||
return cardDescription;
|
return cardDescription;
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,10 @@ public class GameOver extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,4 +27,10 @@ public class GameStart extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,10 @@ public class JailEvent extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,9 @@ public class NextPlayerTurn extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,4 +41,10 @@ public class NotificationMessage extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,4 +27,10 @@ public class PlayerStatusUpdate extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,4 +28,12 @@ public abstract class ServerMessage extends AbstractMessage {
|
|||||||
* @param interpreter the visitor to be used for processing
|
* @param interpreter the visitor to be used for processing
|
||||||
*/
|
*/
|
||||||
public abstract void accept(ServerInterpreter interpreter);
|
public abstract void accept(ServerInterpreter interpreter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the bundle key of the informational text to be shown at the client.
|
||||||
|
* This key is used to retrieve the appropriate localized text for display.
|
||||||
|
*
|
||||||
|
* @return the bundle key of the informational text
|
||||||
|
*/
|
||||||
|
public abstract String getInfoTextKey();
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,10 @@ public class TimeOutWarning extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,10 @@ public class TradeReply extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,4 +34,10 @@ public class TradeRequest extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,13 @@ public class ViewAssetsResponse extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoTextKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'getInfoTextKey'");
|
||||||
|
}
|
||||||
|
|
||||||
public BoardManager getboard() {
|
public BoardManager getboard() {
|
||||||
return board;
|
return board;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
package pp.monopoly.model;
|
package pp.monopoly.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the rotation of a Item and provides functionality related to rotation.
|
* Represents the rotation of a Item and provides functionality related to rotation.
|
||||||
*/
|
*/
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
public enum Rotation implements Serializable {
|
public enum Rotation implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Represents the item facing upwards.
|
* Represents the item facing upwards.
|
||||||
|
@ -22,7 +22,7 @@ public class DeckHelper{
|
|||||||
cards.add(new Card("Du kommst aus dem Gulak frei!", "gulak-frei-2"));
|
cards.add(new Card("Du kommst aus dem Gulak frei!", "gulak-frei-2"));
|
||||||
cards.add(new Card("Du hast den Dienstführerschein bestanden. Ziehe vor bis Teststrecke.", "dienstfuehrerschein"));
|
cards.add(new Card("Du hast den Dienstführerschein bestanden. Ziehe vor bis Teststrecke.", "dienstfuehrerschein"));
|
||||||
cards.add(new Card("Malkmus läd zum Pubquiz ein. Rücke vor bis zum 20er.", "pubquiz"));
|
cards.add(new Card("Malkmus läd zum Pubquiz ein. Rücke vor bis zum 20er.", "pubquiz"));
|
||||||
cards.add(new Card("Deine IGF-Daten sind verschwunden. Statte Padubrin einen Besuch ab und gib ihm einen Jägermeister aus. Zahle 250 EUR", "IGF-Padubrin"));
|
cards.add(new Card("Deine IGF-Daten sind verschwunden, statte Padubrin einen Besuch ab und gib ihm einen Jägermeister aus.", "IGF-Padubrin"));
|
||||||
cards.add(new Card("Du hast heute die Spendierhosen an und gibst eine Runde in der Unibar. Zahle jedem Spieler 400 EUR", "spendierhosen-unibar"));
|
cards.add(new Card("Du hast heute die Spendierhosen an und gibst eine Runde in der Unibar. Zahle jedem Spieler 400 EUR", "spendierhosen-unibar"));
|
||||||
cards.add(new Card("Du warst in der Prüfungsphase krank. Gehe 3 Felder zurück.", "pruefungsphase-krank"));
|
cards.add(new Card("Du warst in der Prüfungsphase krank. Gehe 3 Felder zurück.", "pruefungsphase-krank"));
|
||||||
cards.add(new Card("Ziehe vor bis zum nächsten Monatsgehalt.", "naechstes-monatsgehalt"));
|
cards.add(new Card("Ziehe vor bis zum nächsten Monatsgehalt.", "naechstes-monatsgehalt"));
|
||||||
@ -205,7 +205,7 @@ public class DeckHelper{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void igfPadubrin(Player player) {
|
private void igfPadubrin(Player player) {
|
||||||
player.setPositionWithMoney(24);
|
player.setPosition(24);
|
||||||
player.pay(250);
|
player.pay(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user