private IHand generateRandomThreeOfAKind(StandardDeckFactory deckFactory) { ArrayList<Card> cards = pickNRandomDifferentCards(3); IDeck deck = deckFactory.build(); deck.shuffle(); ImmutableSortedSet.Builder<Card> builder = ImmutableSortedSet.orderedBy(new Card.RankThenSuitComparer()); builder.add(deck.pickRandom(cards.get(0).rank())); builder.add(deck.pickRandom(cards.get(0).rank())); builder.add(deck.pickRandom(cards.get(0).rank())); builder.add(cards.get(1)); builder.add(cards.get(2)); return new SortedHand(builder.build()); }
private IHand generateRandomFourOfAKind(StandardDeckFactory deckFactory) { SortedHand randomHand = new SortedHand(); Rank randomRank = Rank.getRandomRank(); IDeck deck = deckFactory.build(); ImmutableSortedSet.Builder<Card> builder = ImmutableSortedSet.orderedBy(new Card.RankThenSuitComparer()); builder.add(deck.pickRandom(randomRank)); builder.add(deck.pickRandom(randomRank)); builder.add(deck.pickRandom(randomRank)); builder.add(deck.pickRandom(randomRank)); builder.add(deck.dealTopCard()); return new SortedHand(builder.build()); }
private IHand generateRandomFullHouse(StandardDeckFactory deckFactory) { SortedHand randomHand = new SortedHand(); Rank randomTrips = Rank.getRandomRank(); Rank randomPair = null; while ((randomPair = Rank.getRandomRank()) == randomTrips) {} IDeck deck = deckFactory.build(); ImmutableSortedSet.Builder<Card> builder = ImmutableSortedSet.orderedBy(new Card.RankThenSuitComparer()); builder.add(deck.pickRandom(randomTrips)); builder.add(deck.pickRandom(randomTrips)); builder.add(deck.pickRandom(randomTrips)); builder.add(deck.pickRandom(randomPair)); builder.add(deck.pickRandom(randomPair)); return new SortedHand(builder.build()); }