Example #1
0
        public void Clone_HandHistoryHandWithThreePlayers_ShouldReturnExactHand()
        {
            HandHistory script = new HandHistory();

            var mock = new Mock<OmahaPlayer>();
            mock.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction());

            script.ButtonSeat = 0;
            script.SmallBlindSeat = 1;
            script.SmallBlindAmount = 5;
            script.BigBlindSeat = 2;
            script.BigBlindAmount = 10;

            script.Players[0] = new HandHistoryPlayer("Bob", 2300);
            script.Players[1] = new HandHistoryPlayer("Kevin", 2800);
            script.Players[2] = new HandHistoryPlayer("Burger", 2800);

            script.Players[0].HoleCards = new Card[] { new Card("5s"), new Card("Js"), new Card("7h"), new Card("Qs") };
            script.Players[1].HoleCards = new Card[] { new Card("3s"), new Card("3d"), new Card("7d"), new Card("Ah") };
            script.Players[2].HoleCards = new Card[] { new Card("2s"), new Card("Jh"), new Card("3h"), new Card("Ad") };

            script.Actions.Add(new HandHistoryPokerAction(script.Players[0], PokerAction.CreateCallAction()));
            script.Actions.Add(new HandHistoryPokerAction(script.Players[1], PokerAction.CreateCallAction()));
            script.Actions.Add(new HandHistoryPokerAction(script.Players[2], PokerAction.CreateCallAction()));

            OmahaHiLoHand hand = new OmahaHiLoHand(script);
            OmahaHiLoHand cloned = (OmahaHiLoHand)hand.Clone();

            HandResult hr1 = hand.RunToEnd();
            HandResult hr2 = cloned.RunToEnd();

            // This isn't perfect, but for now this is fine
            Assert.AreEqual(hr1.Winners[0].Player.HoleCards, hr2.Winners[0].Player.HoleCards);
        }
Example #2
0
        public void RunToEnd_Player1HasHighAndLowPlayer2HasLow_Player1ShouldHave3TimesWinningAmoutAsPlayer2()
        {
            HandHistory script = new HandHistory();

            var mock1 = new Mock<OmahaPlayer>();
            var mock2 = new Mock<OmahaPlayer>();
            mock1.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction());
            mock1.Setup(p => p.WinEvent(0, 300)).Verifiable();
            mock1.Setup(p => p.WinEvent(1, 100)).Verifiable();
            mock2.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction());
            mock2.Setup(p => p.WinEvent(0, 300)).Verifiable();
            mock2.Setup(p => p.WinEvent(1, 100)).Verifiable();

            script.ButtonSeat = 0;
            script.SmallBlindSeat = 1;
            script.SmallBlindAmount = 100;
            script.BigBlindSeat = 0;
            script.BigBlindAmount = 200;

            script.Players[0] = new HandHistoryPlayer("John", 1000, mock1.Object);
            script.Players[1] = new HandHistoryPlayer("Bill", 1000, mock2.Object);

            script.Players[0].HoleCards = CardHelper.CreateHandFromString("4s 5s 6h 7h"); //// Straight flush!
            script.Players[1].HoleCards = CardHelper.CreateHandFromString("4h 5d 6h 7h");

            script.FlopCards = CardHelper.CreateHandFromString("As 2s 3s");
            script.TurnCard = new Card(HoldemHand.Hand.Rank8, 0);
            script.RiverCard = new Card(HoldemHand.Hand.Rank9, 0);

            OmahaHiLoHand hand = new OmahaHiLoHand(script);

            HandResult hr = hand.RunToEnd();

            mock1.Verify();
            mock2.Verify();
        }
Example #3
0
        public void RunToEnd_SetupHandHistoryScript_PlayersShouldGetCorrectCards()
        {
            HandHistory script = new HandHistory();

            var mock = new Mock<OmahaPlayer>();
            mock.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction());

            script.ButtonSeat = 0;
            script.SmallBlindSeat = 1;
            script.SmallBlindAmount = 5;
            script.BigBlindSeat = 0;
            script.BigBlindAmount = 10;

            script.Players[0] = new HandHistoryPlayer("John", 2300, mock.Object);
            script.Players[1] = new HandHistoryPlayer("Billy", 2800, mock.Object);

            Card[] expected0 = new Card[] { new Card("8s"), new Card("3s"), new Card("Ad"), new Card("Jc") };
            Card[] expected1 = new Card[] { new Card("5s"), new Card("Js"), new Card("5h"), new Card("Qs") };

            script.Players[0].HoleCards = expected0;
            script.Players[1].HoleCards = expected1;

            OmahaHiLoHand hand = new OmahaHiLoHand(script);

            hand.SimulateNext();

            Assert.AreEqual(expected0, script.Players[0].HoleCards);
            Assert.AreEqual(expected1, script.Players[1].HoleCards);
        }
