mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-29 00:49:46 +01:00
send player ready
This commit is contained in:
parent
dcf10e0819
commit
422faec281
@ -40,14 +40,12 @@ public class LobbyMenu extends Dialog {
|
||||
|
||||
private TextField playerInputField = new TextField("Spieler 1");
|
||||
private TextField startingCapital = new TextField("15000");
|
||||
private String figure;
|
||||
|
||||
public LobbyMenu(MonopolyApp app) {
|
||||
super(app.getDialogManager());
|
||||
this.app = app;
|
||||
|
||||
// Entfernt das CreateGameMenu (inklusive Hintergrund)
|
||||
app.getGuiNode().detachAllChildren();
|
||||
|
||||
// Hintergrundbild laden und hinzufügen
|
||||
addBackgroundImage();
|
||||
|
||||
@ -207,7 +205,7 @@ public class LobbyMenu extends Dialog {
|
||||
* Schaltet den "Bereit"-Status um.
|
||||
*/
|
||||
private void toggleReady(Label playersLabel) {
|
||||
app.getGameLogic().send(new PlayerReady(true, "Test", "flugzeug", 15000));;
|
||||
app.getGameLogic().send(new PlayerReady(true, playerInputField.getText(), figure, Integer.parseInt(startingCapital.getText())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -258,19 +256,25 @@ public class LobbyMenu extends Dialog {
|
||||
System.out.println("Selected: " + selected);
|
||||
switch (selected) {
|
||||
case "[0]":
|
||||
System.out.println("Alpha selected");
|
||||
figure = "Laptop";
|
||||
break;
|
||||
case "[1]":
|
||||
System.out.println("Beta selected");
|
||||
figure = "Flugzeug";
|
||||
break;
|
||||
case "[2]":
|
||||
System.out.println("Gamma selected");
|
||||
figure = "Jägermeister";
|
||||
break;
|
||||
case "[3]":
|
||||
close();
|
||||
figure = "Katze";
|
||||
break;
|
||||
case "[4]":
|
||||
figure = "OOP";
|
||||
break;
|
||||
case "[5]":
|
||||
figure = "Handyholster";
|
||||
break;
|
||||
default:
|
||||
System.out.println("Unknown selection");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
LOGGER.log(Level.ERROR, "trying to send {0} with sender==null", msg); //NON-NLS
|
||||
} else {
|
||||
clientSender.send(msg);
|
||||
System.out.println("Message gesendet");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,19 @@
|
||||
package pp.monopoly.message.client;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a request from a player to buy a property.
|
||||
*/
|
||||
@Serializable
|
||||
public class BuyPropertyRequest extends ClientMessage{
|
||||
private int propertyId;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private BuyPropertyRequest() { /* empty */ }
|
||||
|
||||
/**
|
||||
* Constructs a BuyPropertyRequest with the specified property ID.
|
||||
*
|
||||
|
@ -1,9 +1,18 @@
|
||||
package pp.monopoly.message.client;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a message indicating the player wants to end their turn.
|
||||
*/
|
||||
@Serializable
|
||||
public class EndTurn extends ClientMessage{
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
public EndTurn() { /* empty */ }
|
||||
|
||||
@Override
|
||||
public void accept(ClientInterpreter interpreter, int from) {
|
||||
interpreter.received(this, from);
|
||||
|
@ -1,13 +1,21 @@
|
||||
package pp.monopoly.message.client;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a message indicating the player is ready to play.
|
||||
*/
|
||||
@Serializable
|
||||
public class PlayerReady extends ClientMessage {
|
||||
private final boolean isReady;
|
||||
private final String name;
|
||||
private final String figure;
|
||||
private final int startMoney;
|
||||
private boolean isReady;
|
||||
private String name;
|
||||
private String figure;
|
||||
private int startMoney;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private PlayerReady() { /* empty */ }
|
||||
|
||||
/**
|
||||
* Constructs a PlayerReady message.
|
||||
|
@ -1,9 +1,18 @@
|
||||
package pp.monopoly.message.client;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a message requesting to roll the dice.
|
||||
*/
|
||||
@Serializable
|
||||
public class RollDice extends ClientMessage{
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private RollDice() { /* empty */ }
|
||||
|
||||
@Override
|
||||
public void accept(ClientInterpreter interpreter, int from) {
|
||||
interpreter.received(this, from);
|
||||
|
@ -1,14 +1,21 @@
|
||||
package pp.monopoly.message.client;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import pp.monopoly.model.TradeHandler;
|
||||
|
||||
/**
|
||||
* Represents a trade Request message from one player to another.
|
||||
*/
|
||||
@Serializable
|
||||
public class TradeOffer extends ClientMessage{
|
||||
private int receiverId;
|
||||
private TradeHandler tradehandler;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private TradeOffer() { /* empty */ }
|
||||
|
||||
/**
|
||||
* Constructs a TradeOffer with the specified details.
|
||||
|
@ -1,14 +1,22 @@
|
||||
package pp.monopoly.message.client;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import pp.monopoly.model.TradeHandler;
|
||||
|
||||
/**
|
||||
* Represents a response to a trade offer.
|
||||
*/
|
||||
@Serializable
|
||||
public class TradeResponse extends ClientMessage{
|
||||
private int initiatorId;
|
||||
private TradeHandler tradeHandler;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private TradeResponse() { /* empty */ }
|
||||
|
||||
/**
|
||||
* Constructs a TradeResponse with the specified response details.
|
||||
*
|
||||
|
@ -1,13 +1,21 @@
|
||||
package pp.monopoly.message.client;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import pp.monopoly.game.server.Player;
|
||||
|
||||
/**
|
||||
* Represents a request from a player to view their assets.
|
||||
*/
|
||||
@Serializable
|
||||
public class ViewAssetsRequest extends ClientMessage{
|
||||
|
||||
private final Player player;
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private ViewAssetsRequest() { /* empty */ }
|
||||
|
||||
public ViewAssetsRequest(Player player) {
|
||||
this.player = player;
|
||||
|
@ -28,7 +28,14 @@ import pp.monopoly.MonopolyConfig;
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.game.server.ServerGameLogic;
|
||||
import pp.monopoly.game.server.ServerSender;
|
||||
import pp.monopoly.message.client.BuyPropertyRequest;
|
||||
import pp.monopoly.message.client.ClientMessage;
|
||||
import pp.monopoly.message.client.EndTurn;
|
||||
import pp.monopoly.message.client.PlayerReady;
|
||||
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.ServerMessage;
|
||||
import pp.monopoly.model.IntPoint;
|
||||
|
||||
@ -105,6 +112,13 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
||||
|
||||
private void initializeSerializables() {
|
||||
Serializer.registerClass(IntPoint.class);
|
||||
Serializer.registerClass(BuyPropertyRequest.class);
|
||||
Serializer.registerClass(EndTurn.class);
|
||||
Serializer.registerClass(PlayerReady.class);
|
||||
Serializer.registerClass(RollDice.class);
|
||||
Serializer.registerClass(TradeOffer.class);
|
||||
Serializer.registerClass(TradeResponse.class);
|
||||
Serializer.registerClass(ViewAssetsRequest.class);
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
@ -113,6 +127,7 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
||||
|
||||
@Override
|
||||
public void messageReceived(HostedConnection source, Message message) {
|
||||
System.out.println("Message recieved");
|
||||
LOGGER.log(Level.INFO, "message received from {0}: {1}", source.getId(), message); //NON-NLS
|
||||
if (message instanceof ClientMessage clientMessage)
|
||||
pendingMessages.add(new ReceivedMessage(clientMessage, source.getId()));
|
||||
|
Loading…
Reference in New Issue
Block a user