summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/RoundControl.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-20 04:22:23 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-20 04:22:23 +0200
commit39da662f0dc89af73e9b5a5faee2deb419c38e3b (patch)
tree11f4890c01d3f89d20adab6891a8cadc294601e3 /src/jrummikub/control/RoundControl.java
parenta97b8445a2bf0bd7f0e8b551ece08fba02275159 (diff)
downloadJRummikub-39da662f0dc89af73e9b5a5faee2deb419c38e3b.tar
JRummikub-39da662f0dc89af73e9b5a5faee2deb419c38e3b.zip
Don't show show the human player panel before the turn is started and the stones are displayed
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@507 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/RoundControl.java')
-rw-r--r--src/jrummikub/control/RoundControl.java59
1 files changed, 26 insertions, 33 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index 408c275..2936627 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -18,7 +18,6 @@ import jrummikub.model.IHand;
import jrummikub.model.IPlayer;
import jrummikub.model.IRoundState;
import jrummikub.model.ITable;
-import jrummikub.model.Player;
import jrummikub.model.PlayerSettings;
import jrummikub.model.Position;
import jrummikub.model.Score;
@@ -56,9 +55,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;
@@ -152,20 +151,16 @@ public class RoundControl {
clonedTable = (ITable) roundState.getTable().clone();
clonedHand = (IHand) roundState.getActivePlayer().getHand().clone();
- if (isHuman) {
- view.setBottomPanel(oneHuman ? BottomPanelType.HUMAN_HAND_PANEL
- : BottomPanelType.START_TURN_PANEL);
- } else {
- view.setBottomPanel(BottomPanelType.NONHUMAN_HAND_PANEL);
+ if (isHuman && !oneHuman) {
+ view.setBottomPanel(BottomPanelType.START_TURN_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());
turnControl = createTurnControl(roundState.getActivePlayer()
.getPlayerSettings());
@@ -179,6 +174,9 @@ public class RoundControl {
boolean isHuman = roundState.getActivePlayer().getPlayerSettings()
.getType() == HUMAN;
+ view.setBottomPanel(isHuman ? BottomPanelType.HUMAN_HAND_PANEL
+ : BottomPanelType.NONHUMAN_HAND_PANEL);
+
TurnMode turnMode = TurnMode.NORMAL_TURN;
if (roundState.getTurnNumber() < 1) {
@@ -194,8 +192,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) {
@@ -237,10 +235,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));
}
}
@@ -253,13 +249,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();
}
protected void endOfTurn(ITable newTable) {
@@ -269,9 +263,10 @@ public class RoundControl {
turnControl = null;
roundState.getActivePlayer().setLastTurnInvalid(false);
- roundState.getActivePlayer().setLastTurnStoneCount(
- roundState.getActivePlayer().getHand().getSize()
- - clonedHand.getSize());
+ roundState.getActivePlayer()
+ .setLastTurnStoneCount(
+ roundState.getActivePlayer().getHand().getSize()
+ - clonedHand.getSize());
roundState.getActivePlayer().setHand(clonedHand);
boolean goToNextPlayer = true;
@@ -290,8 +285,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));
@@ -484,12 +479,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;