From eb7ccb46c5023fb8a3052f1c6d9fa5d2e384d15e Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Sun, 29 May 2011 19:46:53 +0200 Subject: Added TurnControlFactory git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@308 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/turn/HumanTurnControl.java | 35 ++++++++++++++++------ src/jrummikub/control/turn/TurnControlFactory.java | 9 ++++++ 2 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 src/jrummikub/control/turn/TurnControlFactory.java (limited to 'src/jrummikub/control/turn') diff --git a/src/jrummikub/control/turn/HumanTurnControl.java b/src/jrummikub/control/turn/HumanTurnControl.java index 9b44f4e..399f547 100644 --- a/src/jrummikub/control/turn/HumanTurnControl.java +++ b/src/jrummikub/control/turn/HumanTurnControl.java @@ -34,7 +34,7 @@ public class HumanTurnControl extends AbstractTurnControl { private List selectedStones = new ArrayList(); private List connections = new ArrayList(); - + private boolean inspectOnly; /** @@ -50,7 +50,8 @@ public class HumanTurnControl extends AbstractTurnControl { * @param inspectOnly * the current turn doesn't allow any table manipulation */ - public HumanTurnControl(IHand hand, ITable table, IView view, boolean inspectOnly) { + public HumanTurnControl(IHand hand, ITable table, IView view, + boolean inspectOnly) { this.hand = hand; this.table = table; this.view = view; @@ -58,6 +59,21 @@ public class HumanTurnControl extends AbstractTurnControl { this.timer = new TurnTimer(view); } + /** + * Get a factory for this turn control + * + * @return factory + */ + public static TurnControlFactory getFactory() { + return new TurnControlFactory() { + @Override + public ITurnControl create(IHand hand, ITable table, IView view, + boolean inspectOnly) { + return new HumanTurnControl(hand, table, view, inspectOnly); + } + }; + } + /** Test only constructor **/ HumanTurnControl(IHand hand, ITable table, IView view, ITurnTimer testTimer) { this.hand = hand; @@ -80,13 +96,14 @@ public class HumanTurnControl extends AbstractTurnControl { connections.add(timer.getTimeRunOutEvent().add(endOfTurnListener)); connections.add(view.getPlayerPanel().getEndTurnEvent() .add(endOfTurnListener)); - - connections.add(view.getPlayerPanel().getRedealEvent().add(new IListener() { - @Override - public void handle() { - endOfTurn(true); - } - })); + + connections.add(view.getPlayerPanel().getRedealEvent() + .add(new IListener() { + @Override + public void handle() { + endOfTurn(true); + } + })); addHandPanelHandlers(); addStoneCollectionHandlers(); diff --git a/src/jrummikub/control/turn/TurnControlFactory.java b/src/jrummikub/control/turn/TurnControlFactory.java new file mode 100644 index 0000000..3af910b --- /dev/null +++ b/src/jrummikub/control/turn/TurnControlFactory.java @@ -0,0 +1,9 @@ +package jrummikub.control.turn; + +import jrummikub.model.IHand; +import jrummikub.model.ITable; +import jrummikub.view.IView; + +public interface TurnControlFactory { + public ITurnControl create(IHand hand, ITable table, IView view, boolean inspectOnly); +} -- cgit v1.2.3