Browse files

fixed up three of a kind logic and added another test

  • Loading branch information...
1 parent ff88d85 commit f0ee4f3b316842c512594d5269b42e4bb0d8533f @jbass86 committed Nov 29, 2013
View
3 basic_poker_utils/src/jtj_holdem/game/utility/PokerHandUtility.java
@@ -179,10 +179,11 @@ public static PokerHand determineThreeOfAKind(final List<ICard> pHand){
List <ICard> kickers = new ArrayList<ICard>(pHand);
kickers.removeAll(numbers.get(number));
Collections.sort(kickers);
- while (kickers.size() > 3){
+ while (kickers.size() > 2){
kickers.remove(0);
}
hand = new PokerHand(EPokerHand.THREE_OF_A_KIND, numbers.get(number), kickers);
+ break;
}
}
return hand;
View
27 basic_poker_utils/src/jtj_holdem/tests/poker/PokerHandTests.java
@@ -256,7 +256,34 @@ public void testTwoPair3(){
verifyCardList(hand.getKickers(), kickers);
}
+ @Test
+ public void test3OfaKind1(){
+
+ List<ICard> initialCards = new ArrayList<ICard>();
+ initialCards.add(new Card(ECardNumber.KING, ECardSuit.CLUBS));
+ initialCards.add(new Card(ECardNumber.KING, ECardSuit.SPADES));
+ initialCards.add(new Card(ECardNumber.FOUR, ECardSuit.HEARTS));
+ initialCards.add(new Card(ECardNumber.KING, ECardSuit.DIAMONDS));
+ initialCards.add(new Card(ECardNumber.SEVEN, ECardSuit.DIAMONDS));
+ initialCards.add(new Card(ECardNumber.THREE, ECardSuit.CLUBS));
+ initialCards.add(new Card(ECardNumber.ACE, ECardSuit.SPADES));
+ List<ICard> handCards = new ArrayList<ICard>();
+ handCards.add(new Card(ECardNumber.KING, ECardSuit.CLUBS));
+ handCards.add(new Card(ECardNumber.KING, ECardSuit.SPADES));
+ handCards.add(new Card(ECardNumber.KING, ECardSuit.DIAMONDS));
+ List<ICard> kickers = new ArrayList<ICard>();
+ kickers.add(new Card(ECardNumber.ACE, ECardSuit.SPADES));
+ kickers.add(new Card(ECardNumber.SEVEN, ECardSuit.DIAMONDS));
+
+ PokerHand hand = PokerHandUtility.determineBestHand(initialCards);
+
+ Assert.assertEquals(hand.getHand(), EPokerHand.THREE_OF_A_KIND);
+ verifyCardList(hand.getCards(), handCards);
+ verifyCardList(hand.getKickers(), kickers);
+ }
+
+
private static void verifyCardList(final List<ICard> pList1, final List<ICard> pList2){
for (ICard card : pList1){
Assert.assertEquals(pList2.contains(card), true);
View
1 poker.front_end.2d/src/jtj_holdem/game/graphics2d/test/SlickTest.java
@@ -34,6 +34,7 @@
public SlickTest(String gamename){
super(gamename);
testDeck.populateDeck(false);
+ testDeck.shuffleDeck();
}
@Override

0 comments on commit f0ee4f3

Please sign in to comment.