@Override public Card take() { Preconditions.checkIsTrue(liveDeck.size() > 0 || discardPile.size() > 0, "No cards available!"); if (needsReshuffle()) { reshuffle(); } final Card nextCard = liveDeckItr.next(); liveDeckItr.remove(); return nextCard; }
@Override public Card giveCard(final Id playerId, final TurnPhase turnPhase) { Arguments.checkIsNotNull(playerId, "playerId"); Arguments.checkIsNotNull(turnPhase, "turnPhase"); final int maxCardsInHand = rules.getMaxCardsInHand(turnPhase); Preconditions.checkIsTrue( playerCardHandler.countCardsInHand(playerId) < maxCardsInHand, Strings.format( "Player [{}] has reached maximum cards in hand [{}] for [{}]", playerId, maxCardsInHand, turnPhase)); final Card card = cardDealer.take(); playerCardHandler.addCardToHand(playerId, card); return card; }