diff options
author | Bennet Gerlach <bennet_gerlach@web.de> | 2011-05-31 03:45:32 +0200 |
---|---|---|
committer | Bennet Gerlach <bennet_gerlach@web.de> | 2011-05-31 03:45:32 +0200 |
commit | d276b03c395e7c0e44740174168c0d98a8eaa06c (patch) | |
tree | 95642c255b484354769b7cb2ed4f9a65beb5a14e /src/jrummikub/control/RoundControl.java | |
parent | 278edc37a9861078d5ea1527695ef12766c0fb87 (diff) | |
download | JRummikub-d276b03c395e7c0e44740174168c0d98a8eaa06c.tar JRummikub-d276b03c395e7c0e44740174168c0d98a8eaa06c.zip |
AIUtil now needs game settings, both hand and player do not anymore
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@342 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/RoundControl.java')
-rw-r--r-- | src/jrummikub/control/RoundControl.java | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index 124b196..6a1befa 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -43,9 +43,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; @@ -89,10 +89,10 @@ public class RoundControl { } view.getTablePanel().setStoneSets(clonedTable); - view.setCurrentPlayerName(roundState.getActivePlayer() - .getPlayerSettings().getName()); - view.setCurrentPlayerColor(roundState.getActivePlayer() - .getPlayerSettings().getColor()); + view.setCurrentPlayerName(roundState.getActivePlayer().getPlayerSettings() + .getName()); + view.setCurrentPlayerColor(roundState.getActivePlayer().getPlayerSettings() + .getColor()); view.setHasLaidOut(roundState.getActivePlayer().getLaidOut()); if (!isHuman) @@ -106,15 +106,14 @@ public class RoundControl { .getTurnControlType() == HUMAN; boolean inspectOnly = roundState.getTurnNumber() < 1; boolean mayRedeal = inspectOnly - && roundState.getActivePlayer().getHand() - .getIdenticalStoneCount() >= 3; + && roundState.getActivePlayer().getHand().getIdenticalStoneCount() >= 3; if (isHuman) { view.getPlayerPanel().setEndTurnMode(inspectOnly, mayRedeal); } turnControl = TurnControlFactory.getFactory( - roundState.getActivePlayer().getPlayerSettings() - .getTurnControlType()).create(); + roundState.getActivePlayer().getPlayerSettings().getTurnControlType()) + .create(); turnControl.setup(roundState.getActivePlayer(), clonedTable, view, inspectOnly, mayRedeal); turnControl.getEndOfTurnEvent().add(new IListener() { @@ -136,10 +135,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)); } } } @@ -150,13 +147,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() { @@ -195,8 +190,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; } @@ -205,8 +199,7 @@ public class RoundControl { return; } } - Set<Stone> tableDiff = tableDifference(roundState.getTable(), - clonedTable); + Set<Stone> tableDiff = tableDifference(roundState.getTable(), clonedTable); roundState.setTable(clonedTable); @@ -222,8 +215,7 @@ 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()); @@ -310,13 +302,13 @@ public class RoundControl { int stonePoints = 0; if (!player.getLaidOut()) { - stonePoints = playerHand.isInitialMeldPossible() ? 200 : 100; + stonePoints = playerHand.isInitialMeldPossible(roundState + .getGameSettings()) ? 200 : 100; } else { - stonePoints = playerHand.getStonePoints(); + stonePoints = playerHand.getStonePoints(roundState.getGameSettings()); } - bestScore = updateBestScore(bestScore, -stonePoints, - playerHand.getSize()); + bestScore = updateBestScore(bestScore, -stonePoints, playerHand.getSize()); points.add(-stonePoints); pointSum += stonePoints; |