private IHand generateRandomHighCard(StandardDeckFactory deckFactory) { ArrayList<Card> cards = pickNRandomDifferentCards(5); ImmutableSortedSet.Builder<Card> builder = ImmutableSortedSet.orderedBy(new Card.RankThenSuitComparer()); builder.add(cards.get(0)); builder.add(cards.get(1)); builder.add(cards.get(2)); builder.add(cards.get(3)); builder.add(cards.get(4)); return new SortedHand(builder.build()); }
private IHand generateRandomPair(StandardDeckFactory deckFactory) { SortedHand randomHand = new SortedHand(); ArrayList<Card> cards = pickNRandomDifferentCards(4); IDeck deck = deckFactory.build(); 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(cards.get(1)); builder.add(cards.get(2)); builder.add(cards.get(3)); return new SortedHand(builder.build()); }
private IHand generateRandomFlush(StandardDeckFactory deckFactory) { ArrayList<Card> cards = pickNRandomDifferentCards(5); Suit randomSuit = Suit.getRandomSuit(); IDeck deck = deckFactory.build(); ImmutableSortedSet.Builder<Card> builder = ImmutableSortedSet.orderedBy(new Card.RankThenSuitComparer()); builder.add(Card.from(cards.get(0).rank(), randomSuit)); builder.add(Card.from(cards.get(1).rank(), randomSuit)); builder.add(Card.from(cards.get(2).rank(), randomSuit)); builder.add(Card.from(cards.get(3).rank(), randomSuit)); builder.add(Card.from(cards.get(4).rank(), randomSuit)); return new SortedHand(builder.build()); }