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
7 Commits
acc797f2ff
...
4a9eba255b
Author | SHA1 | Date | |
---|---|---|---|
|
4a9eba255b | ||
|
4713a526b3 | ||
|
362c0e5679 | ||
|
fab2457715 | ||
|
7b3f31f099 | ||
|
ed105f1b70 | ||
|
cd4331aee3 |
@ -228,6 +228,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
||||
private void setupGui() {
|
||||
GuiGlobals.initialize(this);
|
||||
BaseStyles.loadStyleResources(STYLES_SCRIPT);
|
||||
BaseStyles.loadGlassStyle();
|
||||
GuiGlobals.getInstance().getStyles().setDefaultStyle("pp"); //NON-NLS
|
||||
final BitmapFont normalFont = assetManager.loadFont(FONT); //NON-NLS
|
||||
topText = new BitmapText(normalFont);
|
||||
|
@ -25,9 +25,9 @@ import com.simsilica.lemur.component.SpringGridLayout;
|
||||
|
||||
import static pp.monopoly.Resources.lookup;
|
||||
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
import pp.monopoly.client.MonopolyApp;
|
||||
import pp.monopoly.client.NetworkSupport;
|
||||
import pp.monopoly.notification.Sound;
|
||||
import pp.monopoly.server.MonopolyServer;
|
||||
import pp.dialog.Dialog;
|
||||
import pp.dialog.DialogBuilder;
|
||||
@ -78,7 +78,7 @@ public class CreateGameMenu extends Dialog {
|
||||
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
|
||||
app.getGuiNode().attachChild(background);
|
||||
|
||||
|
||||
addChild(new Label("Spiel erstellen", new ElementId("header"))); //NON-NLS
|
||||
final Container input = new Container(new SpringGridLayout());
|
||||
input.addChild(new Label(lookup("host.name") + ": "));
|
||||
input.addChild(host, 1);
|
||||
@ -88,27 +88,20 @@ public class CreateGameMenu extends Dialog {
|
||||
addChild(input);
|
||||
// "Abbrechen"-Button
|
||||
cancelButton.setPreferredSize(new Vector3f(120, 40, 0));
|
||||
cancelButton.addClickCommands(source -> close());
|
||||
addChild(cancelButton);
|
||||
cancelButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
this.close();
|
||||
new StartMenu(app);
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
new StartMenu(network.getApp()).open();
|
||||
}));
|
||||
addChild(cancelButton);
|
||||
|
||||
// "Selber hosten"-Button
|
||||
addChild(serverButton).addClickCommands(s -> ifTopDialog(() -> {
|
||||
startServerInThread();
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
}));
|
||||
serverButton.addClickCommands(s -> ifTopDialog(this::startServerInThread));
|
||||
addChild(serverButton);
|
||||
|
||||
// "Beitreten"-Button
|
||||
joinButton.setPreferredSize(new Vector3f(120, 40, 0));
|
||||
joinButton.addClickCommands(s -> ifTopDialog(this::connect));
|
||||
addChild(joinButton);
|
||||
joinButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
connect();
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,7 +148,7 @@ public class CreateGameMenu extends Dialog {
|
||||
|
||||
@Override
|
||||
public void escape() {
|
||||
close();
|
||||
new SettingsMenu(network.getApp()).open();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,7 +211,6 @@ public class CreateGameMenu extends Dialog {
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
connect();
|
||||
|
@ -131,11 +131,11 @@ public class LobbyMenu extends Dialog {
|
||||
buttonContainer.setBackground(null);
|
||||
// Lower-left container for "Abbrechen" button
|
||||
lowerLeftMenu = new Container();
|
||||
Button cancelButton = new Button("Abbrechen");
|
||||
Button cancelButton = new Button("Beenden");
|
||||
cancelButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
|
||||
cancelButton.setFontSize(18); // Adjust font size
|
||||
cancelButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
this.close();
|
||||
app.closeApp();
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
}));
|
||||
lowerLeftMenu.addChild(cancelButton);
|
||||
@ -217,7 +217,7 @@ public class LobbyMenu extends Dialog {
|
||||
|
||||
@Override
|
||||
public void escape() {
|
||||
super.close();
|
||||
new SettingsMenu(app).open();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,6 @@
|
||||
package pp.monopoly.client.gui;
|
||||
|
||||
import com.simsilica.lemur.Slider;
|
||||
import pp.monopoly.client.GameMusic;
|
||||
import pp.monopoly.client.GameSound;
|
||||
|
||||
public class SoundSlider extends Slider {
|
||||
|
@ -22,8 +22,6 @@ import pp.monopoly.client.gui.GameMenu;
|
||||
*/
|
||||
public class StartMenu extends Dialog {
|
||||
private final MonopolyApp app;
|
||||
private Container logoContainer;
|
||||
private Container unibwLogoContainer;
|
||||
|
||||
/**
|
||||
* Constructs the Startup Menu dialog for the Monopoly application.
|
||||
|
@ -3,10 +3,11 @@ 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.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import com.simsilica.lemur.*;
|
||||
import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.style.ElementId;
|
||||
import pp.dialog.Dialog;
|
||||
|
@ -5,7 +5,6 @@ import com.jme3.material.RenderState.BlendMode;
|
||||
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.Container;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
|
@ -5,7 +5,7 @@ import java.lang.System.Logger.Level;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import pp.monopoly.game.server.PlayerHandler;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.message.client.ClientMessage;
|
||||
import pp.monopoly.message.server.BuyPropertyResponse;
|
||||
import pp.monopoly.message.server.DiceResult;
|
||||
@ -52,7 +52,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
/** The current state of the client game logic. */
|
||||
private ClientState state = new LobbyState(this);
|
||||
|
||||
private PlayerHandler playerHandler;
|
||||
private List<Player> players;
|
||||
|
||||
private BoardManager boardManager = new BoardManager();
|
||||
|
||||
@ -94,8 +94,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
state.entry();
|
||||
}
|
||||
|
||||
public PlayerHandler getPlayerHandler() {
|
||||
return playerHandler;
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,7 +255,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
*/
|
||||
@Override
|
||||
public void received(GameStart msg) {
|
||||
playerHandler = msg.getPlayerHandler();
|
||||
players = msg.getPlayers();
|
||||
setInfoText("The game has started! Good luck!");
|
||||
setState(new WaitForTurnState(this));
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ package pp.monopoly.game.server;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import pp.monopoly.message.server.DiceResult;
|
||||
import pp.monopoly.model.FieldVisitor;
|
||||
import pp.monopoly.model.Figure;
|
||||
@ -28,6 +30,7 @@ import pp.monopoly.model.fields.WacheField;
|
||||
/**
|
||||
* Class representing a player
|
||||
*/
|
||||
@Serializable
|
||||
public class Player implements FieldVisitor<Void>{
|
||||
private final int id;
|
||||
private String name;
|
||||
@ -40,6 +43,14 @@ public class Player implements FieldVisitor<Void>{
|
||||
private final PlayerHandler handler;
|
||||
private PlayerState state = new LobbyState();
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private Player(){
|
||||
id = 0;
|
||||
handler = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a player with the speciefied params
|
||||
* @param id the id of the player
|
||||
|
@ -8,10 +8,13 @@ import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import pp.monopoly.model.LimitedLinkedList;
|
||||
/**
|
||||
* A class for helping with player actions and managing thier turns
|
||||
*/
|
||||
@Serializable
|
||||
public class PlayerHandler {
|
||||
private List<Player> players = new LimitedLinkedList<>(6);
|
||||
private Set<Player> readyPlayers = new HashSet<>();
|
||||
@ -19,6 +22,11 @@ public class PlayerHandler {
|
||||
private Player hostPlayer;
|
||||
private Player extra = null;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private PlayerHandler() {}
|
||||
|
||||
/**
|
||||
* Contructs a PlayerHandler
|
||||
* @param logic the {@link ServerGameLogic} this PlayerHandler is a part of
|
||||
|
@ -204,7 +204,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
if(playerHandler.allPlayersReady()) {
|
||||
playerHandler.setStartBalance(startMoney);
|
||||
for (Player p : playerHandler.getPlayers()) {
|
||||
send(p, new GameStart(playerHandler));
|
||||
send(p, new GameStart(playerHandler.getPlayers()));
|
||||
}
|
||||
playerHandler.randomOrder();
|
||||
send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn(playerHandler.getPlayerAtIndex(0)));
|
||||
|
@ -1,25 +1,27 @@
|
||||
package pp.monopoly.message.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import pp.monopoly.game.server.PlayerHandler;
|
||||
import pp.monopoly.game.server.Player;
|
||||
|
||||
@Serializable
|
||||
public class GameStart extends ServerMessage{
|
||||
|
||||
private PlayerHandler ph;
|
||||
private List<Player> players;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private GameStart() { /* empty */ }
|
||||
|
||||
public GameStart(PlayerHandler ph) {
|
||||
this.ph = ph;
|
||||
public GameStart(List<Player> players) {
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
public PlayerHandler getPlayerHandler() {
|
||||
return ph;
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,9 +4,12 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.Math.min;
|
||||
|
||||
@Serializable
|
||||
public class Figure implements Item{
|
||||
private final String type;
|
||||
private final int length; // The length of the Figure
|
||||
|
@ -2,14 +2,22 @@ package pp.monopoly.model;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* A LinkedList with a maximum size limit.
|
||||
*
|
||||
* @param <E> the type of elements held in this collection
|
||||
*/
|
||||
@Serializable
|
||||
public class LimitedLinkedList<E> extends LinkedList<E> {
|
||||
|
||||
private final int maxSize;
|
||||
private int maxSize;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private LimitedLinkedList() {}
|
||||
|
||||
/**
|
||||
* Constructs a LimitedLinkedList with the specified maximum size.
|
||||
|
@ -26,6 +26,7 @@ import com.jme3.network.serializing.Serializer;
|
||||
|
||||
import pp.monopoly.MonopolyConfig;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.game.server.PlayerHandler;
|
||||
import pp.monopoly.game.server.ServerGameLogic;
|
||||
import pp.monopoly.game.server.ServerSender;
|
||||
import pp.monopoly.message.client.BuyPropertyRequest;
|
||||
@ -36,8 +37,12 @@ import pp.monopoly.message.client.RollDice;
|
||||
import pp.monopoly.message.client.TradeOffer;
|
||||
import pp.monopoly.message.client.TradeResponse;
|
||||
import pp.monopoly.message.client.ViewAssetsRequest;
|
||||
import pp.monopoly.message.server.GameStart;
|
||||
import pp.monopoly.message.server.NextPlayerTurn;
|
||||
import pp.monopoly.message.server.ServerMessage;
|
||||
import pp.monopoly.model.Figure;
|
||||
import pp.monopoly.model.IntPoint;
|
||||
import pp.monopoly.model.LimitedLinkedList;
|
||||
|
||||
/**
|
||||
* Server implementing the visitor pattern as MessageReceiver for ClientMessages
|
||||
@ -119,6 +124,12 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
||||
Serializer.registerClass(TradeOffer.class);
|
||||
Serializer.registerClass(TradeResponse.class);
|
||||
Serializer.registerClass(ViewAssetsRequest.class);
|
||||
Serializer.registerClass(GameStart.class);
|
||||
Serializer.registerClass(LimitedLinkedList.class);
|
||||
Serializer.registerClass(NextPlayerTurn.class);
|
||||
Serializer.registerClass(Player.class);
|
||||
Serializer.registerClass(Figure.class);
|
||||
Serializer.registerClass(PlayerHandler.class);
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
|
Loading…
Reference in New Issue
Block a user