if (msg.getState() == GameState.RUNNING) {
handleGameSetup(msg.getGameSetup());
for (SlotMessage slotMsg : msg.getSlots()) {
handleSlot(slotMsg);
}
CreateGamePhase phase = (CreateGamePhase)game.getPhase();
phase.startGame();
return;
}
CreateGamePhase phase;
Snapshot snapshot = null;
if (msg.getSnapshot() != null) {
try {
snapshot = new Snapshot(msg.getSnapshot());
} catch (IOException e) {
logger.error(e.getMessage(), e);
return;
}
}
if (snapshot == null) {
game = new Game(msg.getGameId());
phase = new CreateGamePhase(game, conn);
} else {
game = snapshot.asGame(msg.getGameId());
phase = new LoadGamePhase(game, snapshot, conn);
}
game.setConfig(client.getConfig());
final PlayerSlot[] slots = new PlayerSlot[PlayerSlot.COUNT];
for (SlotMessage slotMsg : msg.getSlots()) {
int number = slotMsg.getNumber();
PlayerSlot slot = new PlayerSlot(number);
slot.setColors(game.getConfig().getPlayerColor(slot));
slots[number] = slot;
updateSlot(slots, slotMsg);
}
phase.setSlots(slots);
game.getPhases().put(phase.getClass(), phase);
game.setPhase(phase);
if (msg.getState() == GameState.OPEN) {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {