diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-06-20 03:19:02 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-06-20 03:19:02 +0200 |
commit | 8a3e4c3e26cba022dfaf06f8c7cd31b33b0889e9 (patch) | |
tree | 3b32ee8a52f84138a05a2d3eef74cec1a3c15a2d /src/jrummikub/control | |
parent | 4df5c0e665991dd19a2f25ee513c3ff85a672c55 (diff) | |
download | JRummikub-8a3e4c3e26cba022dfaf06f8c7cd31b33b0889e9.tar JRummikub-8a3e4c3e26cba022dfaf06f8c7cd31b33b0889e9.zip |
Finished side panel info
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@501 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r-- | src/jrummikub/control/GameControl.java | 2 | ||||
-rw-r--r-- | src/jrummikub/control/RoundControl.java | 60 |
2 files changed, 38 insertions, 24 deletions
diff --git a/src/jrummikub/control/GameControl.java b/src/jrummikub/control/GameControl.java index 7e95c08..66a96b6 100644 --- a/src/jrummikub/control/GameControl.java +++ b/src/jrummikub/control/GameControl.java @@ -97,7 +97,6 @@ public class GameControl { * Game gets started by initializing the first Round */ public void startGame() { - view.showSidePanel(true); startRound(); } @@ -184,6 +183,7 @@ public class GameControl { } private void showScorePanel() { + view.showSidePanel(false); view.setBottomPanel(BottomPanelType.WIN_PANEL); view.getScorePanel().setPlayers(gameSettings.getPlayerList()); diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index e18ce2e..ac3acf3 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -56,9 +56,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; @@ -93,7 +93,7 @@ public class RoundControl { * Continue a saved round after loading */ public void continueRound() { - + connections.add(view.getStartTurnEvent().add(new IListener() { @Override public void handle() { @@ -144,7 +144,7 @@ public class RoundControl { protected void doPrepareTurn() { updateSidePanel(); - + boolean isHuman = roundState.getActivePlayer().getPlayerSettings() .getType() == HUMAN; boolean oneHuman = roundState.getGameSettings().oneHuman(); @@ -160,11 +160,12 @@ public class RoundControl { } 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()); turnControl = createTurnControl(roundState.getActivePlayer() .getPlayerSettings()); @@ -193,8 +194,8 @@ public class RoundControl { } 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 IListener1<ITable>() { @Override public void handle(ITable newTable) { @@ -211,16 +212,17 @@ public class RoundControl { turnControl.startTurn(); } - + private void updateSidePanel() { view.showSidePanel(true); view.getSidePanel().setGameSettings(roundState.getGameSettings()); List<IPlayer> players = new ArrayList<IPlayer>(); - for (int i = 1; i < roundState.getPlayerCount(); i ++) { + for (int i = 1; i < roundState.getPlayerCount(); i++) { players.add(roundState.getNthNextPlayer(-i)); } view.getSidePanel().setPlayers(players); - view.getSidePanel().setHeapCapacity(roundState.getGameSettings().getTotalStones()); + view.getSidePanel().setHeapCapacity( + roundState.getGameSettings().getTotalStones()); view.getSidePanel().setHeapSize(roundState.getGameHeap().getSize()); } @@ -235,11 +237,13 @@ 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)); } } - + } private boolean laidOutValidPoints() { @@ -248,11 +252,13 @@ 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(); } protected void endOfTurn(ITable newTable) { @@ -261,6 +267,11 @@ public class RoundControl { turnControl = null; + roundState.getActivePlayer().setLastTurnInvalid(false); + roundState.getActivePlayer().setLastTurnStoneCount( + roundState.getActivePlayer().getHand().getSize() + - clonedHand.getSize()); + roundState.getActivePlayer().setHand(clonedHand); boolean goToNextPlayer = true; lastTurnNotEnoughPoints = false; @@ -278,8 +289,8 @@ public class RoundControl { if (lastTurnNotEnoughPoints) { view.setInitialMeldError(roundState.getGameSettings() .getInitialMeldThreshold()); - view.setInvalidStoneSets(tableSetDifference(roundState.getTable(), - newTable)); + view.setInvalidStoneSets(tableSetDifference( + roundState.getTable(), newTable)); } else if (lastTurnMeldError) { view.setInitialMeldFirstError(); view.setInvalidStoneSets(touchedStoneSets(newTable)); @@ -379,6 +390,7 @@ public class RoundControl { Set<Stone> tableDiff = tableDifference(roundState.getTable(), newTable); // deal penalty, reset roundState.getGameHeap().putBack(tableDiff); + roundState.getActivePlayer().setLastTurnInvalid(true); dealPenalty(tableDiff.size()); } @@ -471,10 +483,12 @@ 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; |