public Permanent getPermanentOrLKIBattlefield(Game game) { Permanent permanent = game.getPermanentOrLKIBattlefield(sourceId); if (permanent != null && permanent.getZoneChangeCounter(game) == zoneChangeCounter) { return permanent; } return null; }
@Override public boolean apply(Game game, Ability source, UUID originalId, Cost costToPay) { if (!(source instanceof Spell)) { Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); return permanent != null; } return false; } }
@Override public boolean checkInterveningIfClause(Game game) { Permanent permanent = game.getPermanentOrLKIBattlefield(getSourceId()); if (permanent != null) { return permanent.isCreature(); } return false; }
@Override public int calculate(Game game, Ability source, Effect effect) { Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo()); return enchanted.getToughness().getValue(); }
@Override public boolean checkTrigger(GameEvent event, Game game) { return event.getPlayerId().equals(this.getControllerId()) && filter.match(game.getPermanentOrLKIBattlefield(event.getTargetId()), game); }
@Override public boolean checkTrigger(GameEvent event, Game game) { Card source = game.getPermanentOrLKIBattlefield(event.getSourceId()); if (event.getPlayerId().equals(getControllerId()) && source != null && filter.match(source, game)) { return true; } return false; }
@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Permanent attachment = game.getPermanentOrLKIBattlefield(sourceId); Permanent permanent = game.getPermanent(attachment.getAttachedTo()); if (permanent != null) { paid = permanent.tap(game); } return paid; }
@Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { Permanent attachment = game.getPermanentOrLKIBattlefield(sourceId); Permanent permanent = game.getPermanent(attachment.getAttachedTo()); if (permanent != null) { // return true; // Technically the more correct implementation, but all cards using this cost also come with an "untapped" condition return !permanent.isTapped(); } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent target = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo()); if (target != null) { Effect effect = new CreateTokenCopyTargetEffect(); effect.setTargetPointer(new FixedTarget(enchantment.getAttachedTo())); return effect.apply(game, source); } return false; } }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { Permanent permanent = game.getPermanentOrLKIBattlefield(effect.getTargetPointer().getFirst(game, sourceAbility)); if (permanent != null) { return permanent.getCounters(game).getCount(CounterType.FUNGUS); } return 0; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); if (permanent != null) { FrogLizardToken token = new FrogLizardToken(); token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId()); } return true; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); if (permanent != null && permanent.isLand()) { if (setTargetPointer) { getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent targetPermanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (targetPermanent != null) { int cost = targetPermanent.getConvertedManaCost(); Player player = game.getPlayer(source.getControllerId()); if (player != null) { player.gainLife(cost, game, source); } } return true; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); if (permanent != null && permanent.isLand()) { if (setTargetPointer) { getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent targetCreature = game.getPermanent(targetPointer.getFirst(game, source)); Permanent griefTyrant = game.getPermanentOrLKIBattlefield(source.getSourceId()); int countersOnGriefTyrant = griefTyrant.getCounters(game).getCount(CounterType.M1M1); if (targetCreature != null) { targetCreature.addCounters(CounterType.M1M1.createInstance(countersOnGriefTyrant), source, game); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (controller != null && permanent != null) { controller.gainLife(permanent.getToughness().getValue(), game, source); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (enchantment != null && enchantment.getAttachedTo() != null) { Player defender = game.getPlayer(game.getCombat().getDefendingPlayerId(enchantment.getAttachedTo(), game)); if (defender != null) { defender.loseLife(amount.calculate(game, source, this), game, false); } } return true; }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { DamageEvent damageEvent = (DamageEvent) event; int damage = damageEvent.getAmount(); Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId()); if (permanent != null && controller != null) { permanent.removeCounters(CounterType.ECHO.createInstance(damage), game); game.informPlayers(controller.getLogName() + ": " + damage + " damage replaced with " + permanent.getLogName()); } return true; }
@Override public void adjustTargets(Ability ability, Game game) { UUID creatureId = ability.getEffects().get(0).getTargetPointer().getFirst(game, ability); Permanent creature = game.getPermanentOrLKIBattlefield(creatureId); if (creature != null) { ability.getEffects().get(0).setTargetPointer(new FixedTarget(creature.getControllerId())); } } }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourceObject != null) { Permanent permanentReset = sourceObject.copy(); permanentReset.getCounters(game).clear(); permanentReset.getPower().resetToBaseValue(); permanentReset.getToughness().resetToBaseValue(); game.addEffect(new CopyEffect(Duration.Custom, permanentReset, event.getTargetId()), source); } return false; }