コード例 #1
0
ファイル: Program.cs プロジェクト: Nivlipetz1/WSEP
        static void Main(string[] args)
        {
            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", "-1" }));
            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" }));


            ThreadStart childref    = new ThreadStart(g.StartGame);
            Thread      childThread = new Thread(childref);

            childThread.Start();
            OPlayer.SendMessage("hello world");
            nivPlayer.SendMessage("Got That!");
            //g.StartGame();
            int num_of_moves = g.GetLogger().GetMoves().Count;

            childThread.Join();

            Console.Write("");

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

            g.StartGame();
            Console.Write("");
        }
コード例 #2
0
ファイル: GamePlayTests.cs プロジェクト: Nivlipetz1/WSEP
        public void PlayersCloseBlindAndThenFold()
        {
            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", "0", "Fold" }));
            OPlayer.SetFakeUserInput(new Queue <string>(new[] { "0", "0", "Fold" }));
            NPlayer.SetFakeUserInput(new Queue <string>(new[] { "10", "100" }));

            g.StartGame();

            Assert.AreEqual(1020, NPlayer.GetCredit());
        }
コード例 #3
0
ファイル: GamePlayTests.cs プロジェクト: Nivlipetz1/WSEP
        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);
        }
コード例 #4
0
ファイル: GamePlayTests.cs プロジェクト: Nivlipetz1/WSEP
        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());
        }
コード例 #5
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);
            }
        }
コード例 #6
0
ファイル: GamePlayTests.cs プロジェクト: Nivlipetz1/WSEP
        public void AllPlayersCheck()
        {
            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", "0" }));
            OPlayer.SetFakeUserInput(new Queue <string>(new[] { "0" }));
            NPlayer.SetFakeUserInput(new Queue <string>(new[] { "10", "0" }));

            g.StartGame();
            int num_of_moves = g.GetLogger().GetMoves().Count;

            //game start - 1
            //blinds - 2
            //bets - 3
            //flop - 1
            //bets - 3
            //river - 1
            //bets - 3
            //turn - 1
            //bets - 3

            Assert.AreEqual(19, num_of_moves);
        }