summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-05 21:13:59 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-05 21:13:59 +0200
commit38f6f0dc24bd2755786f8a7947743feadb505b7f (patch)
tree4d8fbf1107dbeeceab0d332d4d5312a691a3ccbe /src/jrummikub/control
parent0b66e7d7631a0effca6fb03b8285e0d4372f5eef (diff)
downloadJRummikub-38f6f0dc24bd2755786f8a7947743feadb505b7f.tar
JRummikub-38f6f0dc24bd2755786f8a7947743feadb505b7f.zip
Add some endOfTurn handling to RoundControl
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@155 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/RoundControl.java34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index 8f8180d..00ebb6e 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -60,6 +60,7 @@ public class RoundControl {
endOfTurn();
}
});
+
turnControl.startTurn();
}
@@ -74,7 +75,27 @@ public class RoundControl {
}
private void endOfTurn() {
+ Set<Stone> tableDiff = tableDifference(gameState.getTable(), clonedTable);
+
+ if (!tableDiff.isEmpty()) { // Player has made a move
+ if (clonedTable.isValid()) {
+ gameState.setTable(clonedTable);
+
+ // TODO Win check
+ } else {
+ gameState.getGameHeap().putBack(tableDiff);
+ dealPenalty(tableDiff.size());
+ }
+ } else { // Player hasn't made a move
+ if (clonedTable.isValid()) {
+ gameState.setTable(clonedTable);
+ }
+
+ dealStone();
+ }
+ gameState.nextPlayer();
+ prepareTurn();
}
static Set<Stone> tableDifference(ITable oldTable, ITable newTable) {
@@ -94,15 +115,12 @@ public class RoundControl {
return ret;
}
- private void resetTable() {
-
- }
-
- private void preparePlayerTurn() {
-
- }
-
private void dealStone() {
+ // gameState.getActivePlayer().getHand().drop(object, position)
+ }
+ private void dealPenalty(int count) {
+ for (int i = 0; i < count + 3; ++i)
+ dealStone();
}
}