summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/RoundControl.java5
-rw-r--r--src/jrummikub/control/turn/TurnControlFactory.java24
2 files changed, 25 insertions, 4 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index fbe5873..bcef40e 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Set;
import jrummikub.control.turn.ITurnControl;
+import jrummikub.control.turn.TurnControlFactory;
import jrummikub.model.Hand;
import jrummikub.model.IHand;
import jrummikub.model.IPlayer;
@@ -94,8 +95,8 @@ public class RoundControl {
view.getPlayerPanel().setEndTurnMode(inspectOnly, mayRedeal);
- ITurnControl turnControl = roundState.getActivePlayer()
- .getPlayerSettings().getTurnControlFactory().create();
+ ITurnControl turnControl = TurnControlFactory.getFactory(roundState.getActivePlayer()
+ .getPlayerSettings().getTurnControlType()).create();
turnControl.setup(roundState.getActivePlayer().getHand(), clonedTable,
view, inspectOnly, mayRedeal);
turnControl.getEndOfTurnEvent().add(new IListener() {
diff --git a/src/jrummikub/control/turn/TurnControlFactory.java b/src/jrummikub/control/turn/TurnControlFactory.java
index 48c028e..ecfc5ff 100644
--- a/src/jrummikub/control/turn/TurnControlFactory.java
+++ b/src/jrummikub/control/turn/TurnControlFactory.java
@@ -4,6 +4,26 @@ import jrummikub.model.IHand;
import jrummikub.model.ITable;
import jrummikub.view.IView;
-public interface TurnControlFactory {
- public ITurnControl create();
+public abstract class TurnControlFactory {
+ /**
+ * Type of turn control.
+ */
+ public enum Type {
+ /** */
+ HUMAN,
+ /** */
+ COMPUTER
+ };
+
+ public abstract ITurnControl create();
+
+ static public TurnControlFactory getFactory(Type type) {
+ switch(type) {
+ case HUMAN:
+ return HumanTurnControl.getFactory();
+ case COMPUTER:
+ return BaseAIControl.getFactory();
+ }
+ return null;
+ }
}