mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-24 22:49:44 +01:00
send PlayerHandler when starting game
This commit is contained in:
parent
e780513b35
commit
9b4cac4e56
@ -5,7 +5,7 @@ import java.lang.System.Logger.Level;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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.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;
|
||||||
@ -51,7 +51,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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a ClientGameLogic with the specified sender object.
|
* Constructs a ClientGameLogic with the specified sender object.
|
||||||
@ -83,8 +83,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
state.entry();
|
state.entry();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Player> getPlayers() {
|
public PlayerHandler getPlayerHandler() {
|
||||||
return players;
|
return playerHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -243,7 +243,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();
|
||||||
setInfoText("The game has started! Good luck!");
|
setInfoText("The game has started! Good luck!");
|
||||||
setState(new WaitForTurnState(this));
|
setState(new WaitForTurnState(this));
|
||||||
}
|
}
|
||||||
|
@ -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(playerHandler.getPlayerAtIndex(0)));
|
send(playerHandler.getPlayerAtIndex(0), new NextPlayerTurn(playerHandler.getPlayerAtIndex(0)));
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
package pp.monopoly.message.server;
|
package pp.monopoly.message.server;
|
||||||
|
|
||||||
import java.util.List;
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
|
||||||
|
|
||||||
public class GameStart extends ServerMessage{
|
public class GameStart extends ServerMessage{
|
||||||
|
|
||||||
private final List<Player> players;
|
private final PlayerHandler ph;
|
||||||
|
|
||||||
public GameStart(List<Player> players) {
|
public GameStart(PlayerHandler ph) {
|
||||||
this.players = players;
|
this.ph = ph;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Player> getPlayers() {
|
public PlayerHandler getPlayerHandler() {
|
||||||
return players;
|
return ph;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user