mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-29 08:59:44 +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 java.util.List;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
import pp.monopoly.message.client.ClientMessage;
|
import pp.monopoly.message.client.ClientMessage;
|
||||||
import pp.monopoly.message.server.BuyPropertyResponse;
|
import pp.monopoly.message.server.BuyPropertyResponse;
|
||||||
import pp.monopoly.message.server.DiceResult;
|
import pp.monopoly.message.server.DiceResult;
|
||||||
@ -52,7 +53,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
/** The current state of the client game logic. */
|
/** The current state of the client game logic. */
|
||||||
private ClientState state = new LobbyState(this);
|
private ClientState state = new LobbyState(this);
|
||||||
|
|
||||||
private List<Player> players;
|
private PlayerHandler playerHandler;
|
||||||
|
|
||||||
private BoardManager boardManager = new BoardManager();
|
private BoardManager boardManager = new BoardManager();
|
||||||
|
|
||||||
@ -94,8 +95,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
state.entry();
|
state.entry();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Player> getPlayers() {
|
public PlayerHandler getPlayerHandler() {
|
||||||
return players;
|
return playerHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -255,7 +256,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(GameStart msg) {
|
public void received(GameStart msg) {
|
||||||
players = msg.getPlayers();
|
playerHandler = msg.getPlayerHandler();
|
||||||
setState(new WaitForTurnState(this));
|
setState(new WaitForTurnState(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
private int getOutOfJailCard;
|
private int getOutOfJailCard;
|
||||||
private int fieldID;
|
private int fieldID;
|
||||||
private DiceResult rollResult;
|
private DiceResult rollResult;
|
||||||
private final PlayerHandler handler;
|
private transient final PlayerHandler handler;
|
||||||
private PlayerState state = new LobbyState();
|
private transient PlayerState state = new LobbyState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor for serialization purposes.
|
* Default constructor for serialization purposes.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package pp.monopoly.game.server;
|
package pp.monopoly.game.server;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -18,7 +17,7 @@ import pp.monopoly.model.LimitedLinkedList;
|
|||||||
public class PlayerHandler {
|
public class PlayerHandler {
|
||||||
private List<Player> players = new LimitedLinkedList<>(6);
|
private List<Player> players = new LimitedLinkedList<>(6);
|
||||||
private Set<Player> readyPlayers = new HashSet<>();
|
private Set<Player> readyPlayers = new HashSet<>();
|
||||||
private ServerGameLogic logic;
|
private transient ServerGameLogic logic;
|
||||||
private Player hostPlayer;
|
private Player hostPlayer;
|
||||||
private Player extra = null;
|
private Player extra = null;
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
if(playerHandler.allPlayersReady()) {
|
if(playerHandler.allPlayersReady()) {
|
||||||
playerHandler.setStartBalance(startMoney);
|
playerHandler.setStartBalance(startMoney);
|
||||||
for (Player p : playerHandler.getPlayers()) {
|
for (Player p : playerHandler.getPlayers()) {
|
||||||
send(p, new GameStart(playerHandler.getPlayers()));
|
send(p, new GameStart(playerHandler));
|
||||||
}
|
}
|
||||||
playerHandler.randomOrder();
|
playerHandler.randomOrder();
|
||||||
send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn());
|
send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn());
|
||||||
|
@ -1,27 +1,25 @@
|
|||||||
package pp.monopoly.message.server;
|
package pp.monopoly.message.server;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
public class GameStart extends ServerMessage{
|
public class GameStart extends ServerMessage{
|
||||||
|
|
||||||
private List<Player> players;
|
private PlayerHandler playerHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor for serialization purposes.
|
* Default constructor for serialization purposes.
|
||||||
*/
|
*/
|
||||||
private GameStart() { /* empty */ }
|
private GameStart() { /* empty */ }
|
||||||
|
|
||||||
public GameStart(List<Player> players) {
|
public GameStart(PlayerHandler playerHandler) {
|
||||||
this.players = players;
|
this.playerHandler = playerHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Player> getPlayers() {
|
public PlayerHandler getPlayerHandler() {
|
||||||
return players;
|
return playerHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,18 +43,6 @@ import pp.monopoly.message.server.ServerMessage;
|
|||||||
import pp.monopoly.model.Figure;
|
import pp.monopoly.model.Figure;
|
||||||
import pp.monopoly.model.IntPoint;
|
import pp.monopoly.model.IntPoint;
|
||||||
import pp.monopoly.model.LimitedLinkedList;
|
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
|
* 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(NextPlayerTurn.class);
|
||||||
Serializer.registerClass(Player.class);
|
Serializer.registerClass(Player.class);
|
||||||
Serializer.registerClass(Figure.class);
|
Serializer.registerClass(Figure.class);
|
||||||
// Serializer.registerClass(PlayerHandler.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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
|
Loading…
Reference in New Issue
Block a user