From 79767f762e39eac3a0247b9ee75b24258790e0de Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 14 Jun 2011 17:18:13 +0200 Subject: Show Human/Network type correctly on game join git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@435 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/network/GameJoinControl.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3