/** * Returns player's card. * * @param player who is on turn. * @param trump suit. * @return Card object instance or null. */ public Card getPlayMethodCard(final Player player, final Suit trump) { Card result = null; for (final SuitIterator iterator = Suit.iterator(); iterator.hasNext(); ) { final Suit suit = iterator.next(); final Card card = player.getCards().findMinSuitCard(suit); if (card != null && !suit.equals(trump)) { final int suitCount = player.getCards().getSuitCount(suit); final boolean isSingle = suitCount == 1; final boolean isMeter = suitCount + getPassedSuitCardsCount(suit) == Rank.getRankCount(); final Card max = player.getCards().findMaxSuitCard(suit); final boolean powerSuit = max != null && isMaxSuitCardLeft(max, true); if (isSingle && !powerSuit && !isMeter && max != null && max.compareRankTo(Rank.King) <= 0) { if (result == null || result.compareRankTo(card) > 0) { result = card; } } } } return result; }
/** * Returns player's card. * * @param player who is on turn. * @return Card object instance or null. */ public Card getPlayMethodCard(final Player player) { for (final SuitIterator iterator = Suit.iterator(); iterator.hasNext(); ) { final Suit suit = iterator.next(); final int count = player.getCards().getSuitCount(suit); final Card jack = player.getCards().findCard(Rank.Jack, suit); final Card nine = player.getCards().findCard(Rank.Nine, suit); if (jack == null && nine != null && count > SINGLE_CARD_COUNT && !isMaxSuitCardLeft(nine, false)) { Player thirdDefencePlayer = getThirdDefencePlayer(); if (!isPlayerSuitAnnounce(thirdDefencePlayer, suit)) { return player.getCards().findMinSuitCard(suit); } } } return null; }