예제 #1
0
        public void Test_IsPlayerAction()
        {
            PokerAction action = new PokerAction();

            action.Kind = Ak.b;
            Assert.IsFalse(action.IsPlayerAction());
            action.Kind = Ak.f;
            Assert.IsTrue(action.IsPlayerAction());
            action.Kind = Ak.c;
            Assert.IsTrue(action.IsPlayerAction());
            action.Kind = Ak.r;
            Assert.IsTrue(action.IsPlayerAction());
            action.Kind = Ak.d;
            Assert.IsFalse(action.IsPlayerAction());
        }
예제 #2
0
 public void Test_IsPlayerAction_Static()
 {
     Assert.IsFalse(PokerAction.IsPlayerAction(Ak.b));
     Assert.IsTrue(PokerAction.IsPlayerAction(Ak.f));
     Assert.IsTrue(PokerAction.IsPlayerAction(Ak.c));
     Assert.IsTrue(PokerAction.IsPlayerAction(Ak.r));
     Assert.IsFalse(PokerAction.IsPlayerAction(Ak.d));
 }
예제 #3
0
        void AdjustAction(ref PokerAction action)
        {
            if (action == null || !action.IsPlayerAction())
            {
                log.WarnFormat("Player returned null action, Action replaced by fold.");
                action = new PokerAction {
                    Kind = Ak.f
                };
            }
            if (!action.IsPlayerAction())
            {
                log.WarnFormat("Player returned a non-player action: {0}. Action replaced by fold.", action);
                action = new PokerAction {
                    Kind = Ak.f
                };
            }

            action.Position = _state.CurrentActor;

            if (action.Kind == Ak.r)
            {
                if (_state.BetCount >= _gameDef.BetsCountLimits[_state.Round])
                {
                    // No more raises allowed.
                    action.Kind = Ak.c;
                }
            }

            if (action.Kind != Ak.r)
            {
                action.Amount = 0;
            }
            else
            {
                double minBet = _state.GetMinBet(_gameDef);
                double maxBet = _state.GetMaxBet(_gameDef);
                if (action.Amount < minBet)
                {
                    action.Amount = minBet;
                }
                if (action.Amount > maxBet)
                {
                    action.Amount = maxBet;
                }
            }
        }