예제 #1
0
 @Override
 public boolean apply(Game game, Ability source) {
   for (Permanent permanent :
       game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
     if (permanent != null) {
       permanent.changeControllerId(source.getControllerId(), game);
     }
   }
   return true;
 }
예제 #2
0
 @Override
 public boolean apply(Game game, Ability source) {
   Permanent permanent = game.getPermanent(source.getFirstTarget());
   if (targetPointer != null) {
     permanent = game.getPermanent(targetPointer.getFirst(game, source));
   }
   if (permanent != null) {
     return permanent.changeControllerId(source.getControllerId(), game);
   }
   return false;
 }
예제 #3
0
 @Override
 public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
   Permanent permanent = game.getPermanent(source.getFirstTarget());
   if (permanent != null) {
     switch (layer) {
       case ControlChangingEffects_2:
         if (sublayer == SubLayer.NA) {
           permanent.changeControllerId(source.getControllerId(), game);
         }
         break;
       case TypeChangingEffects_4:
         if (sublayer == SubLayer.NA) {
           permanent.getSubtype().add("Vampire");
         }
         break;
     }
     return true;
   }
   return false;
 }
예제 #4
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
      return false;
    }

    int cmc = 0;
    for (Cost cost : source.getCosts()) {
      if (cost instanceof PayVariableLoyaltyCost) {
        cmc = ((PayVariableLoyaltyCost) cost).getAmount();
      }
    }

    FilterCard filter =
        new FilterCreatureCard(
            new StringBuilder("creature card with converted mana cost {")
                .append(cmc)
                .append("} exiled with Ashiok, Nightmare Weaver")
                .toString());
    filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, cmc));
    Target target = new TargetCardInExile(filter, CardUtil.getCardExileZoneId(game, source));

    if (target.canChoose(source.getSourceId(), player.getId(), game)) {
      if (player.chooseTarget(Outcome.PutCreatureInPlay, target, source, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null
            && player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId())) {
          Permanent permanent = game.getPermanent(card.getId());
          if (permanent != null) {
            permanent.changeControllerId(source.getControllerId(), game);
          }
          ContinuousEffectImpl effect = new AshiokNightmareWeaverAddTypeEffect();
          effect.setTargetPointer(new FixedTarget(card.getId()));
          game.addEffect(effect, source);
          return true;
        }
      }
    }
    return false;
  }