Exemplo n.º 1
0
		// Two Pair
		else if {
			if (CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.SecondCard.getCardNo()).getRank() && CardsInHand.get(eCardNo.ThidCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.FourthCard.getCardNo()).getRank()) {
				ScoreHand(eHandStrength.TwoPair,CardsInHand.get(eCardNo.ThirdCard.getCardNo()).getRank().getRank(),CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank().getRank(),0);
			} else if (CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.SecondCard.getCardNo()).getRank() && CardsInHand.get(eCardNo.FourthCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.FifthCard.getCardNo()).getRank()) {
				ScoreHand(eHandStrength.TwoPair,CardsInHand.get(eCardNo.FourthCard.getCardNo()).getRank().getRank(),CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank().getRank(),0);	
			} else if (CardsInHand.get(eCardNo.SecondCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.ThirdCard.getCardNo()).getRank() && CardsInHand.get(eCardNo.FourthCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.FifthCard.getCardNo()).getRank()) {
				ScoreHand(eHandStrength.TwoPair,CardsInHand.get(eCardNo.FourthCard.getCardNo()).getRank().getRank(),CardsInHand.get(eCardNo.SecondCard.getCardNo()).getRank().getRank(),0);
			}
		}	
Exemplo n.º 2
0
  @Test
  public void HighCard() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.KING, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.THREE, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.TWO, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.ACE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.HighCard.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.ACE.getRank());
    assertTrue(h.getLowPairStrength() == 0);
    assertTrue(h.getKicker().size() == 4);

    Card c1 = h.getKicker().get(eCardNo.FirstCard.getCardNo());
    Card c2 = h.getKicker().get(eCardNo.SecondCard.getCardNo());
    Card c3 = h.getKicker().get(eCardNo.ThirdCard.getCardNo());
    Card c4 = h.getKicker().get(eCardNo.FourthCard.getCardNo());

    //	Check value of kicker
    assertTrue(c1.getRank().getRank() == eRank.KING.getRank());

    //	Check value of kicker
    assertTrue(c2.getRank().getRank() == eRank.TEN.getRank());

    //	Check value of kicker
    assertTrue(c3.getRank().getRank() == eRank.THREE.getRank());

    //	Check value of kicker
    assertTrue(c4.getRank().getRank() == eRank.TWO.getRank());
  }
Exemplo n.º 3
0
  @Test
  public void ThreeOfAKind_3() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.TWO, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.THREE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.ThreeOfAKind.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.TEN.getRank());
    assertTrue(h.getLowPairStrength() == 0);
    assertTrue(h.getKicker().size() == 2);

    Card c1 = h.getKicker().get(eCardNo.FirstCard.getCardNo());
    Card c2 = h.getKicker().get(eCardNo.SecondCard.getCardNo());

    //	Check to see if the first kicker is a THREE
    assertTrue(c1.getRank().getRank() == eRank.THREE.getRank());

    //	Check to see if the second kicker is a TWO
    assertTrue(c2.getRank().getRank() == eRank.TWO.getRank());
  }
Exemplo n.º 4
0
		// Three of a Kind
		else if {
			if (CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.ThirdCard.getCardNo()).getRank()) {
				ScoreHand(eHandStrength.ThreeOfAKind,0,0,0);
			} else if (CardsInHand.get(eCardNo.SecondCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.FourthCard.getCardNo()).getRank()) {
				ScoreHand(eHandStrength.ThreeOfAKind,0,0,0);
			} else if (CardsInHand.get(eCardNo.ThirdCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.FifthCard.getCardNo()).getRank()) {
				ScoreHand(eHandStrength.ThreeOfAKind,0,0,0);
			}
		}
Exemplo n.º 5
0
		// High Card
		//	I'll give you this one :)
		else {
			ScoreHand(eHandStrength.HighCard,CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank().getRank(), 0,CardsInHand.get(eCardNo.SecondCard.getCardNo()).getRank().getRank());
		}
