summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/network/GameOfferControl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control/network/GameOfferControl.java')
-rw-r--r--src/jrummikub/control/network/GameOfferControl.java38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/jrummikub/control/network/GameOfferControl.java b/src/jrummikub/control/network/GameOfferControl.java
index 0c94c1f..8c5820d 100644
--- a/src/jrummikub/control/network/GameOfferControl.java
+++ b/src/jrummikub/control/network/GameOfferControl.java
@@ -7,6 +7,7 @@ import jrummikub.model.GameSettings;
import jrummikub.model.PlayerSettings;
import jrummikub.model.PlayerSettings.Type;
import jrummikub.util.GameData;
+import jrummikub.util.IListener;
import jrummikub.util.IListener1;
import jrummikub.view.ISettingsPanel.SettingsMode;
import jrummikub.view.IView;
@@ -20,16 +21,15 @@ public class GameOfferControl extends AbstractGameBeginControl {
* Creates new game offer control
*
* @param connectionControl
- * for events (listening and handling)
+ * for events (listening and handling)
* @param settings
- * the game settings for player list, colors, names
+ * the game settings for player list, colors, names
* @param view
- * the view
+ * the view
*/
public GameOfferControl(final IConnectionControl connectionControl,
final GameSettings settings, final IView view) {
- super(connectionControl, view,
- new GameData(UUID.randomUUID(), settings),
+ super(connectionControl, view, new GameData(UUID.randomUUID(), settings),
SettingsMode.NETWORK_OFFER);
connections.add(connectionControl.getGameJoinEvent().add(
@@ -54,11 +54,10 @@ public class GameOfferControl extends AbstractGameBeginControl {
new IListener1<String>() {
@Override
public void handle(String sender) {
- List<PlayerSettings> players = gameData
- .getGameSettings().getPlayerList();
+ List<PlayerSettings> players = gameData.getGameSettings()
+ .getPlayerList();
for (PlayerSettings s : players) {
- if (s.getName().equals(sender)
- && s.getType() == Type.NETWORK) {
+ if (s.getName().equals(sender) && s.getType() == Type.NETWORK) {
s.setType(Type.VACANT);
s.setName("Offen");
break;
@@ -68,6 +67,27 @@ public class GameOfferControl extends AbstractGameBeginControl {
connectionControl.offerGame(gameData);
}
}));
+
+ connections.add(view.getSettingsPanel().getStartGameEvent()
+ .add(new IListener() {
+ @Override
+ public void handle() {
+ List<PlayerSettings> players = gameData.getGameSettings()
+ .getPlayerList();
+ for (PlayerSettings s : players) {
+ if (s.getType() == Type.NETWORK) {
+ startGame();
+ return;
+ }
+ }
+ }
+ }));
+ }
+
+ @Override
+ protected void startGame() {
+ super.startGame();
+ connectionControl.startGame();
}
/**