Esempio n. 1
0
  DefaultCardDealer(final ImmutableSet<Card> baseDeck) {
    Arguments.checkIsNotNull(baseDeck, "baseDeck");

    this.baseDeck = baseDeck;

    // initial deck shuffle
    liveDeck.addAll(Randomness.shuffle(baseDeck));
    liveDeckItr = liveDeck.iterator();
  }
Esempio n. 2
0
  private void reshuffle() {
    // @formatter:off [workaround for Eclipse 4.5 formatter bug; see 470977 for status]
    assert !discardPile.isEmpty() || !liveDeck.isEmpty();
    // @formatter:on

    // in case reshuffle is called early for any reason, add any remaining cards in liveDeck to
    // discard pile
    // and log a warning message
    if (liveDeck.size() > 0) {
      log.warn(
          "Early call to reshuffle; moving {} cards from deck to discard pile...", liveDeck.size());
      discardPile.addAll(liveDeck);
      liveDeck.clear();
    }
    liveDeck.addAll(Randomness.shuffle(discardPile));
    discardPile.clear();
    liveDeckItr = liveDeck.iterator();
  }