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
This commit is contained in:
parent
c7069227f3
commit
f641b76bca
4 changed files with 35 additions and 6 deletions
|
@ -26,6 +26,7 @@ import jrummikub.util.Event1;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
import jrummikub.util.IEvent1;
|
import jrummikub.util.IEvent1;
|
||||||
import jrummikub.util.IListener;
|
import jrummikub.util.IListener;
|
||||||
|
import jrummikub.util.IListener1;
|
||||||
import jrummikub.util.Pair;
|
import jrummikub.util.Pair;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
import jrummikub.view.IView.BottomPanelType;
|
import jrummikub.view.IView.BottomPanelType;
|
||||||
|
@ -40,6 +41,7 @@ public class RoundControl {
|
||||||
IHand clonedHand;
|
IHand clonedHand;
|
||||||
private Event restartRoundEvent = new Event();
|
private Event restartRoundEvent = new Event();
|
||||||
private Event1<Score> endOfRoundEvent = new Event1<Score>();
|
private Event1<Score> endOfRoundEvent = new Event1<Score>();
|
||||||
|
private Event1<ITable> tableUpdateEvent = new Event1<ITable>();
|
||||||
private List<Connection> connections = new ArrayList<Connection>();
|
private List<Connection> connections = new ArrayList<Connection>();
|
||||||
private ITurnControl turnControl;
|
private ITurnControl turnControl;
|
||||||
private boolean roundFinished;
|
private boolean roundFinished;
|
||||||
|
@ -68,6 +70,10 @@ public class RoundControl {
|
||||||
return endOfRoundEvent;
|
return endOfRoundEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEvent1<ITable> getTableUpdateEvent() {
|
||||||
|
return tableUpdateEvent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begin the round
|
* 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() {
|
turnControl.getRedealEvent().add(new IListener() {
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
|
|
|
@ -6,9 +6,12 @@ import java.util.List;
|
||||||
import jrummikub.control.ITurnTimer;
|
import jrummikub.control.ITurnTimer;
|
||||||
import jrummikub.control.TurnTimer;
|
import jrummikub.control.TurnTimer;
|
||||||
import jrummikub.model.GameSettings;
|
import jrummikub.model.GameSettings;
|
||||||
|
import jrummikub.model.ITable;
|
||||||
import jrummikub.util.Connection;
|
import jrummikub.util.Connection;
|
||||||
import jrummikub.util.Event;
|
import jrummikub.util.Event;
|
||||||
|
import jrummikub.util.Event1;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
|
import jrummikub.util.IEvent1;
|
||||||
import jrummikub.util.IListener;
|
import jrummikub.util.IListener;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
|
||||||
|
@ -18,6 +21,7 @@ import jrummikub.view.IView;
|
||||||
public abstract class AbstractTurnControl implements ITurnControl {
|
public abstract class AbstractTurnControl implements ITurnControl {
|
||||||
protected Event endOfTurnEvent = new Event();
|
protected Event endOfTurnEvent = new Event();
|
||||||
protected Event redealEvent = new Event();
|
protected Event redealEvent = new Event();
|
||||||
|
protected Event1<ITable> tableUpdateEvent = new Event1<ITable>();
|
||||||
protected TurnInfo turnInfo;
|
protected TurnInfo turnInfo;
|
||||||
protected GameSettings settings;
|
protected GameSettings settings;
|
||||||
protected IView view;
|
protected IView view;
|
||||||
|
@ -33,6 +37,11 @@ public abstract class AbstractTurnControl implements ITurnControl {
|
||||||
public IEvent getRedealEvent() {
|
public IEvent getRedealEvent() {
|
||||||
return redealEvent;
|
return redealEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEvent1<ITable> getTableUpdateEvent() {
|
||||||
|
return tableUpdateEvent;
|
||||||
|
}
|
||||||
|
|
||||||
protected void pauseTurn() {
|
protected void pauseTurn() {
|
||||||
timer.stopTimer();
|
timer.stopTimer();
|
||||||
|
|
|
@ -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) {
|
private void tableClick(Position position) {
|
||||||
if (selectedStones.isEmpty()) {
|
if (selectedStones.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -309,9 +317,7 @@ public class HumanTurnControl extends AbstractTurnControl {
|
||||||
.getY() - 0.5f));
|
.getY() - 0.5f));
|
||||||
selectedStones.clear();
|
selectedStones.clear();
|
||||||
|
|
||||||
view.getTablePanel().setStoneSets(turnInfo.getTable());
|
updateTable();
|
||||||
view.getHandPanel().setStones(turnInfo.getHand());
|
|
||||||
view.setSelectedStones(selectedStones);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tableSetClick(Stone stone, boolean collect) {
|
private void tableSetClick(Stone stone, boolean collect) {
|
||||||
|
@ -434,9 +440,7 @@ public class HumanTurnControl extends AbstractTurnControl {
|
||||||
|
|
||||||
selectedStones.clear();
|
selectedStones.clear();
|
||||||
|
|
||||||
view.getTablePanel().setStoneSets(turnInfo.getTable());
|
updateTable();
|
||||||
view.getHandPanel().setStones(turnInfo.getHand());
|
|
||||||
view.setSelectedStones(selectedStones);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void endOfTurn(boolean redeal) {
|
private void endOfTurn(boolean redeal) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import jrummikub.model.GameSettings;
|
||||||
import jrummikub.model.IHand;
|
import jrummikub.model.IHand;
|
||||||
import jrummikub.model.ITable;
|
import jrummikub.model.ITable;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
|
import jrummikub.util.IEvent1;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,6 +49,8 @@ public interface ITurnControl {
|
||||||
*/
|
*/
|
||||||
public void abortTurn();
|
public void abortTurn();
|
||||||
|
|
||||||
|
public IEvent1<ITable> getTableUpdateEvent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The TurnInfo class encapsulates all information concerning the current turn
|
* The TurnInfo class encapsulates all information concerning the current turn
|
||||||
*/
|
*/
|
||||||
|
|
Reference in a new issue