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); }
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); }
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); }
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); }
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); }
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)); }
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); }
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); }
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); }
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); }
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); }
public PlayerAction TakeTurn(Hand DealerHand) { return DecisionHelper.MakeDecision(DealerHand, this.Hand.First()); }
private static PlayerAction StandardHand(Hand DealerHand, Hand PlayerHand) { return PlayerAction.Stand; }
private static PlayerAction SplittableHand(Hand DealerHand, Hand PlayerHand) { return PlayerAction.Stand; }
private static PlayerAction HasAceHand(Hand DealerHand, Hand PlayerHand) { return PlayerAction.Stand; }