summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/RoundControl.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-08 21:58:16 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-08 21:58:16 +0200
commit45d5b3ae10ed8cfbecb5489636093c6fb0576970 (patch)
tree1aa1c012f46fe204d997e8c6896940800f5461bb /src/jrummikub/control/RoundControl.java
parent2e376414b941da3c6fa3c20ddad085c695175542 (diff)
downloadJRummikub-45d5b3ae10ed8cfbecb5489636093c6fb0576970.tar
JRummikub-45d5b3ae10ed8cfbecb5489636093c6fb0576970.zip
Implement pause function
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@390 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/RoundControl.java')
-rw-r--r--src/jrummikub/control/RoundControl.java50
1 files changed, 20 insertions, 30 deletions
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<Stone> tableDiff = tableDifference(roundState.getTable(),
- clonedTable);
+ Set<Stone> tableDiff = tableDifference(roundState.getTable(), clonedTable);
roundState.setTable(clonedTable);
@@ -243,8 +236,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());
@@ -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;