Exemplo n.º 6
0
	public void EvalHand() {
		// Evaluates if the hand is a flush and/or straight then figures out
		// the hand's strength attributes

		// Sort the cards!
		Collections.sort(CardsInHand, Card.CardRank);

		// Ace Evaluation
		if (CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank() == eRank.ACE) {
			Ace = true;
		}

		// Flush Evaluation
		if (CardsInHand.get(eCardNo.FirstCard.getCardNo()).getSuit() == CardsInHand
				.get(eCardNo.SecondCard.getCardNo()).getSuit()
				&& CardsInHand.get(eCardNo.FirstCard.getCardNo()).getSuit() == CardsInHand
						.get(eCardNo.ThirdCard.getCardNo()).getSuit()
				&& CardsInHand.get(eCardNo.FirstCard.getCardNo()).getSuit() == CardsInHand
						.get(eCardNo.FourthCard.getCardNo()).getSuit()
				&& CardsInHand.get(eCardNo.FirstCard.getCardNo()).getSuit() == CardsInHand
						.get(eCardNo.FifthCard.getCardNo()).getSuit()) {
			Flush = true;
		} else {
			Flush = false;
		}

		// five of a Kind

		if (CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank() == CardsInHand
				.get(eCardNo.FifthCard.getCardNo()).getRank()) {
			ScoreHand(eHandStrength.FiveOfAKind,
					CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank()
							.getRank(), 0, 0);
		}

		// Straight Evaluation
		else if (Ace) {
			// Looks for Ace, King, Queen, Jack, 10
			if (CardsInHand.get(eCardNo.SecondCard.getCardNo()).getRank() == eRank.KING
					&& CardsInHand.get(eCardNo.ThirdCard.getCardNo()).getRank() == eRank.QUEEN
					&& CardsInHand.get(eCardNo.FourthCard.getCardNo())
							.getRank() == eRank.JACK
					&& CardsInHand.get(eCardNo.FifthCard.getCardNo()).getRank() == eRank.TEN) {
				Straight = true;
				// Looks for Ace, 2, 3, 4, 5
			} else if (CardsInHand.get(eCardNo.FifthCard.getCardNo()).getRank() == eRank.TWO
					&& CardsInHand.get(eCardNo.FourthCard.getCardNo())
							.getRank() == eRank.THREE
					&& CardsInHand.get(eCardNo.ThirdCard.getCardNo()).getRank() == eRank.FOUR
					&& CardsInHand.get(eCardNo.SecondCard.getCardNo())
							.getRank() == eRank.FIVE) {
				Straight = true;
			} else {
				Straight = false;
			}
			// Looks for straight without Ace
		} else if (CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank()
				.getRank() == CardsInHand.get(eCardNo.SecondCard.getCardNo())
				.getRank().getRank() + 1
				&& CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank()
						.getRank() == CardsInHand
						.get(eCardNo.ThirdCard.getCardNo()).getRank().getRank() + 2
				&& CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank()
						.getRank() == CardsInHand
						.get(eCardNo.FourthCard.getCardNo()).getRank()
						.getRank() + 3
				&& CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank()
						.getRank() == CardsInHand
						.get(eCardNo.FifthCard.getCardNo()).getRank().getRank() + 4) {
			Straight = true;
		} else {
			Straight = false;
		}

		// Evaluate Royal Flush
		if (Straight == true
				&& Flush == true
				&& CardsInHand.get(eCardNo.FifthCard.getCardNo()).getRank() == eRank.TEN
				&& Ace) {
			ScoreHand(eHandStrength.RoyalFlush, 0, 0, 0);
		}

		// Straight Flush
		else if (Straight == true && Flush == true) {
			ScoreHand(eHandStrength.StraightFlush,
					CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank()
							.getRank(), 0, 0);
		}
		
		// Four of a Kind
		if {
			if (CardsInHand.get(eCardNo.FirstCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.FourthCard.getCardNo()).getRank()) {
				ScoreHand(eHandStrength.FourOfAKind,0,0,0);
			} else if (CardsInHand.get(eCardNo.SecondCard.getCardNo()).getRank() == CardsInHand.get(eCardNo.FifthCard.getCardNo()).getRank()) {
				ScoreHand(eHandStrength.FourOfAKind,0,0,0);
			}
		} 
		
		// Full House
		else if {