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
This commit is contained in:
parent
a97b8445a2
commit
39da662f0d
1 changed files with 26 additions and 33 deletions
|
@ -18,7 +18,6 @@ import jrummikub.model.IHand;
|
||||||
import jrummikub.model.IPlayer;
|
import jrummikub.model.IPlayer;
|
||||||
import jrummikub.model.IRoundState;
|
import jrummikub.model.IRoundState;
|
||||||
import jrummikub.model.ITable;
|
import jrummikub.model.ITable;
|
||||||
import jrummikub.model.Player;
|
|
||||||
import jrummikub.model.PlayerSettings;
|
import jrummikub.model.PlayerSettings;
|
||||||
import jrummikub.model.Position;
|
import jrummikub.model.Position;
|
||||||
import jrummikub.model.Score;
|
import jrummikub.model.Score;
|
||||||
|
@ -56,9 +55,9 @@ public class RoundControl {
|
||||||
* Create a new RoundControl using the given gameState and view
|
* Create a new RoundControl using the given gameState and view
|
||||||
*
|
*
|
||||||
* @param roundState
|
* @param roundState
|
||||||
* initial round state
|
* initial round state
|
||||||
* @param view
|
* @param view
|
||||||
* view used for user interaction
|
* view used for user interaction
|
||||||
*/
|
*/
|
||||||
public RoundControl(IRoundState roundState, IView view) {
|
public RoundControl(IRoundState roundState, IView view) {
|
||||||
this.roundState = roundState;
|
this.roundState = roundState;
|
||||||
|
@ -152,20 +151,16 @@ public class RoundControl {
|
||||||
clonedTable = (ITable) roundState.getTable().clone();
|
clonedTable = (ITable) roundState.getTable().clone();
|
||||||
clonedHand = (IHand) roundState.getActivePlayer().getHand().clone();
|
clonedHand = (IHand) roundState.getActivePlayer().getHand().clone();
|
||||||
|
|
||||||
if (isHuman) {
|
if (isHuman && !oneHuman) {
|
||||||
view.setBottomPanel(oneHuman ? BottomPanelType.HUMAN_HAND_PANEL
|
view.setBottomPanel(BottomPanelType.START_TURN_PANEL);
|
||||||
: BottomPanelType.START_TURN_PANEL);
|
|
||||||
} else {
|
|
||||||
view.setBottomPanel(BottomPanelType.NONHUMAN_HAND_PANEL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view.getTablePanel().setStoneSets(clonedTable.clone());
|
view.getTablePanel().setStoneSets(clonedTable.clone());
|
||||||
view.setCurrentPlayerName(roundState.getActivePlayer()
|
view.setCurrentPlayerName(roundState.getActivePlayer().getPlayerSettings()
|
||||||
.getPlayerSettings().getName());
|
.getName());
|
||||||
view.setCurrentPlayerColor(roundState.getActivePlayer()
|
view.setCurrentPlayerColor(roundState.getActivePlayer().getPlayerSettings()
|
||||||
.getPlayerSettings().getColor());
|
.getColor());
|
||||||
view.setCurrentPlayerHasLaidOut(roundState.getActivePlayer()
|
view.setCurrentPlayerHasLaidOut(roundState.getActivePlayer().getLaidOut());
|
||||||
.getLaidOut());
|
|
||||||
|
|
||||||
turnControl = createTurnControl(roundState.getActivePlayer()
|
turnControl = createTurnControl(roundState.getActivePlayer()
|
||||||
.getPlayerSettings());
|
.getPlayerSettings());
|
||||||
|
@ -179,6 +174,9 @@ public class RoundControl {
|
||||||
boolean isHuman = roundState.getActivePlayer().getPlayerSettings()
|
boolean isHuman = roundState.getActivePlayer().getPlayerSettings()
|
||||||
.getType() == HUMAN;
|
.getType() == HUMAN;
|
||||||
|
|
||||||
|
view.setBottomPanel(isHuman ? BottomPanelType.HUMAN_HAND_PANEL
|
||||||
|
: BottomPanelType.NONHUMAN_HAND_PANEL);
|
||||||
|
|
||||||
TurnMode turnMode = TurnMode.NORMAL_TURN;
|
TurnMode turnMode = TurnMode.NORMAL_TURN;
|
||||||
|
|
||||||
if (roundState.getTurnNumber() < 1) {
|
if (roundState.getTurnNumber() < 1) {
|
||||||
|
@ -194,8 +192,8 @@ public class RoundControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
turnControl.setup(new ITurnControl.TurnInfo(clonedTable, clonedHand,
|
turnControl.setup(new ITurnControl.TurnInfo(clonedTable, clonedHand,
|
||||||
roundState.getActivePlayer().getLaidOut(), turnMode),
|
roundState.getActivePlayer().getLaidOut(), turnMode), roundState
|
||||||
roundState.getGameSettings(), view);
|
.getGameSettings(), view);
|
||||||
turnControl.getEndOfTurnEvent().add(new IListener1<ITable>() {
|
turnControl.getEndOfTurnEvent().add(new IListener1<ITable>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ITable newTable) {
|
public void handle(ITable newTable) {
|
||||||
|
@ -237,10 +235,8 @@ public class RoundControl {
|
||||||
void deal() {
|
void deal() {
|
||||||
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
||||||
IHand hand = roundState.getNthNextPlayer(i).getHand();
|
IHand hand = roundState.getNthNextPlayer(i).getHand();
|
||||||
for (int j = 0; j < roundState.getGameSettings()
|
for (int j = 0; j < roundState.getGameSettings().getNumberOfStonesDealt(); j++) {
|
||||||
.getNumberOfStonesDealt(); j++) {
|
hand.drop(roundState.getGameHeap().drawStone(), new Position(0, 0));
|
||||||
hand.drop(roundState.getGameHeap().drawStone(), new Position(0,
|
|
||||||
0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,13 +249,11 @@ public class RoundControl {
|
||||||
|
|
||||||
int totalValue = 0;
|
int totalValue = 0;
|
||||||
for (StoneSet set : newSets) {
|
for (StoneSet set : newSets) {
|
||||||
totalValue += set.classify(roundState.getGameSettings())
|
totalValue += set.classify(roundState.getGameSettings()).getSecond();
|
||||||
.getSecond();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalValue == 0
|
return totalValue == 0
|
||||||
|| totalValue >= roundState.getGameSettings()
|
|| totalValue >= roundState.getGameSettings().getInitialMeldThreshold();
|
||||||
.getInitialMeldThreshold();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void endOfTurn(ITable newTable) {
|
protected void endOfTurn(ITable newTable) {
|
||||||
|
@ -269,9 +263,10 @@ public class RoundControl {
|
||||||
turnControl = null;
|
turnControl = null;
|
||||||
|
|
||||||
roundState.getActivePlayer().setLastTurnInvalid(false);
|
roundState.getActivePlayer().setLastTurnInvalid(false);
|
||||||
roundState.getActivePlayer().setLastTurnStoneCount(
|
roundState.getActivePlayer()
|
||||||
roundState.getActivePlayer().getHand().getSize()
|
.setLastTurnStoneCount(
|
||||||
- clonedHand.getSize());
|
roundState.getActivePlayer().getHand().getSize()
|
||||||
|
- clonedHand.getSize());
|
||||||
|
|
||||||
roundState.getActivePlayer().setHand(clonedHand);
|
roundState.getActivePlayer().setHand(clonedHand);
|
||||||
boolean goToNextPlayer = true;
|
boolean goToNextPlayer = true;
|
||||||
|
@ -290,8 +285,8 @@ public class RoundControl {
|
||||||
if (lastTurnNotEnoughPoints) {
|
if (lastTurnNotEnoughPoints) {
|
||||||
view.setInitialMeldError(roundState.getGameSettings()
|
view.setInitialMeldError(roundState.getGameSettings()
|
||||||
.getInitialMeldThreshold());
|
.getInitialMeldThreshold());
|
||||||
view.setInvalidStoneSets(tableSetDifference(
|
view.setInvalidStoneSets(tableSetDifference(roundState.getTable(),
|
||||||
roundState.getTable(), newTable));
|
newTable));
|
||||||
} else if (lastTurnMeldError) {
|
} else if (lastTurnMeldError) {
|
||||||
view.setInitialMeldFirstError();
|
view.setInitialMeldFirstError();
|
||||||
view.setInvalidStoneSets(touchedStoneSets(newTable));
|
view.setInvalidStoneSets(touchedStoneSets(newTable));
|
||||||
|
@ -484,12 +479,10 @@ public class RoundControl {
|
||||||
stonePoints = playerHand.isInitialMeldPossible(roundState
|
stonePoints = playerHand.isInitialMeldPossible(roundState
|
||||||
.getGameSettings()) ? 200 : 100;
|
.getGameSettings()) ? 200 : 100;
|
||||||
} else {
|
} else {
|
||||||
stonePoints = playerHand.getStonePoints(roundState
|
stonePoints = playerHand.getStonePoints(roundState.getGameSettings());
|
||||||
.getGameSettings());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bestScore = updateBestScore(bestScore, -stonePoints,
|
bestScore = updateBestScore(bestScore, -stonePoints, playerHand.getSize());
|
||||||
playerHand.getSize());
|
|
||||||
|
|
||||||
points.add(-stonePoints);
|
points.add(-stonePoints);
|
||||||
pointSum += stonePoints;
|
pointSum += stonePoints;
|
||||||
|
|
Reference in a new issue