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