diff options
Diffstat (limited to 'src/jrummikub')
-rw-r--r-- | src/jrummikub/control/network/GameJoinControl.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/jrummikub/control/network/GameJoinControl.java b/src/jrummikub/control/network/GameJoinControl.java index c436887..048491a 100644 --- a/src/jrummikub/control/network/GameJoinControl.java +++ b/src/jrummikub/control/network/GameJoinControl.java @@ -3,6 +3,9 @@ package jrummikub.control.network; import java.util.ArrayList; import java.util.List; +import jrummikub.model.GameSettings; +import jrummikub.model.PlayerSettings; +import jrummikub.model.PlayerSettings.Type; import jrummikub.util.Connection; import jrummikub.util.GameData; import jrummikub.util.IListener1; @@ -30,13 +33,28 @@ public class GameJoinControl { @Override public void handle(GameData data) { if (data.getGameID().equals(gameData.getGameID())) { - gameData.setGameSettings(data.getGameSettings()); - view.getSettingsPanel().setGameSettings(data.getGameSettings()); + GameSettings settings = data.getGameSettings(); + + fixGameSettings(settings); + + gameData.setGameSettings(settings); + view.getSettingsPanel().setGameSettings(settings); } } })); } + private void fixGameSettings(GameSettings settings) { + for (PlayerSettings player : settings.getPlayerList()) { + if (player.getType() == Type.HUMAN) { + player.setType(Type.NETWORK); + } else if (player.getType() == Type.NETWORK + && player.getName().equals(connectionControl.getNickname())) { + player.setType(Type.HUMAN); + } + } + } + public void startGameJoin() { view.showSettingsPanel(true); } |