Example #1
0
        public void CheckSpecialHands2()
        {
            GamingTable gamingTable = new GamingTable();

            Dictionary <int, HandWarGame <CardWarGame> > players = new Dictionary <int, HandWarGame <CardWarGame> >();

            HandWarGame <CardWarGame> Hand1 = new HandWarGame <CardWarGame>();

            HandWarGame <CardWarGame> Hand2 = new HandWarGame <CardWarGame>();

            Hand2.AddCard(new CardWarGame(CardValueEnum.Five, CardColorEnum.Spade));
            Hand2.AddCard(new CardWarGame(CardValueEnum.Six, CardColorEnum.Spade));
            Hand2.AddCard(new CardWarGame(CardValueEnum.Seven, CardColorEnum.Spade));
            Hand2.AddCard(new CardWarGame(CardValueEnum.Height, CardColorEnum.Spade));

            HandWarGame <CardWarGame> Hand3 = new HandWarGame <CardWarGame>();

            players.Add(1, Hand1);
            players.Add(2, Hand2);
            players.Add(3, Hand3);


            TableHistory tableHistory = gamingTable.PlayGameWhithGivenHand(players);

            Assert.AreEqual(2, tableHistory.GetHistories()[0].GetWinner());
        }
        public void TieBreakNotTheSameNumberOfCardTest()
        {
            Dictionary <int, HandWarGame <CardWarGame> > players = new Dictionary <int, HandWarGame <CardWarGame> >();

            HandWarGame <CardWarGame> Hand1 = new HandWarGame <CardWarGame>();

            Hand1.AddCard(new CardWarGame(CardValueEnum.Five, CardColorEnum.Spade));
            Hand1.AddCard(new CardWarGame(CardValueEnum.Ace, CardColorEnum.Spade));

            HandWarGame <CardWarGame> Hand2 = new HandWarGame <CardWarGame>();

            Hand2.AddCard(new CardWarGame(CardValueEnum.Five, CardColorEnum.Clover));
            Hand2.AddCard(new CardWarGame(CardValueEnum.Three, CardColorEnum.Clover));
            Hand2.AddCard(new CardWarGame(CardValueEnum.King, CardColorEnum.Clover));

            players.Add(1, Hand1);
            players.Add(2, Hand2);

            GameWar dealerWarGame = new GameWar(players);

            dealerWarGame.Play();
            GameHistory history = dealerWarGame.GetHistory();

            Assert.AreEqual(2, history.GetWinner());
        }
        public void SameCardInDifferentHandTest()
        {
            Dictionary <int, HandWarGame <CardWarGame> > players = new Dictionary <int, HandWarGame <CardWarGame> >();

            HandWarGame <CardWarGame> Hand1 = new HandWarGame <CardWarGame>();

            Hand1.AddCard(new CardWarGame(CardValueEnum.Five, CardColorEnum.Spade));

            HandWarGame <CardWarGame> Hand2 = new HandWarGame <CardWarGame>();

            Hand2.AddCard(new CardWarGame(CardValueEnum.Five, CardColorEnum.Spade));

            players.Add(1, Hand1);
            players.Add(2, Hand2);

            GameWar dealerWarGame = new GameWar(players);

            dealerWarGame.Play();
        }
        public void HandOneCardEqualValueTest()
        {
            Dictionary <int, HandWarGame <CardWarGame> > players = new Dictionary <int, HandWarGame <CardWarGame> >();

            HandWarGame <CardWarGame> Hand1 = new HandWarGame <CardWarGame>();

            Hand1.AddCard(new CardWarGame(CardValueEnum.Five, CardColorEnum.Clover));

            HandWarGame <CardWarGame> Hand2 = new HandWarGame <CardWarGame>();

            Hand2.AddCard(new CardWarGame(CardValueEnum.Five, CardColorEnum.Spade));

            players.Add(1, Hand1);
            players.Add(2, Hand2);

            GameWar dealerWarGame = new GameWar(players);

            dealerWarGame.Play();
            GameHistory history = dealerWarGame.GetHistory();

            Assert.AreEqual(-1, history.GetWinner());
        }