예제 #1
0
  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());
  }
예제 #2
0
  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());
  }
예제 #3
0
  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());
  }