Added player type selection to the settings panel
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@315 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
08e9b28f3b
commit
43ace4c18a
4 changed files with 155 additions and 88 deletions
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue