@Override
 public boolean apply(Game game, Ability source) {
   for (Permanent permanent :
       game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game)) {
     permanent.destroy(source.getId(), game, false);
   }
   return true;
 }
Ejemplo n.º 2
0
 @Override
 public boolean apply(Game game, Ability source) {
   int randomNumber = (int) (Math.random() * 3);
   Permanent target = game.getPermanent(source.getTargets().get(randomNumber).getFirstTarget());
   if (target != null) {
     game.informPlayers(
         "Wild Swing: The randomly chosen target to destroy is " + target.getName());
     return target.destroy(source.getSourceId(), game, false);
   }
   return false;
 }
Ejemplo n.º 3
0
 @Override
 public boolean apply(Game game, Ability source) {
   for (Permanent permanent :
       game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
     if (permanent != null
         && permanent.getCardType().contains(CardType.ARTIFACT)
         && permanent.getManaCost().convertedManaCost() <= source.getManaCostsToPay().getX()) {
       permanent.destroy(source.getSourceId(), game, false);
     }
   }
   return true;
 }
Ejemplo n.º 4
0
 @Override
 public boolean apply(Game game, Ability source) {
   Permanent targetedLand = game.getPermanent(source.getFirstTarget());
   if (targetedLand != null) {
     targetedLand.destroy(source.getSourceId(), game, true);
     Player controller = game.getPlayer(targetedLand.getControllerId());
     if (controller != null) {
       controller.damage(2, source.getSourceId(), game, false, true);
     }
     return true;
   }
   return false;
 }
Ejemplo n.º 5
0
 @Override
 public boolean apply(Game game, Ability source) {
   int amount = source.getManaCostsToPay().getX();
   if (amount > 4) {
     for (Permanent permanent :
         game.getBattlefield()
             .getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
       permanent.destroy(source.getSourceId(), game, false);
     }
   }
   token.putOntoBattlefield(amount, game, source.getId(), source.getControllerId());
   return true;
 }
Ejemplo n.º 6
0
 @Override
 public boolean apply(Game game, Ability source) {
   Permanent permanent = game.getPermanent(source.getFirstTarget());
   if (permanent != null) {
     LinkedList<UUID> attachments = new LinkedList();
     attachments.addAll(permanent.getAttachments());
     for (UUID uuid : attachments) {
       Permanent aura = game.getPermanent(uuid);
       if (aura != null && aura.getSubtype().contains("Aura")) {
         aura.destroy(source.getId(), game, false);
       }
     }
   }
   return false;
 }
Ejemplo n.º 7
0
 @Override
 public boolean apply(Game game, Ability source) {
   Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
   if (creature != null) {
     ObjectColor color = creature.getColor(game);
     for (Permanent permanent :
         game.getBattlefield().getActivePermanents(FILTER, source.getControllerId(), game)) {
       if (permanent.getColor(game).shares(color) && permanent != creature) {
         permanent.destroy(source.getSourceId(), game, true);
       }
     }
     return true;
   }
   return false;
 }
Ejemplo n.º 8
0
 @Override
 public boolean apply(Game game, Ability source) {
   int amount = source.getManaCostsToPay().getX();
   token.putOntoBattlefield(amount, game, source.getSourceId(), source.getControllerId());
   List<UUID> tokens = token.getLastAddedTokenIds();
   if (amount > 4) {
     for (Permanent permanent :
         game.getBattlefield()
             .getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
       if (!tokens.contains(permanent.getId())) {
         permanent.destroy(source.getSourceId(), game, false);
       }
     }
   }
   return true;
 }
Ejemplo n.º 9
0
  @Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (permanent == null) {
      return false;
    }

    FilterPermanent filter = new FilterPermanent("black permanent");
    filter.add(new ColorPredicate(ObjectColor.BLACK));

    if (game.getBattlefield().countAll(filter, source.getControllerId(), game) == 0) {
      permanent.damage(2, source.getSourceId(), game, true, false);
    } else {
      permanent.destroy(source.getId(), game, false);
    }
    return true;
  }
Ejemplo n.º 10
0
 @Override
 public boolean apply(Game game, Ability source) {
   boolean applied = false;
   Permanent permanent = game.getPermanent(source.getFirstTarget());
   if (permanent != null) {
     permanent.destroy(source.getId(), game, false);
     applied = true;
   }
   Player player = game.getPlayer(source.getControllerId());
   Card card = game.getCard(source.getSourceId());
   if (card != null && player != null) {
     player.getGraveyard().remove(card);
     card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
     applied = true;
   }
   return applied;
 }
Ejemplo n.º 11
0
  @Override
  public boolean apply(Game game, Ability source) {

    Player player = game.getPlayer(source.getControllerId());

    for (Card card : player.getGraveyard().getCards(filterZombie, game)) {
      card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
      Permanent permanent = game.getPermanent(card.getId());
      if (permanent != null) {
        permanent.setTapped(true);
      }
    }
    for (Permanent permanent :
        game.getBattlefield().getActivePermanents(filterHuman, source.getControllerId(), game)) {
      permanent.destroy(source.getSourceId(), game, false);
    }
    return true;
  }
Ejemplo n.º 12
0
 @Override
 public boolean apply(Game game, Ability source) {
   boolean result = false;
   int destroyedCreatures = 0;
   for (Target target : source.getTargets()) {
     if (target instanceof TargetPermanent) {
       Permanent targetPermanent = game.getPermanent(target.getFirstTarget());
       if (targetPermanent != null) {
         if (targetPermanent.destroy(source.getSourceId(), game, false)) {
           destroyedCreatures++;
         }
       }
     }
   }
   if (destroyedCreatures > 0) {
     new SearchLibraryPutInPlayEffect(
             new TargetCardInLibrary(destroyedCreatures, filterForest), true, true)
         .apply(game, source);
   }
   return result;
 }
Ejemplo n.º 13
0
  @Override
  public boolean apply(Game game, Ability source) {

    FilterPermanent filter = new FilterPermanent("artifacts, creatures, and enchantments");

    filter.add(
        Predicates.or(
            new CardTypePredicate(CardType.ARTIFACT),
            new CardTypePredicate(CardType.CREATURE),
            new CardTypePredicate(CardType.ENCHANTMENT)));
    filter.add(
        new ConvertedManaCostPredicate(
            Filter.ComparisonType.LessThan, source.getManaCostsToPay().getX() + 1));

    for (Permanent permanent :
        game.getBattlefield()
            .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
      permanent.destroy(source.getSourceId(), game, false);
    }
    return true;
  }
Ejemplo n.º 14
0
 @Override
 public boolean apply(Game game, Ability source) {
   for (UUID permanentId : targetPointer.getTargets(game, source)) {
     Permanent permanent = game.getPermanent(permanentId);
     if (permanent != null) {
       Card card = game.getCard(permanent.getId());
       int zoneChangeCounter = card.getZoneChangeCounter();
       if (permanent.destroy(source.getSourceId(), game, false)) {
         if (card != null
             && game.getPlayer(permanent.getOwnerId()).getGraveyard().contains(card.getId())
             && card.getZoneChangeCounter() == zoneChangeCounter) {
           return new CreateTokenEffect(
                   new VampireToken(
                       permanent.getPower().getValue(), permanent.getToughness().getValue()))
               .apply(game, source);
         }
       }
     }
   }
   return false;
 }
Ejemplo n.º 15
0
  @Override
  public boolean apply(Game game, Ability source) {
    ArrayList<Permanent> targetPermanents = new ArrayList<Permanent>();
    Permanent permanent = game.getPermanent(source.getTargets().get(0).getFirstTarget());
    if (permanent != null) {
      targetPermanents.add(permanent);
    }
    for (UUID targetID : source.getTargets().get(1).getTargets()) {
      permanent = game.getPermanent(targetID);
      if (permanent != null) {
        targetPermanents.add(permanent);
      }
    }

    if (!targetPermanents.isEmpty()) {
      Random random = new Random();
      permanent = targetPermanents.get(random.nextInt(targetPermanents.size()));
      permanent.destroy(source.getSourceId(), game, false);
      return true;
    }
    return false;
  }