summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/RoundControl.java
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-08 16:29:13 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-08 16:29:13 +0200
commit3ff911ab930cb87f90307b9a82dafc4d0b5fe305 (patch)
tree5019f591188fd57d07c16a3e03820876f2e08f48 /src/jrummikub/control/RoundControl.java
parentce1b716e128bef53b140344bf1e58960fa32cba6 (diff)
downloadJRummikub-3ff911ab930cb87f90307b9a82dafc4d0b5fe305.tar
JRummikub-3ff911ab930cb87f90307b9a82dafc4d0b5fe305.zip
man kann speichern und laden, nur nicht während eines laufenden spiels laden
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@386 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/RoundControl.java')
-rw-r--r--src/jrummikub/control/RoundControl.java53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index 5e85167..4fadc15 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;
@@ -70,7 +70,10 @@ public class RoundControl {
*/
public void startRound() {
deal();
+ continueRound();
+ }
+ public void continueRound() {
connections.add(view.getStartTurnEvent().add(new IListener() {
@Override
public void handle() {
@@ -91,11 +94,12 @@ 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();
@@ -120,11 +124,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() {
@@ -144,8 +148,10 @@ 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));
}
}
}
@@ -156,11 +162,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();
}
private void endOfTurn() {
@@ -200,7 +208,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;
}
@@ -209,7 +218,8 @@ public class RoundControl {
return;
}
}
- Set<Stone> tableDiff = tableDifference(roundState.getTable(), clonedTable);
+ Set<Stone> tableDiff = tableDifference(roundState.getTable(),
+ clonedTable);
roundState.setTable(clonedTable);
@@ -225,7 +235,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());
@@ -315,10 +326,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;