Fixed drawing single cards before the initial meld

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@269 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Jannis Harder 2011-05-24 22:33:08 +02:00
parent 21f866d2ea
commit 79bffeba5d

View file

@ -109,7 +109,7 @@ public class RoundControl {
} }
} }
private boolean laidOutEnough() { private boolean laidOutValidPoints() {
List<StoneSet> newSets = tableSetDifference(roundState.getTable(), List<StoneSet> newSets = tableSetDifference(roundState.getTable(),
clonedTable); clonedTable);
@ -118,13 +118,14 @@ public class RoundControl {
totalValue += set.classify().getSecond(); totalValue += set.classify().getSecond();
} }
return totalValue >= roundState.getGameSettings() return totalValue == 0
.getInitialMeldThreshold(); || totalValue >= roundState.getGameSettings()
.getInitialMeldThreshold();
} }
private void endOfTurn() { private void endOfTurn() {
checkTurn(); checkTurn();
if (roundState.getLastPlayer() == null) { if (roundState.getLastPlayer() == null) {
if (roundState.getGameHeap().getSize() == 0) { if (roundState.getGameHeap().getSize() == 0) {
roundState.setLastPlayer(roundState.getNthNextPlayer(-1)); roundState.setLastPlayer(roundState.getNthNextPlayer(-1));
@ -143,26 +144,27 @@ public class RoundControl {
prepareTurn(); prepareTurn();
} }
} }
private void checkTurn() { private void checkTurn() {
if (!clonedTable.isValid()) { if (!clonedTable.isValid()) {
rejectMove(); rejectMove();
return; return;
} }
if (!roundState.getActivePlayer().getLaidOut()) { if (!roundState.getActivePlayer().getLaidOut()) {
// Player touched forbidden stones // Player touched forbidden stones
if (!tableSetDifference(clonedTable, roundState.getTable()).isEmpty()) { if (!tableSetDifference(clonedTable, roundState.getTable())
.isEmpty()) {
rejectMove(); rejectMove();
return; return;
} }
if (!laidOutEnough()) { if (!laidOutValidPoints()) {
rejectMove(); rejectMove();
return; return;
} }
} }
Set<Stone> tableDiff = tableDifference(roundState.getTable(), Set<Stone> tableDiff = tableDifference(roundState.getTable(),
clonedTable); clonedTable);
roundState.setTable(clonedTable); roundState.setTable(clonedTable);
if (tableDiff.isEmpty()) { if (tableDiff.isEmpty()) {
@ -182,7 +184,7 @@ public class RoundControl {
// deal penalty, reset // deal penalty, reset
roundState.getGameHeap().putBack(tableDiff); roundState.getGameHeap().putBack(tableDiff);
dealPenalty(tableDiff.size()); dealPenalty(tableDiff.size());
} }
static Set<Stone> tableDifference(ITable oldTable, ITable newTable) { static Set<Stone> tableDifference(ITable oldTable, ITable newTable) {