Example #1
0
 void updateRemembered(Card c) {
   if (c.getRemembered() == null) {
     set(TrackableProperty.Remembered, null);
     return;
   }
   StringBuilder sb = new StringBuilder();
   sb.append("\r\nRemembered: \r\n");
   for (final Object o : c.getRemembered()) {
     if (o instanceof Card) {
       final Card card = (Card) o;
       if (card.isFaceDown()) {
         sb.append("Face Down");
         // face-down cards don't show unique number to avoid cheating
       } else {
         sb.append(card.getName());
         sb.append(" (");
         sb.append(card.getId());
         sb.append(")");
       }
     } else if (o != null) {
       sb.append(o.toString());
     }
     sb.append("\r\n");
   }
   set(TrackableProperty.Remembered, sb.toString());
 }
Example #2
0
  public String getText(CardStateView state) {
    final StringBuilder sb = new StringBuilder();
    // final boolean isSplitCard = (state.getState() == CardStateName.LeftSplit);

    if (getId() < 0) {
      if (isSplitCard()) {
        sb.append("(").append(state.getName()).append(") ");
        sb.append(state.getOracleText());
        sb.append("\r\n\r\n");
        sb.append("(").append(getAlternateState().getName()).append(") ");
        sb.append(getAlternateState().getOracleText());
        return sb.toString().trim();
      } else {
        return state.getOracleText();
      }
    }

    final String rulesText = state.getRulesText();
    if (!rulesText.isEmpty()) {
      sb.append(rulesText).append("\r\n\r\n");
    }
    if (isCommander()) {
      sb.append(getOwner()).append("'s Commander\r\n");
      sb.append(getOwner().getCommanderInfo()).append("\r\n");
    }

    if (isSplitCard()) {
      CardStateView view =
          state.getState() == CardStateName.LeftSplit ? state : getAlternateState();
      if (getZone() != ZoneType.Stack) {
        sb.append("(");
        sb.append(view.getName());
        sb.append(") ");
      }
      sb.append(view.getAbilityText());
    } else {
      sb.append(state.getAbilityText());
    }

    if (isSplitCard() && getZone() != ZoneType.Stack) {
      // ensure ability text for right half of split card is included unless spell is on stack
      sb.append("\r\n\r\n")
          .append("(")
          .append(getAlternateState().getName())
          .append(") ")
          .append(getAlternateState().getOracleText());
    }

    String nonAbilityText = get(TrackableProperty.NonAbilityText);
    int blockAdditional = state.getBlockAdditional();
    if (blockAdditional > 1) {
      final StringBuilder ab = new StringBuilder();
      ab.append("CARDNAME can block an additional ");
      ab.append(blockAdditional);
      ab.append(" creatures.");
      nonAbilityText =
          nonAbilityText.replaceFirst("CARDNAME can block an additional creature.", ab.toString());
      nonAbilityText = nonAbilityText.replaceAll("CARDNAME can block an additional creature.", "");
      nonAbilityText = nonAbilityText.replaceAll("\r\n\r\n\r\n", "");
    }
    if (!nonAbilityText.isEmpty()) {
      sb.append("\r\n \r\nNon ability features: \r\n");
      sb.append(nonAbilityText.replaceAll("CARDNAME", getName()));
    }

    sb.append(getRemembered());

    PlayerView chosenPlayer = getChosenPlayer();
    if (chosenPlayer != null) {
      sb.append("\r\n[Chosen player: ");
      sb.append(chosenPlayer);
      sb.append("]\r\n");
    }

    Direction chosenDirection = getChosenDirection();
    if (chosenDirection != null) {
      sb.append("\r\n[Chosen direction: ");
      sb.append(chosenDirection);
      sb.append("]\r\n");
    }

    Iterable<CardView> hauntedBy = getHauntedBy();
    if (hauntedBy != null) {
      sb.append("Haunted by: ");
      boolean needDelim = false;
      for (final CardView c : hauntedBy) {
        if (needDelim) {
          sb.append(",");
        } else {
          needDelim = false;
        }
        sb.append(c);
      }
      sb.append("\r\n");
    }

    CardView haunting = getHaunting();
    if (haunting != null) {
      sb.append("Haunting: ").append(haunting);
      sb.append("\r\n");
    }

    CardView pairedWith = getPairedWith();
    if (pairedWith != null) {
      sb.append("\r\n \r\nPaired With: ").append(pairedWith);
      sb.append("\r\n");
    }

    String cloner = get(TrackableProperty.Cloner);
    if (!cloner.isEmpty()) {
      sb.append("\r\nCloned by: ").append(cloner);
    }

    return sb.toString().trim();
  }