Esempio 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());
        }
Esempio n. 2
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);
            }
        }