예제 #1
0
        public void TestThreeHand()
        {
            Round r = new Round();

            r.Hands = new List <Play>();
            r.Hands.Add(new Play()
            {
                Name = "Bill", Hand = new List <string>()
                {
                    "2C", "3D", "4S", "8C", "AH"
                }
            });
            r.Hands.Add(new Play()
            {
                Name = "Bob", Hand = new List <string>()
                {
                    "2H", "3C", "4D", "5H", "7H"
                }
            });
            r.Hands.Add(new Play()
            {
                Name = "Ted", Hand = new List <string>()
                {
                    "KH", "AC", "AS", "7S", "10H"
                }
            });
            var actionResult = new PokerController().Post(r);

            Assert.IsInstanceOfType(actionResult, typeof(OkNegotiatedContentResult <string>),
                                    "Duplicate player names should return an OkResult when passed three hands.");
            var contentResult = actionResult as OkNegotiatedContentResult <string>;

            Assert.AreEqual("Ted", contentResult.Content,
                            "API should behave correctly when given 3 players.");
        }
예제 #2
0
        public void TestCorrectWinnerComplexHands()
        {
            Round r = new Round();

            r.Hands = new List <Play>();
            r.Hands.Add(new Play()
            {
                Name = "Bill", Hand = new List <string>()
                {
                    "2C", "3D", "4S", "8C", "AH"
                }
            });
            r.Hands.Add(new Play()
            {
                Name = "Bob", Hand = new List <string>()
                {
                    "2H", "3H", "4H", "5H", "6H"
                }
            });
            var actionResult = new PokerController().Post(r);

            Assert.IsInstanceOfType(actionResult, typeof(OkNegotiatedContentResult <string>),
                                    "Duplicate player names should return an OkResult under normal conditions.");
            var contentResult = actionResult as OkNegotiatedContentResult <string>;

            Assert.AreEqual("Bob", contentResult.Content,
                            "Correct winner should be returned when hand is complex.");
        }
예제 #3
0
 public void NewGame(List <string> names)
 {
     PokerController.NewGame(names);
     UpdateGameStats();
     UpdateStatusBar(PokerController.CurrentPlayer.Name + " make a bet");
     DisableOrEnableButtons();
 }
예제 #4
0
        public PokerGameWindow(int NumOfP)
        {
            OnNavigatedTo();

            controller = new PokerController(NumOfP);

            InitializeComponent();
        }
예제 #5
0
        private void Awake()
        {
            table = new DataTable();
            table.InitTable();

            controller = new PokerController(table);
            scheduler  = new PokerScheduleController(table);
        }
예제 #6
0
        static void Main(string[] args)
        {
            Poker           poker      = new Poker();
            ServerView      view       = new ServerView();
            PokerController controller = new PokerController(poker, view);

            controller.startServer();
        }
예제 #7
0
        private void Raise_Click(object sender, RoutedEventArgs e)
        {
            //PokerController.Raise(0);
            int betAmount = (int)sBetAmount.Value;

            if (betAmount > 0 && PokerController.ValidateFunds(betAmount))
            {
                PokerController.Raise(betAmount);
                UpdateGameStats();
            }
        }
        public void Usuario1Obtiene1Poker()
        {
            List <Carta> barajaPrueba = new List <Carta>();
            Carta        carta1       = new Carta();

            carta1.Id     = 1;
            carta1.Digito = 2;
            carta1.Nombre = "Trebol";
            carta1.IdUser = 1;

            Carta carta2 = new Carta();

            carta2.Id     = 2;
            carta2.Digito = 2;
            carta2.Nombre = "Diamante";
            carta2.IdUser = 1;

            Carta carta3 = new Carta();

            carta3.Id     = 3;
            carta3.Digito = 2;
            carta3.Nombre = "Trebol";
            carta3.IdUser = 1;

            Carta carta4 = new Carta();

            carta4.Id     = 4;
            carta4.Digito = 4;
            carta4.Nombre = "Pica";
            carta4.IdUser = 1;

            Carta carta5 = new Carta();

            carta5.Id     = 5;
            carta5.Digito = 2;
            carta5.Nombre = "Corazon";
            carta5.IdUser = 1;

            barajaPrueba.Add(carta1);
            barajaPrueba.Add(carta2);
            barajaPrueba.Add(carta3);
            barajaPrueba.Add(carta4);
            barajaPrueba.Add(carta5);

            var pokerMock = new Mock <IPokerRepository>();

            pokerMock.Setup(o => o.ValorMano(barajaPrueba));

            var pokController = new PokerController(pokerMock.Object);
            var val           = pokController.ValorMano(barajaPrueba);

            Assert.IsInstanceOf <RedirectToActionResult>(val);
        }
