예제 #1
0
  @Override
  public void resolve(SpellAbility sa) {
    final Card card = sa.getHostCard();
    final Game game = card.getGame();

    final boolean remDestroyed = sa.hasParam("RememberDestroyed");
    final boolean remAttached = sa.hasParam("RememberAttached");
    if (remDestroyed || remAttached) {
      card.clearRemembered();
    }

    final boolean noRegen = sa.hasParam("NoRegen");
    final boolean sac = sa.hasParam("Sacrifice");

    final List<Card> tgtCards = getTargetCards(sa);
    final List<Card> untargetedCards = new ArrayList<Card>();

    final TargetRestrictions tgt = sa.getTargetRestrictions();

    if (sa.hasParam("Radiance")) {
      for (final Card c :
          CardUtil.getRadiance(card, tgtCards.get(0), sa.getParam("ValidTgts").split(","))) {
        untargetedCards.add(c);
      }
    }

    for (final Card tgtC : tgtCards) {
      if (tgtC.isInPlay() && ((tgt == null) || tgtC.canBeTargetedBy(sa))) {
        boolean destroyed = false;
        final Card lki = CardUtil.getLKICopy(tgtC);
        if (remAttached) {
          card.addRemembered(tgtC.getEnchantedBy(false));
          card.addRemembered(tgtC.getEquippedBy(false));
          card.addRemembered(tgtC.getFortifiedBy(false));
        }
        if (sac) {
          destroyed = game.getAction().sacrifice(tgtC, sa) != null;
        } else if (noRegen) {
          destroyed = game.getAction().destroyNoRegeneration(tgtC, sa);
        } else {
          destroyed = game.getAction().destroy(tgtC, sa);
        }
        if (destroyed && remDestroyed) {
          card.addRemembered(tgtC);
        }
        if (destroyed && sa.hasParam("RememberLKI")) {
          card.addRemembered(lki);
        }
      }
    }

    for (final Card unTgtC : untargetedCards) {
      if (unTgtC.isInPlay()) {
        boolean destroyed = false;
        if (sac) {
          destroyed = game.getAction().sacrifice(unTgtC, sa) != null;
        } else if (noRegen) {
          destroyed = game.getAction().destroyNoRegeneration(unTgtC, sa);
        } else {
          destroyed = game.getAction().destroy(unTgtC, sa);
        }
        if (destroyed && remDestroyed) {
          card.addRemembered(unTgtC);
        }
      }
    }
  }