Esempio n. 1
0
        public void ProcessAction(ActionBase action)
        {
            switch (action.GetActionType())
            {
            case ActionType.BetAction:
                BetStage.ProcessBetAction((BetAction)action);
                if (BetStage.BetResult != null)
                {
                    Log.Information(BetStage.BetResult.ToString());
                    ConfirmAction?.Invoke();
                    var playType = BetStage.BetResult.Bet.PlayType;
                    PlayStage          = new PlayStage(Rules, PlayerGroupInfo, ConfirmAction, PlayerHandDictionary, InitialPlayer, playType);
                    ExpectedActionType = ActionType.PlayAction;
                }
                return;

            case ActionType.PlayAction:
                PlayStage.ProcessPlayAction((PlayAction)action);
                if (PlayStage.PlayResult != null)
                {
                    Log.Information(PlayStage.PlayResult.ToString());
                    ConfirmAction?.Invoke();
                    RoundResult        = GetRoundResult();
                    ExpectedActionType = ActionType.Invalid;
                }
                return;

            default:
                var msg = $"Invalid ActionType {action?.GetActionType()}!";
                Log.Error(msg);
                throw new Exception(msg);
            }
        }
Esempio n. 2
0
        public IList <int> GetValidActionIdList(string playerId)
        {
            switch (ExpectedActionType)
            {
            case ActionType.BetAction:
                return(BetStage.GetValidActionIdList(playerId));

            case ActionType.PlayAction:
                return(PlayStage.GetValidActionIdList(playerId));

            default:
                return(new List <int>());
            }
        }
Esempio n. 3
0
        public GameRound(
            Rules rules,
            PlayerGroupInfo playerGroup,
            Action confirmAction,
            PlayerInfo initialPlayer,
            CardPile deck)
        {
            Rules           = rules;
            PlayerGroupInfo = playerGroup;
            ConfirmAction   = confirmAction;
            InitialPlayer   = initialPlayer;
            var playerList = PlayerGroupInfo.GetPlayerList(InitialPlayer.PlayerId);

            PlayerHandDictionary = playerList
                                   .ToDictionary(p => p.PlayerId, p => new CardPile(deck.Draw(9)));
            BetStage           = new BetStage(Rules, PlayerGroupInfo, PlayerHandDictionary, InitialPlayer);
            ExpectedActionType = ActionType.BetAction;
        }