예제 #9
0
    /**
     * 单张比大小
     * 先比点数大小
     * 点数一样比花色
     */
    private bool CompareSingle(PokerController selectedCard, PokerController lastPlayCard)
    {
        if (selectedCard.poker.point > lastPlayCard.poker.point)
        {
            return(true);
        }
        if (selectedCard.poker.point == lastPlayCard.poker.point)
        {
            return(selectedCard.poker.color > lastPlayCard.poker.color);
        }

        return(false);
    }
예제 #10
0
        private void NextPhase()
        {
            if (PokerController.NextPhase())
            {
                ;
            }
            //if (PokerController.NextPhase())
            //{
            //    if (Flop)
            //    {

            //    }
            //    else if (Turn)
            //    {

            //    }
            //    else if (River)
            //    {

            //    }
            //}
        }
예제 #11
0
        public void TestResult()
        {
            Round r = new Round();

            r.Hands = new List <Play>();
            r.Hands.Add(new Play()
            {
                Name = "Bill", Hand = new List <string>()
                {
                    "2C", "3H", "4S", "8C", "AH"
                }
            });
            r.Hands.Add(new Play()
            {
                Name = "Bob", Hand = new List <string>()
                {
                    "2H", "3D", "5S", "9C", "KD"
                }
            });
            var actionResult = new PokerController().Post(r);

            Assert.IsInstanceOfType(actionResult, typeof(OkNegotiatedContentResult <string>),
                                    "Should return an OkResult under normal conditions.");
        }
예제 #12
0
        public void MissingDataTest()
        {
            //Missing data should cause the API to return a bad request, not crash and burn.
            PokerController p            = new PokerController();
            var             actionResult = p.Post(null);

            Assert.IsInstanceOfType(actionResult, typeof(BadRequestErrorMessageResult),
                                    "No data should result in a BadRequestErrorMessageResult");
            Round r = new Round();

            Assert.IsInstanceOfType(actionResult, typeof(BadRequestErrorMessageResult),
                                    "Missing hand data should result in a BadRequestErrorMessageResult");

            r.Hands = new List <Play>();
            r.Hands.Add(new Play()
            {
                Name = "Bob", Hand = null
            });
            Assert.IsInstanceOfType(actionResult, typeof(BadRequestErrorMessageResult),
                                    "Missing hand data should result in a BadRequestErrorMessageResult");
            r.Hands = new List <Play>();
            r.Hands.Add(null);
            Assert.IsInstanceOfType(actionResult, typeof(BadRequestErrorMessageResult),
                                    "Missing hand data should result in a BadRequestErrorMessageResult");

            r.Hands = new List <Play>();
            r.Hands.Add(new Play()
            {
                Name = null, Hand = new List <string>()
                {
                    "2C", "3H", "4S", "8C", "AH", "2S"
                }
            });
            Assert.IsInstanceOfType(actionResult, typeof(BadRequestErrorMessageResult),
                                    "Missing hand data should result in a BadRequestErrorMessageResult");
        }
예제 #13
0
        public void WrongCardCountTest()
        {
            Round r = new Round();

            r.Hands = new List <Play>();
            r.Hands.Add(new Play()
            {
                Name = "Bob", Hand = new List <string>()
                {
                    "2C", "3H", "4S", "8C", "AH", "2S"
                }
            });
            r.Hands.Add(new Play()
            {
                Name = "Bill", Hand = new List <string>()
                {
                    "2H", "3D", "5S", "9C", "KD"
                }
            });
            var actionResult = new PokerController().Post(r);

            Assert.IsInstanceOfType(actionResult, typeof(BadRequestErrorMessageResult),
                                    "Wrong card count should return a BadRequestErrorMessageResult");
        }
예제 #14
0
        private void Bet_Click(object sender, RoutedEventArgs e)
        {
            if (sBetAmount.Value < 0)
            {
                UpdateStatusBar("Bet must be greter than 0, Try again");
            }

            if (PokerController.Bet((int)sBetAmount.Value))
            {
                if (firstBet)
                {
                    DisableOrEnableButtons();
                    firstBet = false;
                }

                UpdateStatusBar("Betting Successful!");
                UpdateGameStats();
                NextPlayerTurn();
            }
            else
            {
                UpdateStatusBar("Don't have enough funds!, Try again!");
            }
        }
예제 #15
0
 private void UpdateGameStats()
 {
     lbBank.Content = $"Amount in Bank: {PokerController.GetBank()}.";
     lbPot.Content  = $"Amount in Pot: {PokerController.GetPot()}.";
 }
예제 #16
0
 private void Call_Click(object sender, RoutedEventArgs e)
 {
     PokerController.Call();
     UpdateGameStats();
 }
예제 #17
0
 public void Awake()
 {
     instance = this;
     enabled=false;
 }
예제 #18
0
 private void Fold_Click(object sender, RoutedEventArgs e)
 {
     //PokerController.Fold();
     PokerController.Fold();
     NextPlayerTurn();
 }