diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-27 17:54:42 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-27 17:54:42 +0200 |
commit | f7743efa7ddf473a9ee24bfe7b69e0ccccdeacd5 (patch) | |
tree | deaa144e619eeb790b8cdb50d5bcdf53cb252a9e /src | |
parent | 531fe57b17394c931ee968a66104429e69cf60c6 (diff) | |
download | JRummikub-f7743efa7ddf473a9ee24bfe7b69e0ccccdeacd5.tar JRummikub-f7743efa7ddf473a9ee24bfe7b69e0ccccdeacd5.zip |
Test redealing in RoundControl
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@286 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src')
-rw-r--r-- | src/jrummikub/control/RoundControl.java | 41 | ||||
-rw-r--r-- | src/jrummikub/view/IPlayerPanel.java | 2 | ||||
-rw-r--r-- | src/jrummikub/view/IView.java | 2 |
3 files changed, 32 insertions, 13 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index 46ae459..c1997bb 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -15,7 +15,9 @@ import jrummikub.model.Score; import jrummikub.model.Stone; import jrummikub.model.StoneSet; import jrummikub.util.Connection; +import jrummikub.util.Event; import jrummikub.util.Event1; +import jrummikub.util.IEvent; import jrummikub.util.IEvent1; import jrummikub.util.IListener; import jrummikub.util.Pair; @@ -28,6 +30,7 @@ public class RoundControl { private IRoundState roundState; private IView view; private ITable clonedTable; + private Event restartRoundEvent = new Event(); private Event1<Score> endOfRoundEvent = new Event1<Score>(); private List<Connection> connections = new ArrayList<Connection>(); private boolean roundFinished; @@ -36,9 +39,9 @@ public class RoundControl { * Create a new RoundControl using the given gameState and view * * @param roundState - * initial round state + * initial round state * @param view - * view used for user interaction + * view used for user interaction */ public RoundControl(IRoundState roundState, IView view) { this.roundState = roundState; @@ -75,8 +78,8 @@ public class RoundControl { clonedTable = (ITable) roundState.getTable().clone(); view.enableStartTurnPanel(true); view.getTablePanel().setStoneSets(clonedTable); - view.setCurrentPlayerName(roundState.getActivePlayer().getPlayerSettings() - .getName()); + view.setCurrentPlayerName(roundState.getActivePlayer() + .getPlayerSettings().getName()); } private void startTurn() { @@ -97,8 +100,10 @@ public class RoundControl { for (int i = 0; i < roundState.getPlayerCount(); i++) { IHand hand = roundState.getNthNextPlayer(i).getHand(); for (int j = 0; j < 7; j++) { - hand.drop(roundState.getGameHeap().drawStone(), new Position(j, 0)); - hand.drop(roundState.getGameHeap().drawStone(), new Position(j, 1)); + hand.drop(roundState.getGameHeap().drawStone(), new Position(j, + 0)); + hand.drop(roundState.getGameHeap().drawStone(), new Position(j, + 1)); } } } @@ -113,7 +118,8 @@ public class RoundControl { } return totalValue == 0 - || totalValue >= roundState.getGameSettings().getInitialMeldThreshold(); + || totalValue >= roundState.getGameSettings() + .getInitialMeldThreshold(); } private void endOfTurn() { @@ -149,7 +155,8 @@ public class RoundControl { } if (!roundState.getActivePlayer().getLaidOut()) { // Player touched forbidden stones - if (!tableSetDifference(clonedTable, roundState.getTable()).isEmpty()) { + if (!tableSetDifference(clonedTable, roundState.getTable()) + .isEmpty()) { rejectMove(); return; } @@ -158,7 +165,8 @@ public class RoundControl { return; } } - Set<Stone> tableDiff = tableDifference(roundState.getTable(), clonedTable); + Set<Stone> tableDiff = tableDifference(roundState.getTable(), + clonedTable); roundState.setTable(clonedTable); @@ -174,7 +182,8 @@ public class RoundControl { } private void rejectMove() { - Set<Stone> tableDiff = tableDifference(roundState.getTable(), clonedTable); + Set<Stone> tableDiff = tableDifference(roundState.getTable(), + clonedTable); // deal penalty, reset roundState.getGameHeap().putBack(tableDiff); dealPenalty(tableDiff.size()); @@ -266,7 +275,8 @@ public class RoundControl { stonePoints = playerHand.getStonePoints(); } - bestScore = updateBestScore(bestScore, -stonePoints, playerHand.getSize()); + bestScore = updateBestScore(bestScore, -stonePoints, + playerHand.getSize()); points.add(-stonePoints); pointSum += stonePoints; @@ -295,4 +305,13 @@ public class RoundControl { } return bestScore; } + + /** + * Emitted when the round is aborted and needs to be restarted + * + * @return the event + */ + public IEvent getRestartRoundEvent() { + return restartRoundEvent; + } } diff --git a/src/jrummikub/view/IPlayerPanel.java b/src/jrummikub/view/IPlayerPanel.java index f1f8f95..03f04cd 100644 --- a/src/jrummikub/view/IPlayerPanel.java +++ b/src/jrummikub/view/IPlayerPanel.java @@ -42,5 +42,5 @@ public interface IPlayerPanel { * * @return the event */ - IEvent getRedealEvent(); + public IEvent getRedealEvent(); } diff --git a/src/jrummikub/view/IView.java b/src/jrummikub/view/IView.java index 67e0885..6a96213 100644 --- a/src/jrummikub/view/IView.java +++ b/src/jrummikub/view/IView.java @@ -79,7 +79,7 @@ public interface IView { * * @return the event */ - IEvent getFinalScoreEvent(); + public IEvent getFinalScoreEvent(); /** * The new round event is emitted when the player wants to start a new round |