summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/RoundControl.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-16 22:01:02 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-16 22:01:02 +0200
commit604ef91282ad234130b1d46569efd486ab6c5024 (patch)
tree53fab92b75551c8acc8979d77ffa8351f788ae90 /src/jrummikub/control/RoundControl.java
parent57227570fe6bf9eb5ecf17c32a1db1a7bbed85e3 (diff)
downloadJRummikub-604ef91282ad234130b1d46569efd486ab6c5024.tar
JRummikub-604ef91282ad234130b1d46569efd486ab6c5024.zip
Fix dealing stones for more than 2 rows
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@244 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/RoundControl.java')
-rw-r--r--src/jrummikub/control/RoundControl.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index 7cea255..dad2e30 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -149,17 +149,26 @@ public class RoundControl {
return ret;
}
- void dealStone() {
- gameState
- .getActivePlayer()
- .getHand()
- .drop(gameState.getGameHeap().drawStone(),
- new Position(Hand.WIDTH - 1, Hand.HEIGHT - 1));
+ void dealStones(int count) {
+ IHand hand = gameState.getActivePlayer().getHand();
+ int rowCount = hand.getRowCount();
+
+ for (int i = 0; i < count; ++i) {
+ if (hand.getFreeRowSpace(rowCount - 1) == 0) {
+ rowCount++;
+ }
+
+ hand.drop(gameState.getGameHeap().drawStone(), new Position(
+ Hand.WIDTH - 1, rowCount - 1));
+ }
+ }
+
+ private void dealStone() {
+ dealStones(1);
}
private void dealPenalty(int count) {
- for (int i = 0; i < count + 3; ++i)
- dealStone();
+ dealStones(count + 3);
}
private void win() {