Exemplo n.º 1
0
        public void TestAllInSidePots()
        {
            Action[] actions = new Action[] {
                new Action("Player3", Action.ActionTypes.PostSmallBlind, 1),
                new Action("Player4", Action.ActionTypes.PostBigBlind, 2),
                new Action("Player0", Action.ActionTypes.AllIn, 250),
                new Action("Player1", Action.ActionTypes.AllIn, 275),
                new Action("Player2", Action.ActionTypes.AllIn, 125),
                new Action("Player3", Action.ActionTypes.AllIn, 499),
                new Action("Player4", Action.ActionTypes.AllIn, 498)
            };

            Assert.AreEqual(0, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount, "Started with something besides 1 pot");

            potMan.AddAction(actions[0]);
            Assert.AreEqual(1, potMan.Total, "small blind not added correctly");
            Assert.AreEqual(1, potMan.PotCount, "pots wrong after small blind");

            potMan.AddAction(actions[1]);
            Assert.AreEqual(3, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount);

            potMan.AddAction(actions[2]);
            Assert.AreEqual(253, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount);

            potMan.AddAction(actions[3]);
            Assert.AreEqual(528, potMan.Total);
            Assert.AreEqual(2, potMan.PotCount);
            Assert.AreEqual(503, potMan.Pots[0].Size);
            Assert.AreEqual(25, potMan.Pots[1].Size);

            potMan.AddAction(actions[4]);
            Assert.AreEqual(653, potMan.Total);
            Assert.AreEqual(3, potMan.PotCount);
            Assert.AreEqual(378, potMan.Pots[0].Size);
            Assert.AreEqual(250, potMan.Pots[1].Size);
            Assert.AreEqual(25, potMan.Pots[2].Size);

            potMan.AddAction(actions[5]);
            Assert.AreEqual(1152, potMan.Total);
            Assert.AreEqual(4, potMan.PotCount);
            Assert.AreEqual(502, potMan.Pots[0].Size);
            Assert.AreEqual(375, potMan.Pots[1].Size);
            Assert.AreEqual(50, potMan.Pots[2].Size);
            Assert.AreEqual(225, potMan.Pots[3].Size);

            potMan.AddAction(actions[6]);
            Assert.AreEqual(1650, potMan.Total);
            Assert.AreEqual(4, potMan.PotCount);
            Assert.AreEqual(625, potMan.Pots[0].Size);
            Assert.AreEqual(500, potMan.Pots[1].Size);
            Assert.AreEqual(75, potMan.Pots[2].Size);
            Assert.AreEqual(450, potMan.Pots[3].Size);

            Dictionary <string, ulong> strengths = new Dictionary <string, ulong>();

            strengths["Player0"] = 1;
            strengths["Player1"] = 2;
            strengths["Player2"] = 5;
            strengths["Player3"] = 4;
            strengths["Player4"] = 3;


            List <Winner> winners = potMan.GetWinners(strengths);

            Assert.AreEqual(4, winners.Count);

            Assert.AreEqual(625, winners[0].Amount);
            Assert.AreEqual("Player2", winners[0].Player);

            Assert.AreEqual(500, winners[1].Amount);
            Assert.AreEqual("Player3", winners[1].Player);

            Assert.AreEqual(75, winners[2].Amount);
            Assert.AreEqual("Player3", winners[2].Player);

            Assert.AreEqual(450, winners[3].Amount);
            Assert.AreEqual("Player3", winners[3].Player);
        }
Exemplo n.º 2
0
        public void TestAllInSidePots()
        {
            Action[] actions = new Action[] {
                new Action("Player3", Action.ActionTypes.PostSmallBlind, 1),
                new Action("Player4", Action.ActionTypes.PostBigBlind, 2),
                new Action("Player0", Action.ActionTypes.Raise, 250, true),
                new Action("Player1", Action.ActionTypes.Raise, 275, true),
                new Action("Player2", Action.ActionTypes.Call, 125, true),
                new Action("Player3", Action.ActionTypes.Raise, 499, true),
                new Action("Player4", Action.ActionTypes.Call, 498, true)
            };

            Assert.AreEqual(0, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount, "Started with something besides 1 pot");

            potMan.AddAction(3, actions[0]);
            Assert.AreEqual(1, potMan.Total, "small blind not added correctly");
            Assert.AreEqual(1, potMan.PotCount, "pots wrong after small blind");

            potMan.AddAction(4, actions[1]);
            Assert.AreEqual(3, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount);

            potMan.AddAction(0, actions[2]);
            Assert.AreEqual(253, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount);

            potMan.AddAction(1, actions[3]);
            Assert.AreEqual(528, potMan.Total);
            Assert.AreEqual(2, potMan.PotCount);
            Assert.AreEqual(503, potMan.Pots[0].Size);
            Assert.AreEqual(25, potMan.Pots[1].Size);

            potMan.AddAction(2, actions[4]);
            Assert.AreEqual(653, potMan.Total);
            Assert.AreEqual(3, potMan.PotCount);
            Assert.AreEqual(378, potMan.Pots[0].Size);
            Assert.AreEqual(250, potMan.Pots[1].Size);
            Assert.AreEqual(25, potMan.Pots[2].Size);

            potMan.AddAction(3, actions[5]);
            Assert.AreEqual(1152, potMan.Total);
            Assert.AreEqual(4, potMan.PotCount);
            Assert.AreEqual(502, potMan.Pots[0].Size);
            Assert.AreEqual(375, potMan.Pots[1].Size);
            Assert.AreEqual(50, potMan.Pots[2].Size);
            Assert.AreEqual(225, potMan.Pots[3].Size);

            potMan.AddAction(4, actions[6]);
            Assert.AreEqual(1650, potMan.Total);
            Assert.AreEqual(4, potMan.PotCount);
            Assert.AreEqual(625, potMan.Pots[0].Size);
            Assert.AreEqual(500, potMan.Pots[1].Size);
            Assert.AreEqual(75, potMan.Pots[2].Size);
            Assert.AreEqual(450, potMan.Pots[3].Size);

            uint[] strengths = new uint[5];
            strengths[0] = 1;
            strengths[1] = 2;
            strengths[2] = 5;
            strengths[3] = 4;
            strengths[4] = 3;


            IList <Winner> winners = potMan.GetWinners(strengths);

            Assert.AreEqual(4, winners.Count);

            Assert.AreEqual(625, winners[0].Amount);
            Assert.AreEqual("Player2", winners[0].Player);

            Assert.AreEqual(500, winners[1].Amount);
            Assert.AreEqual("Player3", winners[1].Player);

            Assert.AreEqual(75, winners[2].Amount);
            Assert.AreEqual("Player3", winners[2].Player);

            Assert.AreEqual(450, winners[3].Amount);
            Assert.AreEqual("Player3", winners[3].Player);
        }