Ejemplo n.º 1
0
        public void HeadToHead3Players()
        {
            Game       g      = new Game(new GamePreferences());
            GameLogger logger = g.GetLogger();

            UserProfile Niv  = new UserProfile("Niv", "123");
            UserProfile Omer = new UserProfile("Omer", "456");
            UserProfile Naor = new UserProfile("Naor", "789");

            PlayingUser nivPlayer = new PlayingUser(Niv.Username, 1000, g);
            PlayingUser OPlayer   = new PlayingUser(Omer.Username, 1000, g);
            PlayingUser NPlayer   = new PlayingUser(Naor.Username, 1000, g);

            g.addPlayer(nivPlayer);
            g.addPlayer(OPlayer);
            g.addPlayer(NPlayer);

            nivPlayer.SetFakeUserInput(new Queue <string>(new[] { "5", "50", "50", "100", "0" }));
            OPlayer.SetFakeUserInput(new Queue <string>(new[] { "0", "50", "50", "100", "0" }));
            NPlayer.SetFakeUserInput(new Queue <string>(new[] { "10", "100", "0", "100", "0" }));

            g.StartGame();
            BetMove lastMove = (BetMove)logger.GetMoves().ElementAt(logger.GetMoves().Count - 1);
            IDictionary <string, int> playerBets = lastMove.GetPlayerBets();
            int potSize = 0;

            foreach (string s in playerBets.Keys)
            {
                potSize += playerBets[s];
            }

            Assert.AreEqual(1000 + 420, OPlayer.GetCredit());
        }
Ejemplo n.º 2
0
        public void CheckGameReplay_29Moves()
        {
            Game       g      = new Game(new GamePreferences());
            GameLogger logger = g.GetLogger();

            UserProfile Niv   = new UserProfile("Niv", "123");
            UserProfile Omer  = new UserProfile("Omer", "456");
            UserProfile Naor  = new UserProfile("Naor", "789");
            UserProfile Koren = new UserProfile("Koren", "9");
            UserProfile Ohad  = new UserProfile("Ohad", "8");



            PlayingUser nivPlayer = new PlayingUser(Niv.Username, 1000, g);
            PlayingUser OPlayer   = new PlayingUser(Omer.Username, 1000, g);
            PlayingUser NPlayer   = new PlayingUser(Naor.Username, 1000, g);
            PlayingUser KPlayer   = new PlayingUser(Koren.Username, 1000, g);
            PlayingUser OhPlayer  = new PlayingUser(Ohad.Username, 1000, g);

            g.addPlayer(nivPlayer);
            g.addPlayer(OPlayer);
            g.addPlayer(NPlayer);
            g.addPlayer(KPlayer);
            g.addPlayer(OhPlayer);

            nivPlayer.SetFakeUserInput(new Queue <string>(new[] { "5", "0", "100" }));
            OPlayer.SetFakeUserInput(new Queue <string>(new[] { "0", "0", "100", "100", "0", "50", "Fold" }));
            NPlayer.SetFakeUserInput(new Queue <string>(new[] { "10", "100", "100", "100" }));
            KPlayer.SetFakeUserInput(new Queue <string>(new[] { "10", "100", "100", "100" }));
            OhPlayer.SetFakeUserInput(new Queue <string>(new[] { "10", "100", "100", "100" }));

            g.StartGame();

            Assert.AreEqual(29, logger.GetMoves().Count);
        }
Ejemplo n.º 3
0
        public void ValidBetMove()
        {
            Game       g      = new Game(new GamePreferences());
            GameLogger logger = g.GetLogger();

            UserProfile Niv  = new UserProfile("Niv", "123");
            UserProfile Omer = new UserProfile("Omer", "456");

            PlayingUser nivPlayer = new PlayingUser(Niv.Username, 1000, g);
            PlayingUser OPlayer   = new PlayingUser(Omer.Username, 1000, g);

            g.addPlayer(nivPlayer);
            g.addPlayer(OPlayer);

            nivPlayer.SetFakeUserInput(new Queue <string>(new[] { "5", "0" }));
            OPlayer.SetFakeUserInput(new Queue <string>(new[] { "0" }));

            g.StartGame();

            IDictionary <string, int> playerBets = new Dictionary <string, int>();

            playerBets.Add(nivPlayer.GetUserName(), 5);
            playerBets.Add(OPlayer.GetUserName(), 10);
            BetMove bm = new BetMove(playerBets, OPlayer, 10);
            BetMove compareToBetMove = ((BetMove)logger.GetMoves()[2]); //third move in game -> bigblind (first = start game, second = small blind, third=bigblind)


            foreach (string s in bm.GetPlayerBets().Keys)
            {
                int testBet = bm.GetPlayerBets()[s];
                int gameBet = compareToBetMove.GetPlayerBets()[s];
                Assert.AreEqual(testBet, gameBet);
            }
        }