Example #4
0
        public void RunToEnd_SetupHandHistoryScript_MockPlayerShouldNeverBeCalled()
        {
            HandHistory script = new HandHistory();

            var mock = new Mock<OmahaPlayer>();
            mock.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction());

            script.ButtonSeat = 0;
            script.SmallBlindSeat = 1;
            script.SmallBlindAmount = 5;
            script.BigBlindSeat = 2;
            script.BigBlindAmount = 10;

            script.Players[0] = new HandHistoryPlayer("John", 2300);
            script.Players[1] = new HandHistoryPlayer("Billy", 2800);
            script.Players[2] = new HandHistoryPlayer("Roger", 3000, mock.Object);
            script.Players[5] = new HandHistoryPlayer("Nick", 1000);

            script.Players[2].HoleCards = new Card[] { new Card("5s"), new Card("Js"), new Card("5h"), new Card("Qs") };

            script.Actions.Add(new HandHistoryPokerAction(script.Players[5], PokerAction.CreateFoldAction()));
            script.Actions.Add(new HandHistoryPokerAction(script.Players[0], PokerAction.CreateFoldAction()));
            script.Actions.Add(new HandHistoryPokerAction(script.Players[1], PokerAction.CreateFoldAction()));

            OmahaHiLoHand hand = new OmahaHiLoHand(script);

            Assert.AreEqual("Roger", hand.RunToEnd().Winners[0].Player.Name);

            mock.Verify();
        }
Example #5
0
        public void RunToEnd_Player1HasHighPlayer2HasLow_ShouldBeTwoWinners()
        {
            HandHistory script = new HandHistory();

            var mock1 = new Mock<OmahaPlayer>();
            var mock2 = new Mock<OmahaPlayer>();
            mock1.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction());
            mock2.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction());

            script.ButtonSeat = 0;
            script.SmallBlindSeat = 1;
            script.SmallBlindAmount = 5;
            script.BigBlindSeat = 0;
            script.BigBlindAmount = 10;

            script.Players[0] = new HandHistoryPlayer("John", 1000, mock1.Object);
            script.Players[1] = new HandHistoryPlayer("Bill", 1000, mock2.Object);

            script.Players[0].HoleCards = CardHelper.CreateHandFromString("Ah Ad 7h 8h");
            script.Players[1].HoleCards = CardHelper.CreateHandFromString("4h 6d Th Jh");

            script.FlopCards = CardHelper.CreateHandFromString("As 2s 3s");
            script.TurnCard = new Card(HoldemHand.Hand.Rank8, 0);
            script.RiverCard = new Card(HoldemHand.Hand.Rank9, 0);

            OmahaHiLoHand hand = new OmahaHiLoHand(script);

            HandResult hr = hand.RunToEnd();

            Assert.AreEqual(2, hr.Winners.Count);
        }
Example #6
0
        public HandHistory Parse(string handLog)
        {
            StringReader sr = new StringReader(handLog);

            while (_doNotConsumeNextLine || (_line = sr.ReadLine()) != null)
            {
                _doNotConsumeNextLine = false;

                switch (_state)
                {
                    case ParseState.Site:
                        StateSite();
                        break;
                    case ParseState.TableId:
                        StateTableId();
                        break;
                    case ParseState.Seats:
                        StateSeats();
                        break;
                    case ParseState.Blinds:
                        StateBlinds();
                        break;
                    case ParseState.Cards:
                        StateCards();
                        break;
                    case ParseState.Preflop:
                        StatePlayerAction();
                        break;
                    case ParseState.FlopTransition:
                        StateRoundTransition();
                        break;
                    case ParseState.Flop:
                        StatePlayerAction();
                        break;
                    case ParseState.TurnTransition:
                        StateRoundTransition();
                        break;
                    case ParseState.Turn:
                        StatePlayerAction();
                        break;
                    case ParseState.RiverTransition:
                        StateRoundTransition();
                        break;
                    case ParseState.River:
                        StatePlayerAction();
                        break;
                    case ParseState.ShowdownTransition:
                        StateShowdownTransition();
                        break;
                    case ParseState.Showdown:
                        StateShowdown();
                        break;
                    case ParseState.Summary:
                        break;
                }
            }

            HandHistory hand = new HandHistory(_players);
            hand.Site = _site;

            hand.ButtonSeat = _buttonSeat;
            hand.SmallBlindSeat = _smallBlindSeat;
            hand.BigBlindSeat = _bigBlindSeat;
            hand.SmallBlindAmount = _smallBlindAmount;
            hand.BigBlindAmount = _bigBlindAmount;

            if (_commonCards.Count > 2)
            {
                hand.FlopCards = new Card[3];

                for (int i = 0; i < 3; i++)
                {
                    hand.FlopCards[i] = _commonCards[i];
                }
            }

            if (_commonCards.Count > 3)
            {
                hand.TurnCard = _commonCards[3];
            }

            if (_commonCards.Count > 4)
            {
                hand.RiverCard = _commonCards[4];
            }

            foreach (HandHistoryPokerAction action in _actions)
            {
                hand.Actions.Add(action);
            }

            foreach (Pair<HandHistoryPlayer, long> winner in _winners)
            {
                hand.Winners.Add(winner);
            }

            return hand;
        }