From 121afdf6c6341cb04a91d47db0c2fc477ccd84da Mon Sep 17 00:00:00 2001 From: Bennet Gerlach Date: Thu, 5 May 2011 01:33:58 +0200 Subject: Implemented stone display in both controls, tested (weniger Mock-Mist) git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@140 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/JRummikub.java | 13 ++++++++----- src/jrummikub/control/RoundControl.java | 26 +++++++++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/jrummikub/JRummikub.java b/src/jrummikub/JRummikub.java index 38d152d..80d7080 100644 --- a/src/jrummikub/JRummikub.java +++ b/src/jrummikub/JRummikub.java @@ -2,9 +2,11 @@ package jrummikub; import javax.swing.UIManager; -import jrummikub.control.TurnControl; +import jrummikub.control.RoundControl; import jrummikub.model.GameState; import jrummikub.model.Position; +import jrummikub.model.Stone; +import jrummikub.model.StoneSet; import jrummikub.view.impl.View; public class JRummikub { @@ -20,11 +22,12 @@ public class JRummikub { GameState gameState = new GameState(); View view = new View(); - gameState.getActivePlayer().getHand() - .drop(gameState.getGameHeap().drawStone(), new Position(0, 0)); + for (Stone stone : gameState.getGameHeap().drawStones(5)) { + gameState.getTable().drop(new StoneSet(stone), new Position(0, 0)); + } - TurnControl turnControl = new TurnControl(gameState.getActivePlayer() - .getHand(), gameState.getTable(), view); + RoundControl roundControl = new RoundControl(gameState, view); + roundControl.startRound(); } diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index a481991..2282666 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -2,8 +2,8 @@ package jrummikub.control; import jrummikub.model.IGameState; import jrummikub.model.IHand; -import jrummikub.model.Player; import jrummikub.model.Position; +import jrummikub.util.IListener; import jrummikub.view.IView; public class RoundControl { @@ -16,17 +16,33 @@ public class RoundControl { } public void startRound() { + deal(); + view.getStartTurnEvent().add(new IListener() { + + @Override + public void handle() { + startTurn(); + } + }); + + view.enableStartTurnPanel(true); + view.getTablePanel().setStoneSets(gameState.getTable().clone()); + } + + private void startTurn() { + TurnControl turnControl = new TurnControl(gameState.getActivePlayer() + .getHand(), gameState.getTable(), view); + + } void deal() { for (int i = 0; i < gameState.getPlayerCount(); i++) { IHand hand = gameState.getPlayer(i).getHand(); for (int j = 0; j < 7; j++) { - hand.drop(gameState.getGameHeap().drawStone(), new Position(j, - 0)); - hand.drop(gameState.getGameHeap().drawStone(), new Position(j, - 1)); + hand.drop(gameState.getGameHeap().drawStone(), new Position(j, 0)); + hand.drop(gameState.getGameHeap().drawStone(), new Position(j, 1)); } } } -- cgit v1.2.3