Example #1
0
 protected String getTargetDescriptionForLog(Targets targets, Game game) {
   StringBuilder sb =
       new StringBuilder(); // threadLocal StringBuilder can't be used because calling method
   // already uses it
   if (targets.size() > 0) {
     String usedVerb = null;
     for (Target target : targets) {
       if (!target.getTargets().isEmpty()) {
         if (!target.isNotTarget()) {
           if (usedVerb == null || usedVerb.equals(" choosing ")) {
             usedVerb = " targeting ";
             sb.append(usedVerb);
           }
         } else if (target.isNotTarget() && (usedVerb == null || usedVerb.equals(" targeting "))) {
           usedVerb = " choosing ";
           sb.append(usedVerb);
         }
         sb.append(target.getTargetedName(game));
       }
     }
   }
   return sb.toString();
 }
Example #2
0
 protected String getMessageText(Game game) {
   StringBuilder sb = threadLocalBuilder.get();
   MageObject object = game.getObject(this.sourceId);
   if (object != null) {
     if (object instanceof StackAbility) {
       Card card = game.getCard(((StackAbility) object).getSourceId());
       if (card != null) {
         sb.append(GameLog.getColoredObjectIdName(card));
       } else {
         sb.append(GameLog.getColoredObjectIdName(object));
       }
     } else if (object instanceof Spell) {
       Spell spell = (Spell) object;
       String castText = spell.getSpellCastText(game);
       sb.append((castText.startsWith("Cast ") ? castText.substring(5) : castText));
       if (spell.getFromZone() == Zone.GRAVEYARD) {
         sb.append(" from graveyard");
       }
       sb.append(getOptionalTextSuffix(game, spell));
     } else {
       sb.append(GameLog.getColoredObjectIdName(object));
     }
   } else {
     sb.append("unknown");
   }
   if (object instanceof Spell && ((Spell) object).getSpellAbilities().size() > 1) {
     if (((Spell) object)
         .getSpellAbility()
         .getSpellAbilityType()
         .equals(SpellAbilityType.SPLIT_FUSED)) {
       Spell spell = (Spell) object;
       int i = 0;
       for (SpellAbility spellAbility : spell.getSpellAbilities()) {
         i++;
         String half;
         if (i == 1) {
           half = " left";
         } else {
           half = " right";
         }
         if (spellAbility.getTargets().size() > 0) {
           sb.append(half).append(" half targeting ");
           for (Target target : spellAbility.getTargets()) {
             sb.append(target.getTargetedName(game));
           }
         }
       }
     } else {
       Spell spell = (Spell) object;
       int i = 0;
       for (SpellAbility spellAbility : spell.getSpellAbilities()) {
         i++;
         if (i > 1) {
           sb.append(" splicing ");
           if (spellAbility.name.length() > 5 && spellAbility.name.startsWith("Cast ")) {
             sb.append(spellAbility.name.substring(5));
           } else {
             sb.append(spellAbility.name);
           }
         }
         sb.append(getTargetDescriptionForLog(spellAbility.getTargets(), game));
       }
     }
   } else if (object instanceof Spell
       && ((Spell) object).getSpellAbility().getModes().size() > 1) {
     Modes spellModes = ((Spell) object).getSpellAbility().getModes();
     for (Mode selectedMode : spellModes.getSelectedModes()) {
       int item = 0;
       for (Mode mode : spellModes.values()) {
         item++;
         if (mode.getId().equals(selectedMode.getId())) {
           sb.append(" (mode ").append(item).append(")");
           sb.append(getTargetDescriptionForLog(selectedMode.getTargets(), game));
           break;
         }
       }
     }
   } else {
     sb.append(getTargetDescriptionForLog(getTargets(), game));
   }
   return sb.toString();
 }