summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/turn
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-19 01:40:14 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-19 01:40:14 +0200
commitf641b76bcac15871458e649cdde02331c2cef882 (patch)
treeb7ded99b42dfe7fa53ce76d80b0267b14f07ab89 /src/jrummikub/control/turn
parentc7069227f324d42e3c1f2456f1ff6876455379fd (diff)
downloadJRummikub-f641b76bcac15871458e649cdde02331c2cef882.tar
JRummikub-f641b76bcac15871458e649cdde02331c2cef882.zip
Added table update event to turn control and round control
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@477 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control/turn')
-rw-r--r--src/jrummikub/control/turn/AbstractTurnControl.java9
-rw-r--r--src/jrummikub/control/turn/HumanTurnControl.java16
-rw-r--r--src/jrummikub/control/turn/ITurnControl.java3
3 files changed, 22 insertions, 6 deletions
diff --git a/src/jrummikub/control/turn/AbstractTurnControl.java b/src/jrummikub/control/turn/AbstractTurnControl.java
index d6d0271..fd88370 100644
--- a/src/jrummikub/control/turn/AbstractTurnControl.java
+++ b/src/jrummikub/control/turn/AbstractTurnControl.java
@@ -6,9 +6,12 @@ import java.util.List;
import jrummikub.control.ITurnTimer;
import jrummikub.control.TurnTimer;
import jrummikub.model.GameSettings;
+import jrummikub.model.ITable;
import jrummikub.util.Connection;
import jrummikub.util.Event;
+import jrummikub.util.Event1;
import jrummikub.util.IEvent;
+import jrummikub.util.IEvent1;
import jrummikub.util.IListener;
import jrummikub.view.IView;
@@ -18,6 +21,7 @@ import jrummikub.view.IView;
public abstract class AbstractTurnControl implements ITurnControl {
protected Event endOfTurnEvent = new Event();
protected Event redealEvent = new Event();
+ protected Event1<ITable> tableUpdateEvent = new Event1<ITable>();
protected TurnInfo turnInfo;
protected GameSettings settings;
protected IView view;
@@ -33,6 +37,11 @@ public abstract class AbstractTurnControl implements ITurnControl {
public IEvent getRedealEvent() {
return redealEvent;
}
+
+ @Override
+ public IEvent1<ITable> getTableUpdateEvent() {
+ return tableUpdateEvent;
+ }
protected void pauseTurn() {
timer.stopTimer();
diff --git a/src/jrummikub/control/turn/HumanTurnControl.java b/src/jrummikub/control/turn/HumanTurnControl.java
index a9a73d7..3efad2f 100644
--- a/src/jrummikub/control/turn/HumanTurnControl.java
+++ b/src/jrummikub/control/turn/HumanTurnControl.java
@@ -297,6 +297,14 @@ public class HumanTurnControl extends AbstractTurnControl {
}
}
+ private void updateTable() {
+ view.getTablePanel().setStoneSets(turnInfo.getTable());
+ view.getHandPanel().setStones(turnInfo.getHand());
+ view.setSelectedStones(selectedStones);
+
+ tableUpdateEvent.emit(turnInfo.getTable());
+ }
+
private void tableClick(Position position) {
if (selectedStones.isEmpty()) {
return;
@@ -309,9 +317,7 @@ public class HumanTurnControl extends AbstractTurnControl {
.getY() - 0.5f));
selectedStones.clear();
- view.getTablePanel().setStoneSets(turnInfo.getTable());
- view.getHandPanel().setStones(turnInfo.getHand());
- view.setSelectedStones(selectedStones);
+ updateTable();
}
private void tableSetClick(Stone stone, boolean collect) {
@@ -434,9 +440,7 @@ public class HumanTurnControl extends AbstractTurnControl {
selectedStones.clear();
- view.getTablePanel().setStoneSets(turnInfo.getTable());
- view.getHandPanel().setStones(turnInfo.getHand());
- view.setSelectedStones(selectedStones);
+ updateTable();
}
private void endOfTurn(boolean redeal) {
diff --git a/src/jrummikub/control/turn/ITurnControl.java b/src/jrummikub/control/turn/ITurnControl.java
index 63290d5..0039a42 100644
--- a/src/jrummikub/control/turn/ITurnControl.java
+++ b/src/jrummikub/control/turn/ITurnControl.java
@@ -4,6 +4,7 @@ import jrummikub.model.GameSettings;
import jrummikub.model.IHand;
import jrummikub.model.ITable;
import jrummikub.util.IEvent;
+import jrummikub.util.IEvent1;
import jrummikub.view.IView;
/**
@@ -48,6 +49,8 @@ public interface ITurnControl {
*/
public void abortTurn();
+ public IEvent1<ITable> getTableUpdateEvent();
+
/**
* The TurnInfo class encapsulates all information concerning the current turn
*/