summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/TurnControl.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-09 00:33:34 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-09 00:33:34 +0200
commitb86571cf832ff13010798f3607eea6ad0ef039d0 (patch)
treed39b22dc07ad068083181d701a8d8aad95a10c85 /src/jrummikub/control/TurnControl.java
parentb9fbe279c3d6e750f7c90ad0b244d315c9744bb2 (diff)
downloadJRummikub-b86571cf832ff13010798f3607eea6ad0ef039d0.tar
JRummikub-b86571cf832ff13010798f3607eea6ad0ef039d0.zip
Allow laying out stone sets
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@180 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/TurnControl.java')
-rw-r--r--src/jrummikub/control/TurnControl.java71
1 files changed, 59 insertions, 12 deletions
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java
index a71e56c..3213fd6 100644
--- a/src/jrummikub/control/TurnControl.java
+++ b/src/jrummikub/control/TurnControl.java
@@ -12,6 +12,7 @@ import jrummikub.util.Connection;
import jrummikub.util.Event;
import jrummikub.util.IEvent;
import jrummikub.util.IListener;
+import jrummikub.util.IListener1;
import jrummikub.util.IListener2;
import jrummikub.view.IView;
@@ -59,8 +60,7 @@ public class TurnControl {
@Override
public void handle(Stone stone, Boolean collect) {
- handStoneClick(stone, collect);
-
+ stoneClick(stone, collect);
}
}));
@@ -72,6 +72,36 @@ public class TurnControl {
collectionStoneClick(stone, collect);
}
}));
+ connections.add(view.getTablePanel().getStoneClickEvent()
+ .add(new IListener2<Stone, Boolean>() {
+
+ @Override
+ public void handle(Stone stone, Boolean collect) {
+ stoneClick(stone, collect);
+ }
+ }));
+
+ connections.add(view.getTablePanel().getClickEvent()
+ .add(new IListener1<Position>() {
+ @Override
+ public void handle(Position pos) {
+ tableClick(pos);
+ }
+ }));
+ connections.add(view.getTablePanel().getLeftConnectorClickEvent()
+ .add(new IListener1<StoneSet>() {
+ @Override
+ public void handle(StoneSet set) {
+ leftConnectorClick(set);
+ }
+ }));
+ connections.add(view.getTablePanel().getRightConnectorClickEvent()
+ .add(new IListener1<StoneSet>() {
+ @Override
+ public void handle(StoneSet set) {
+ rightConnectorClick(set);
+ }
+ }));
view.getPlayerPanel().getHandPanel().setStones(hand.clone());
view.enableStartTurnPanel(false);
@@ -87,7 +117,7 @@ public class TurnControl {
}
- private void handStoneClick(Stone stone, boolean collect) {
+ private void stoneClick(Stone stone, boolean collect) {
if (collect) {
if (!selectedStones.remove(stone)) {
selectedStones.add(stone);
@@ -109,17 +139,34 @@ public class TurnControl {
view.setSelectedStones(selectedStones);
}
-
- private void leftConnectorClick(StoneSet set){
-
+
+ private void pickUpSelectedStones() {
+ for (Stone stone : selectedStones) {
+ hand.pickUp(stone);
+ table.pickUpStone(stone);
+ }
+ }
+
+ private void tableClick(Position position) {
+ if (selectedStones.isEmpty()) {
+ return;
+ }
+
+ pickUpSelectedStones();
+ table.drop(new StoneSet(selectedStones), position);
+ selectedStones.clear();
+
+ view.getTablePanel().setStoneSets(table);
+ view.getPlayerPanel().getHandPanel().setStones(hand);
+ view.setSelectedStones(selectedStones);
}
-
- private void rightConnectorClick(StoneSet set){
-
+
+ private void leftConnectorClick(StoneSet set) {
+
}
-
- private void tableClick(Position position){
-
+
+ private void rightConnectorClick(StoneSet set) {
+
}
private void endOfTurn() {