diff options
author | Bennet Gerlach <bennet_gerlach@web.de> | 2011-05-05 20:22:14 +0200 |
---|---|---|
committer | Bennet Gerlach <bennet_gerlach@web.de> | 2011-05-05 20:22:14 +0200 |
commit | 0b66e7d7631a0effca6fb03b8285e0d4372f5eef (patch) | |
tree | db2e9cf29e221b2288efbfd1b6c88d1100bd9afd | |
parent | 8c65bafde4ec05718433791915bcbf3c838e90a6 (diff) | |
download | JRummikub-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
-rw-r--r-- | src/jrummikub/control/TurnControl.java | 31 |
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(); |