summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jrummikub/control/RoundControl.java13
-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
4 files changed, 35 insertions, 6 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index 174cc9a..d8435af 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -26,6 +26,7 @@ import jrummikub.util.Event1;
import jrummikub.util.IEvent;
import jrummikub.util.IEvent1;
import jrummikub.util.IListener;
+import jrummikub.util.IListener1;
import jrummikub.util.Pair;
import jrummikub.view.IView;
import jrummikub.view.IView.BottomPanelType;
@@ -40,6 +41,7 @@ public class RoundControl {
IHand clonedHand;
private Event restartRoundEvent = new Event();
private Event1<Score> endOfRoundEvent = new Event1<Score>();
+ private Event1<ITable> tableUpdateEvent = new Event1<ITable>();
private List<Connection> connections = new ArrayList<Connection>();
private ITurnControl turnControl;
private boolean roundFinished;
@@ -68,6 +70,10 @@ public class RoundControl {
return endOfRoundEvent;
}
+ public IEvent1<ITable> getTableUpdateEvent() {
+ return tableUpdateEvent;
+ }
+
/**
* Begin the round
*/
@@ -170,6 +176,13 @@ public class RoundControl {
}
});
+ turnControl.getTableUpdateEvent().add(new IListener1<ITable>() {
+ @Override
+ public void handle(ITable table) {
+ tableUpdateEvent.emit(table);
+ }
+ });
+
turnControl.getRedealEvent().add(new IListener() {
@Override
public void handle() {
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
*/