summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/RoundControl.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index dad2e30..c46d402 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -33,9 +33,9 @@ public class RoundControl {
* Create a new RoundControl using the given gameState and view
*
* @param gameState
- * initial game state
+ * initial game state
* @param view
- * view used for user interaction
+ * view used for user interaction
*/
public RoundControl(IGameState gameState, IView view) {
this.gameState = gameState;
@@ -99,14 +99,17 @@ public class RoundControl {
for (int i = 0; i < gameState.getPlayerCount(); i++) {
IHand hand = gameState.getNthNextPlayer(i).getHand();
for (int j = 0; j < 7; j++) {
- hand.drop(gameState.getGameHeap().drawStone(), new Position(j, 0));
- hand.drop(gameState.getGameHeap().drawStone(), new Position(j, 1));
+ hand.drop(gameState.getGameHeap().drawStone(), new Position(j,
+ 0));
+ hand.drop(gameState.getGameHeap().drawStone(), new Position(j,
+ 1));
}
}
}
private void endOfTurn() {
- Set<Stone> tableDiff = tableDifference(gameState.getTable(), clonedTable);
+ Set<Stone> tableDiff = tableDifference(gameState.getTable(),
+ clonedTable);
if (!tableDiff.isEmpty()) { // Player has made a move
if (clonedTable.isValid()) {
@@ -145,7 +148,18 @@ public class RoundControl {
ret.remove(stone);
}
}
+ return ret;
+ }
+ static List<StoneSet> tableSetDifference(ITable oldTable, ITable newTable) {
+ List<StoneSet> ret = new ArrayList<StoneSet>();
+
+ for (Pair<StoneSet, Position> entry : newTable) {
+ ret.add(entry.getFirst());
+ }
+ for (Pair<StoneSet, Position> entry : oldTable) {
+ ret.remove(entry.getFirst());
+ }
return ret;
}