示例#1
0
        public void IsBlackJack_Test()
        {
            Hand hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.King));

            Assert.IsTrue(hand.IsBlackJack);

            hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Queen));

            Assert.IsTrue(hand.IsBlackJack);

            hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Jack));

            Assert.IsTrue(hand.IsBlackJack);

            hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Ten));

            Assert.IsTrue(hand.IsBlackJack);
        }
        public static PlayerAction MakeDecision(Hand DealerHand, Hand PlayerHand)
        {
            if (PlayerHand.IsSplittable) return DecisionHelper.SplittableHand(DealerHand, PlayerHand);

            if (PlayerHand.HasAce) return DecisionHelper.HasAceHand(DealerHand, PlayerHand);

            return DecisionHelper.HasAceHand(DealerHand, PlayerHand);
        }
示例#3
0
        public void BuildHandWithAce_Test()
        {
            Hand hand = new Hand();
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Five));

            Assert.AreEqual(16, hand.HighValue);
            Assert.AreEqual(6, hand.LowValue);
        }
示例#4
0
        public void BuildSimpleHand_Test()
        {
            Hand hand = new Hand();

            hand.Cards.Add(new Card(Suit.Clubs, CardType.Five));
            hand.Cards.Add(new Card(Suit.Diamonds, CardType.Five));

            Assert.AreEqual(10, hand.HighValue);
            Assert.AreEqual(10, hand.LowValue);
        }
示例#5
0
        public void BuildHandThreeCards_TwoAces_Test()
        {
            Hand hand = new Hand();
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Queen));

            Assert.AreEqual(32, hand.HighValue);
            Assert.AreEqual(12, hand.LowValue);
        }
示例#6
0
        public void HasAce_Test()
        {
            Hand hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Nine));
            Assert.IsTrue(hand.HasAce);

            hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Nine));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Nine));
            Assert.IsFalse(hand.HasAce);
        }
示例#7
0
        public void Decision_Test()
        {
            Hand dealerHand = new Hand();
            dealerHand.Cards.Add(new Card(Suit.Hearts, CardType.Ten));
            dealerHand.Cards.Add(new Card(Suit.Hearts, CardType.Seven));

            Hand playerHand = new Hand();
            playerHand.Cards.Add(new Card(Suit.Hearts, CardType.Ten));
            playerHand.Cards.Add(new Card(Suit.Hearts, CardType.Eight));

            Assert.AreEqual(PlayerAction.Stand, DecisionHelper.MakeDecision(dealerHand, playerHand));
        }
示例#8
0
        public void IsSplittable_Test()
        {
            Hand hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Nine));
            Assert.IsFalse(hand.IsSplittable);

            hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Nine));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Nine));
            Assert.IsTrue(hand.IsSplittable);

            hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Deuce));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Deuce));
            Assert.IsTrue(hand.IsSplittable);
        }
示例#9
0
        public void IsNotBlackJack_Test()
        {
            Hand hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Nine));

            Assert.IsFalse(hand.IsBlackJack);

            hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Ace));

            Assert.IsFalse(hand.IsBlackJack);

            hand = new Hand();
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.King));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Deuce));

            Assert.IsFalse(hand.IsBlackJack);
        }
示例#10
0
        public void IsBust_withTwoAces_NotBust_Test()
        {
            Hand hand = new Hand();
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Hearts, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.King));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Nine));

            Assert.IsFalse(hand.IsBust);
        }
示例#11
0
        public void IsBust_withAces_Test()
        {
            Hand hand = new Hand();
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Ace));
            hand.Cards.Add(new Card(Suit.Hearts, CardType.King));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.King));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Deuce));

            Assert.IsTrue(hand.IsBust);
        }
示例#12
0
        public void IsBust_Test()
        {
            Hand hand = new Hand();
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Queen));
            hand.Cards.Add(new Card(Suit.Hearts, CardType.King));
            hand.Cards.Add(new Card(Suit.Clubs, CardType.Three));

            Assert.IsTrue(hand.IsBust);
        }
示例#13
0
 public PlayerAction TakeTurn(Hand DealerHand)
 {
     return DecisionHelper.MakeDecision(DealerHand, this.Hand.First());
 }
示例#14
0
 private static PlayerAction StandardHand(Hand DealerHand, Hand PlayerHand)
 {
     return PlayerAction.Stand;
 }
示例#15
0
 private static PlayerAction SplittableHand(Hand DealerHand, Hand PlayerHand)
 {
     return PlayerAction.Stand;
 }
示例#16
0
 private static PlayerAction HasAceHand(Hand DealerHand, Hand PlayerHand)
 {
     return PlayerAction.Stand;
 }