mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-24 23:59:44 +01:00
send GameStart message with a list of all Players
This commit is contained in:
parent
f11f4a59f1
commit
cdce478d77
@ -50,6 +50,14 @@ public class PlayerHandler {
|
||||
return players.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retuns all players
|
||||
* @return List of all players
|
||||
*/
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chechs if all players are ready to start the game
|
||||
* @return {@code true} if all players are ready, otherwise {@code false}
|
||||
|
@ -2,6 +2,7 @@ package pp.monopoly.game.server;
|
||||
|
||||
import pp.monopoly.MonopolyConfig;
|
||||
import pp.monopoly.message.client.*;
|
||||
import pp.monopoly.message.server.GameStart;
|
||||
import pp.monopoly.message.server.ServerMessage;
|
||||
import pp.monopoly.message.server.TradeReply;
|
||||
import pp.monopoly.message.server.TradeRequest;
|
||||
@ -177,6 +178,12 @@ public class ServerGameLogic implements ClientInterpreter {
|
||||
playerHandler.setPlayerReady(player, true);
|
||||
LOGGER.log(Level.DEBUG, "Player {0} is ready", player.getName());
|
||||
}
|
||||
|
||||
if(playerHandler.allPlayersReady()) {
|
||||
for (Player p : playerHandler.getPlayers()) {
|
||||
send(p, new GameStart(playerHandler.getPlayers()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,21 @@
|
||||
package pp.monopoly.message.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import pp.monopoly.game.server.Player;
|
||||
|
||||
public class GameStart extends ServerMessage{
|
||||
|
||||
private final List<Player> players;
|
||||
|
||||
public GameStart(List<Player> players) {
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
interpreter.received(this);
|
||||
|
Loading…
Reference in New Issue
Block a user