コード例 #1
0
  /**
   * Returns player's card.
   *
   * @param player AI player.
   * @param opposite standard player.
   * @return Card object instance or null.
   */
  protected Card getPlayMethodCard(final Player player) {
    final Card result = player.getCards().findMaxSuitCard(game.getTrumpSuit());
    final Card rivalCard = getRival(player).getPlayedCard();

    if (result != null
        && rivalCard != null
        && (!rivalCard.getSuit().equals(game.getTrumpSuit())
            || rivalCard.getRank().compareTo(result.getRank()) < 0)) {
      if (player.getPoints(game.getTrumpSuit()) + Card.getPoints(rivalCard) + Card.getPoints(result)
          >= SantaseFacade.END_GAME_POINTS) {
        return result;
      }
    }
    return null;
  }
コード例 #2
0
  /**
   * Returns player's card.
   *
   * @param player AI player.
   * @param opposite player.
   * @return Card object instance or null.
   */
  protected Card getPlayMethodCard(final Player player) {
    Card result = null;
    for (PackIterator iterator = player.getCards().iterator(); iterator.hasNext(); ) {
      final Card card = iterator.next();
      final Pack pack = possibleEnemyCards(player, true);

      final Card bestSuitCard = pack.findMaxSuitCard(card.getSuit());
      final boolean isSingleCard = player.getCards().getSuitCount(card.getSuit()) == 1;

      if (isSingleCard
          && bestSuitCard != null
          && bestSuitCard.getRank().compareTo(card.getRank()) > 0) {
        if (result == null || result.getRank().compareTo(card.getRank()) > 0) {
          result = card;
        }
      }
    }
    return canPlayWithoutLoose(getRival(player), result) ? result : null;
  }