Ejemplo n.º 1
0
        private PlayerAction GetTurnChain(PlayerTurnContext context)
        {
            var decisionContext = new DecisionMakingContext()
            {
                ActionChoser = ActionChoser,
                CardChoser   = CardChoser,
                MyCards      = this.Cards,
                Tracker      = Tracker,
                TurnContext  = context,
                Validator    = this.PlayerActionValidator
            };

            // TODO: this of something more elegant
            var action = decisionMaker.Handle(decisionContext);

            switch (action.Type)
            {
            case PlayerActionType.PlayCard:
                return(this.PlayCard(action.Card));

            case PlayerActionType.ChangeTrump:
                return(this.ChangeTrump(context.TrumpCard));

            case PlayerActionType.CloseGame:
                return(this.CloseGame());

            default:
                throw new InvalidOperationException("Invalid type of player action");
            }
        }