Updated 'LobbyState' class.
Updated the 'LobbyState' class by updating the 'received(ServerStartGameMessage msg)' method in it after updating the 'ServerStartGameMessage' class.
This commit is contained in:
@@ -5,12 +5,14 @@
|
|||||||
import pp.mdga.client.DialogsState;
|
import pp.mdga.client.DialogsState;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
|
import pp.mdga.game.Player;
|
||||||
import pp.mdga.message.client.*;
|
import pp.mdga.message.client.*;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
import pp.mdga.notification.*;
|
import pp.mdga.notification.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class LobbyState extends DialogStates {
|
public class LobbyState extends DialogStates {
|
||||||
@@ -61,9 +63,7 @@ public void selectUnready() {
|
|||||||
@Override
|
@Override
|
||||||
public void selectStart() {
|
public void selectStart() {
|
||||||
if (logic.isHost() && logic.getGame().areAllReady()) {
|
if (logic.isHost() && logic.getGame().areAllReady()) {
|
||||||
logic.send(new StartGameMessage(false));
|
logic.send(new StartGameMessage());
|
||||||
} else if (logic.isHost() && !logic.getGame().areAllReady()) {
|
|
||||||
logic.send(new StartGameMessage(true));
|
|
||||||
} else {
|
} else {
|
||||||
LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
|
LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
|
||||||
}
|
}
|
||||||
@@ -71,6 +71,13 @@ public void selectStart() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(ServerStartGameMessage msg) {
|
public void received(ServerStartGameMessage msg) {
|
||||||
|
for (Player player: msg.getPlayers()) {
|
||||||
|
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
|
||||||
|
if (entry.getValue().getColor() == player.getColor()) {
|
||||||
|
this.logic.getGame().getPlayers().put(entry.getKey(), player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
logic.getGame().setBoard(msg.getBoard());
|
logic.getGame().setBoard(msg.getBoard());
|
||||||
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
|
logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
|
||||||
for (var player : logic.getGame().getPlayers().values()) {
|
for (var player : logic.getGame().getPlayers().values()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user