From 45d5b3ae10ed8cfbecb5489636093c6fb0576970 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 8 Jun 2011 21:58:16 +0200 Subject: Implement pause function git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@390 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/RoundControl.java | 50 +++++++++++++-------------------- 1 file changed, 20 insertions(+), 30 deletions(-) (limited to 'src/jrummikub/control/RoundControl.java') diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index e1009af..5371b0c 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -47,9 +47,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; @@ -102,12 +102,11 @@ public class RoundControl { : BottomPanelType.COMPUTER_HAND_PANEL); view.getTablePanel().setStoneSets(clonedTable.clone()); - view.setCurrentPlayerName(roundState.getActivePlayer() - .getPlayerSettings().getName()); - view.setCurrentPlayerColor(roundState.getActivePlayer() - .getPlayerSettings().getColor()); - view.setCurrentPlayerHasLaidOut(roundState.getActivePlayer() - .getLaidOut()); + view.setCurrentPlayerName(roundState.getActivePlayer().getPlayerSettings() + .getName()); + view.setCurrentPlayerColor(roundState.getActivePlayer().getPlayerSettings() + .getColor()); + view.setCurrentPlayerHasLaidOut(roundState.getActivePlayer().getLaidOut()); if (!isHuman) startTurn(); @@ -132,11 +131,11 @@ public class RoundControl { view.getPlayerPanel().setEndTurnMode(turnMode); } turnControl = TurnControlFactory.getFactory( - roundState.getActivePlayer().getPlayerSettings() - .getTurnControlType()).create(); + roundState.getActivePlayer().getPlayerSettings().getTurnControlType()) + .create(); turnControl.setup(new ITurnControl.TurnInfo(clonedTable, clonedHand, - roundState.getActivePlayer().getLaidOut(), turnMode), - roundState.getGameSettings(), view); + roundState.getActivePlayer().getLaidOut(), turnMode), roundState + .getGameSettings(), view); turnControl.getEndOfTurnEvent().add(new IListener() { @Override public void handle() { @@ -156,10 +155,8 @@ public class RoundControl { void deal() { for (int i = 0; i < roundState.getPlayerCount(); i++) { IHand hand = roundState.getNthNextPlayer(i).getHand(); - for (int j = 0; j < roundState.getGameSettings() - .getNumberOfStonesDealt(); j++) { - hand.drop(roundState.getGameHeap().drawStone(), new Position(0, - 0)); + for (int j = 0; j < roundState.getGameSettings().getNumberOfStonesDealt(); j++) { + hand.drop(roundState.getGameHeap().drawStone(), new Position(0, 0)); } } } @@ -170,13 +167,11 @@ public class RoundControl { int totalValue = 0; for (StoneSet set : newSets) { - totalValue += set.classify(roundState.getGameSettings()) - .getSecond(); + totalValue += set.classify(roundState.getGameSettings()).getSecond(); } return totalValue == 0 - || totalValue >= roundState.getGameSettings() - .getInitialMeldThreshold(); + || totalValue >= roundState.getGameSettings().getInitialMeldThreshold(); } private void endOfTurn() { @@ -216,8 +211,7 @@ 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; } @@ -226,8 +220,7 @@ public class RoundControl { return; } } - Set tableDiff = tableDifference(roundState.getTable(), - clonedTable); + Set tableDiff = tableDifference(roundState.getTable(), clonedTable); roundState.setTable(clonedTable); @@ -243,8 +236,7 @@ public class RoundControl { } private void rejectMove() { - Set tableDiff = tableDifference(roundState.getTable(), - clonedTable); + Set tableDiff = tableDifference(roundState.getTable(), clonedTable); // deal penalty, reset roundState.getGameHeap().putBack(tableDiff); dealPenalty(tableDiff.size()); @@ -338,12 +330,10 @@ public class RoundControl { stonePoints = playerHand.isInitialMeldPossible(roundState .getGameSettings()) ? 200 : 100; } else { - stonePoints = playerHand.getStonePoints(roundState - .getGameSettings()); + stonePoints = playerHand.getStonePoints(roundState.getGameSettings()); } - bestScore = updateBestScore(bestScore, -stonePoints, - playerHand.getSize()); + bestScore = updateBestScore(bestScore, -stonePoints, playerHand.getSize()); points.add(-stonePoints); pointSum += stonePoints; -- cgit v1.2.3