@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { HashSet<String> landNames = new HashSet<>(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(sourceAbility.getControllerId())) { if (permanent.isLand()) { landNames.add(permanent.getName()); } } return landNames.size(); }
@Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { Permanent permanent = game.getPermanent(sourceId); if (permanent != null) { for (UUID attachmentId :permanent.getAttachments()) { Permanent attachment = game.getPermanent(attachmentId); if (attachment != null && attachment.getName().equals("Shuriken")) { return true; } } } return false; }
@Override public int calculate(Game game, Ability source, Effect effect) { Permanent aura = game.getPermanent(source.getSourceId()); if (aura != null) { Permanent permanent = game.getPermanent(aura.getAttachedTo()); if (permanent != null) { return Pattern.compile("\\s+").split(permanent.getName()).length; } } return 0; }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent permanent = ((ZoneChangeEvent) event).getTarget(); if (permanent != null) { if (permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true)) { game.informPlayers(permanent.getName() + " was put on the top of its owner's library"); return true; } } return false; }
@Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.getName().equals("Brothers Yamazaki")) { return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 2; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanent(source.getFirstTarget()); if (creature == null) { return false; } FilterCard filter = new FilterCard("a card named " + creature.getName()); filter.add(new NamePredicate(creature.getName())); return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)).apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { Permanent p = game.getPermanent(targetPointer.getFirst(game, source)); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Player player = game.getPlayer(source.getControllerId()); if (p != null && player != null && sourcePermanent != null) { if (player.chooseUse(Outcome.Benefit, "Attach " + p.getName() + " to " + sourcePermanent.getName() + '?', source, game)) { sourcePermanent.addAttachment(p.getId(), game); } return true; } return false; }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE) { if (!event.getSourceId().equals(event.getTargetId())) { MageObjectReference damageSourceRef = new MageObjectReference(event.getSourceId(), game); MageObjectReference damageTargetRef = new MageObjectReference(event.getTargetId(), game); if (game.getPermanentOrLKIBattlefield(event.getSourceId()) != null && game.getPermanentOrLKIBattlefield(event.getSourceId()).getName().equals("Blazing Effigy")) { damagedObjects.putIfAbsent(damageTargetRef, 0); damagedObjects.compute(damageTargetRef, (k, damage) -> damage + event.getAmount()); } } } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { return permanent.moveToExile(source.getSourceId(), permanent.getName(), source.getSourceId(), game); } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent == null) { return false; } ability = new AttacksTriggeredAbility(new GrothamaAllDevouringFightEffect(permanent.getId(), permanent.getName()), true); return super.apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { if (permanent.isTransformable()) { permanent.transform(game); game.informPlayers(permanent.getName() + " transforms into " + permanent.getSecondCardFace().getName()); } } return true; }
@Override public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanent(source.getFirstTarget()); if (creature != null) { SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice boosted " + creature.getName(), source.getControllerId()); sacrificeEffect.setTargetPointer(new FixedTarget(creature, game)); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect); game.addDelayedTriggeredAbility(delayedAbility, source); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); MageObject sourceObject = source.getSourceObject(game); if (permanent != null && sourceObject instanceof Permanent) { if (permanent.moveToExile(null, null, source.getSourceId(), game) && ((Permanent) sourceObject).imprint(permanent.getId(), game)) { ((Permanent) sourceObject).addInfo("imprint", "[Imprinted card - " + permanent.getName() + ']', game); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); FilterCard filter = new FilterPermanentCard(); filter.add(new NamePredicate(permanent.getName())); return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0,3, filter), true).apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); FilterCard filter = new FilterPermanentCard(); filter.add(new NamePredicate(permanent.getName())); return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)).apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (creature != null) { SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice boosted " + creature.getName(), source.getControllerId()); sacrificeEffect.setTargetPointer(new FixedTarget(creature, game)); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect); game.addDelayedTriggeredAbility(delayedAbility, source); } return true; } }
@Override public boolean apply(Game game, Ability source) { Card card = game.getCard(source.getSourceId()); if (card == null) { return false; } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { permanent.addCounters(CounterType.FUSE.createInstance(), source, game); game.informPlayers(card.getName() + " puts a fuse counter on " + permanent.getName()); } return true; } }
@Override public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); if (creature != null) { FilterPermanent filter = new FilterPermanent(); filter.add(TokenPredicate.instance); filter.add(new NamePredicate(creature.getName())); new ExileAllEffect(filter).apply(game, source); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent equipment = game.getPermanent(source.getSourceId()); if (equipment != null && equipment.getAttachedTo() != null) { Permanent attachedTo = game.getPermanent(equipment.getAttachedTo()); if (attachedTo != null) { attachedTo.removeAttachment(equipment.getId(), game); equipment.transform(game); game.informPlayers(equipment.getName() + " transforms into " + equipment.getSecondCardFace().getName()); } } return false; }
@Override public boolean apply(Game game, Ability source) { FilterPermanent filter = new FilterPermanent(); filter.add(new CardTypePredicate(CardType.CREATURE)); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { Player controller = game.getPlayer(permanent.getControllerId()); if (controller != null) { controller.damage(1, permanent.getId(), game, false, true); game.informPlayers("1 damage to " + controller.getLogName() + " from " + permanent.getName()); } } return true; }