summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
authorBennet Gerlach <bennet_gerlach@web.de>2011-05-05 20:22:14 +0200
committerBennet Gerlach <bennet_gerlach@web.de>2011-05-05 20:22:14 +0200
commit0b66e7d7631a0effca6fb03b8285e0d4372f5eef (patch)
treedb2e9cf29e221b2288efbfd1b6c88d1100bd9afd /src/jrummikub/control
parent8c65bafde4ec05718433791915bcbf3c838e90a6 (diff)
downloadJRummikub-0b66e7d7631a0effca6fb03b8285e0d4372f5eef.tar
JRummikub-0b66e7d7631a0effca6fb03b8285e0d4372f5eef.zip
Implemented stone clicking on hand
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@154 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/TurnControl.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java
index 840b0e9..fbe026d 100644
--- a/src/jrummikub/control/TurnControl.java
+++ b/src/jrummikub/control/TurnControl.java
@@ -5,10 +5,12 @@ import java.util.List;
import jrummikub.model.IHand;
import jrummikub.model.ITable;
+import jrummikub.model.Stone;
import jrummikub.util.Connection;
import jrummikub.util.Event;
import jrummikub.util.IEvent;
import jrummikub.util.IListener;
+import jrummikub.util.IListener2;
import jrummikub.view.IView;
public class TurnControl {
@@ -16,6 +18,9 @@ public class TurnControl {
private ITable table;
private ITurnTimer timer;
private IView view;
+
+ private List<Stone> selectedStones = new ArrayList<Stone>();
+
private Event endOfTurnEvent = new Event();
List<Connection> connections = new ArrayList<Connection>();
@@ -44,7 +49,18 @@ public class TurnControl {
}
};
connections.add(timer.getTimeRunOutEvent().add(endOfTurnListener));
- connections.add(view.getPlayerPanel().getEndTurnEvent().add(endOfTurnListener));
+ connections.add(view.getPlayerPanel().getEndTurnEvent()
+ .add(endOfTurnListener));
+
+ connections.add(view.getPlayerPanel().getHandPanel().getStoneClickEvent()
+ .add(new IListener2<Stone, Boolean>() {
+
+ @Override
+ public void handle(Stone stone, Boolean collect) {
+ handStoneClick(stone, collect);
+
+ }
+ }));
view.getPlayerPanel().getHandPanel().setStones(hand.clone());
view.enableStartTurnPanel(false);
@@ -60,6 +76,19 @@ public class TurnControl {
}
+ private void handStoneClick(Stone stone, boolean collect) {
+ if (collect) {
+ if (!selectedStones.remove(stone)) {
+ selectedStones.add(stone);
+ }
+ } else {
+ selectedStones.clear();
+ selectedStones.add(stone);
+ }
+
+ view.setSelectedStones(selectedStones);
+ }
+
private void endOfTurn() {
timer.stopTimer();
endOfTurnEvent.emit();