Commit() public méthode

Updates the information about the current betting scenario.
public Commit ( System.Action action ) : void
action System.Action The validated action the player is taking
Résultat void
Exemple #1
0
        public void AddAction(int pIdx, Action action)
        {
            action = _betManager.GetValidatedAction(action);

            _betManager.Commit(action);
            //curRoundActions.Add(action);

            if (action.Amount > 0)
            {
                _seats[pIdx].Chips -= action.Amount;
            }

            //update the pots
            _potManager.AddAction(pIdx, action);

            if (action.ActionType == Action.ActionTypes.None)
            {
                throw new Exception("Must have an action");
            }

            //if the player either folded or went all-in, they can no longer
            //bet so remove them from the player pool
            if (action.ActionType == Action.ActionTypes.Fold)
            {
                _playerIndices.Remove(pIdx);
                _history.Folded[pIdx] = true;
            }
            else if (action.AllIn)
            {
                _playerIndices.Remove(pIdx);
                _history.AllIn[pIdx] = true;
            }
        }
        public void TestAntes()
        {
            double[] blinds = new double[] { 2, 4 };
            betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 1);

            Action[] actions = new Action[] {
                new Action("Player3", Action.ActionTypes.PostAnte, 25),//should be 1
                new Action("Player4", Action.ActionTypes.PostAnte, 0.5),// should be 1
                new Action("Player0", Action.ActionTypes.PostAnte, 2),//should be PostAnte and 1
            };

            Action action = betMan.GetValidatedAction(actions[0]);
            Assert.AreEqual(1, action.Amount);
            Assert.AreEqual(Action.ActionTypes.PostAnte, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[1]);
            Assert.AreEqual(1, action.Amount);
            Assert.AreEqual(Action.ActionTypes.PostAnte, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[2]);
            Assert.AreEqual(1, action.Amount);
            Assert.AreEqual(Action.ActionTypes.PostAnte, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);
        }
        public void TestBlinds()
        {
            double[] blinds = new double[]{1,2};
            betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0);

            FastPokerAction[] actions = new FastPokerAction[] {
                new FastPokerAction("Player3", FastPokerAction.ActionTypes.PostSmallBlind, 25),
                new FastPokerAction("Player4", FastPokerAction.ActionTypes.PostBigBlind, 62),
                new FastPokerAction("Player0", FastPokerAction.ActionTypes.Raise, 1),
            };

            FastPokerAction action = betMan.GetValidatedAction(actions[0]);
            Assert.AreEqual(1, action.Amount);
            Assert.AreEqual(FastPokerAction.ActionTypes.PostSmallBlind, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[1]);
            Assert.AreEqual(2, action.Amount);
            Assert.AreEqual(FastPokerAction.ActionTypes.PostBigBlind, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[2]);
            Assert.AreEqual(4, action.Amount);
            Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);
        }
        public void TestNoLimitRaising()
        {
            double[] blinds = new double[] { 2, 4 };
            betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0);

            Action[] actions = new Action[] {
                new Action("Player0", Action.ActionTypes.PostSmallBlind, 2),
                new Action("Player1", Action.ActionTypes.PostBigBlind, 4),
                new Action("Player2", Action.ActionTypes.Bet, 6),//should be corrected to Raise 8
                new Action("Player3", Action.ActionTypes.Raise, 20),
                new Action("Player4", Action.ActionTypes.Raise, 0)//should be corrected to 32
            };

            betMan.Commit(actions[0]);
            betMan.Commit(actions[1]);

            Action action = betMan.GetValidatedAction(actions[2]);
            Assert.AreEqual(8, action.Amount);
            Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType);
            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[3]);
            Assert.AreEqual(20, action.Amount);
            Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType);
            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[4]);
            Assert.AreEqual(32, action.Amount);
            Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType);
            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);
        }