mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-29 06:40:00 +01:00
send PlayerHandler in GameStart
This commit is contained in:
parent
4095d9e79d
commit
0e405d2f90
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.game.server.PlayerHandler;
|
||||
import pp.monopoly.message.client.ClientMessage;
|
||||
import pp.monopoly.message.server.BuyPropertyResponse;
|
||||
import pp.monopoly.message.server.DiceResult;
|
||||
@ -52,7 +53,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
/** The current state of the client game logic. */
|
||||
private ClientState state = new LobbyState(this);
|
||||
|
||||
private List<Player> players;
|
||||
private PlayerHandler playerHandler;
|
||||
|
||||
private BoardManager boardManager = new BoardManager();
|
||||
|
||||
@ -94,8 +95,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
state.entry();
|
||||
}
|
||||
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
public PlayerHandler getPlayerHandler() {
|
||||
return playerHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,7 +256,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
||||
*/
|
||||
@Override
|
||||
public void received(GameStart msg) {
|
||||
players = msg.getPlayers();
|
||||
playerHandler = msg.getPlayerHandler();
|
||||
setState(new WaitForTurnState(this));
|
||||
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ public class Player implements FieldVisitor<Void>{
|
||||
private int getOutOfJailCard;
|
||||
private int fieldID;
|
||||
private DiceResult rollResult;
|
||||
private final PlayerHandler handler;
|
||||
private PlayerState state = new LobbyState();
|
||||
private transient final PlayerHandler handler;
|
||||
private transient PlayerState state = new LobbyState();
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
|
@ -1,6 +1,5 @@
|
||||
package pp.monopoly.game.server;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@ -18,7 +17,7 @@ import pp.monopoly.model.LimitedLinkedList;
|
||||
public class PlayerHandler {
|
||||
private List<Player> players = new LimitedLinkedList<>(6);
|
||||
private Set<Player> readyPlayers = new HashSet<>();
|
||||
private ServerGameLogic logic;
|
||||
private transient ServerGameLogic logic;
|
||||
private Player hostPlayer;
|
||||
private Player extra = null;
|
||||
|
||||
|
@ -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.getPlayers()));
|
||||
send(p, new GameStart(playerHandler));
|
||||
}
|
||||
playerHandler.randomOrder();
|
||||
send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn());
|
||||
|
@ -1,27 +1,25 @@
|
||||
package pp.monopoly.message.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import pp.monopoly.game.server.Player;
|
||||
import pp.monopoly.game.server.PlayerHandler;
|
||||
|
||||
@Serializable
|
||||
public class GameStart extends ServerMessage{
|
||||
|
||||
private List<Player> players;
|
||||
private PlayerHandler playerHandler;
|
||||
|
||||
/**
|
||||
* Default constructor for serialization purposes.
|
||||
*/
|
||||
private GameStart() { /* empty */ }
|
||||
|
||||
public GameStart(List<Player> players) {
|
||||
this.players = players;
|
||||
public GameStart(PlayerHandler playerHandler) {
|
||||
this.playerHandler = playerHandler;
|
||||
}
|
||||
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
public PlayerHandler getPlayerHandler() {
|
||||
return playerHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,18 +43,6 @@ import pp.monopoly.message.server.ServerMessage;
|
||||
import pp.monopoly.model.Figure;
|
||||
import pp.monopoly.model.IntPoint;
|
||||
import pp.monopoly.model.LimitedLinkedList;
|
||||
import pp.monopoly.model.fields.BuildingProperty;
|
||||
import pp.monopoly.model.fields.EventField;
|
||||
import pp.monopoly.model.fields.Field;
|
||||
import pp.monopoly.model.fields.FieldColor;
|
||||
import pp.monopoly.model.fields.FineField;
|
||||
import pp.monopoly.model.fields.FoodField;
|
||||
import pp.monopoly.model.fields.GateField;
|
||||
import pp.monopoly.model.fields.GoField;
|
||||
import pp.monopoly.model.fields.GulagField;
|
||||
import pp.monopoly.model.fields.PropertyField;
|
||||
import pp.monopoly.model.fields.TestStreckeField;
|
||||
import pp.monopoly.model.fields.WacheField;
|
||||
|
||||
/**
|
||||
* Server implementing the visitor pattern as MessageReceiver for ClientMessages
|
||||
@ -141,19 +129,7 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
||||
Serializer.registerClass(NextPlayerTurn.class);
|
||||
Serializer.registerClass(Player.class);
|
||||
Serializer.registerClass(Figure.class);
|
||||
// Serializer.registerClass(PlayerHandler.class);
|
||||
// Serializer.registerClass(BuildingProperty.class);
|
||||
// Serializer.registerClass(EventField.class);
|
||||
// Serializer.registerClass(Field.class);
|
||||
// // Serializer.registerClass(FieldColor.class);
|
||||
// Serializer.registerClass(FineField.class);
|
||||
// Serializer.registerClass(FoodField.class);
|
||||
// Serializer.registerClass(GateField.class);
|
||||
// Serializer.registerClass(GoField.class);
|
||||
// Serializer.registerClass(GulagField.class);
|
||||
// Serializer.registerClass(PropertyField.class);
|
||||
// Serializer.registerClass(TestStreckeField.class);
|
||||
// Serializer.registerClass(WacheField.class);
|
||||
Serializer.registerClass(PlayerHandler.class);
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
|
Loading…
Reference in New Issue
Block a user