private void updateTargets(Game game, StackAbility ability) {
    List<String> names = new ArrayList<>();
    for (Mode mode : ability.getModes().getSelectedModes()) {
      if (mode.getTargets().size() > 0) {
        setTargets(mode.getTargets());
      } else {
        List<UUID> targetList = new ArrayList<>();
        for (Effect effect : mode.getEffects()) {
          TargetPointer targetPointer = effect.getTargetPointer();
          if (targetPointer instanceof FixedTarget) {
            targetList.add(((FixedTarget) targetPointer).getTarget());
          }
        }
        if (targetList.size() > 0) {
          overrideTargets(targetList);

          for (UUID uuid : targetList) {
            MageObject mageObject = game.getObject(uuid);
            if (mageObject != null) {
              if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) {
                continue;
              }
              names.add(GameLog.getColoredObjectIdNameForTooltip(mageObject));
            }
          }
        }
      }
    }
    if (!names.isEmpty()) {
      getRules().add("<i>Related objects: " + names.toString() + "</i>");
    }
    // show for modal ability, which mode was choosen
    if (ability.isModal()) {
      Modes modes = ability.getModes();
      for (Mode mode : modes.getSelectedModes()) {
        this.rules.add(
            "<span color='green'><i>Chosen mode: "
                + mode.getEffects().getText(mode)
                + "</i></span>");
      }
    }
  }
Beispiel #2
0
 @Override
 public String getLogName() {
   return GameLog.getColoredObjectIdName(this);
 }
Beispiel #3
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();
 }