public FixedTarget(Permanent permanent, Game game) { this.targetId = permanent.getId(); this.zoneChangeCounter = permanent.getZoneChangeCounter(game); this.initialized = true; }
public Permanent getPermanentOrLKIBattlefield(Game game) { Permanent permanent = game.getPermanentOrLKIBattlefield(sourceId); if (permanent != null && permanent.getZoneChangeCounter(game) == zoneChangeCounter) { return permanent; } return null; }
public Permanent getPermanent(Game game) { Permanent permanent = game.getPermanent(sourceId); if (permanent != null && permanent.getZoneChangeCounter(game) == zoneChangeCounter) { return permanent; } return null; }
public FixedTargets(List<Permanent> permanents, Game game) { for (Permanent permanent : permanents) { MageObjectReference mor = new MageObjectReference(permanent.getId(), permanent.getZoneChangeCounter(game), game); targets.add(mor); } this.initialized = true; }
public Permanent getTargetedPermanentOrLKIBattlefield(Game game) { Permanent permanent = game.getPermanentOrLKIBattlefield(targetId); if (permanent != null && permanent.getZoneChangeCounter(game) != zoneChangeCounter) { permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD, zoneChangeCounter); } return permanent; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (((ZoneChangeEvent) event).isDiesEvent()) { if (event.getTargetId().equals(watchedCreatureId)) { Permanent creature = (Permanent) game.getLastKnownInformation(watchedCreatureId, Zone.BATTLEFIELD); if (creature.getZoneChangeCounter(game) == this.zoneChangeCounter) { return true; } } } return false; }
@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { boolean result = super.pay(ability, game, sourceId, controllerId, noMana, costToPay); if (paid && !getPermanents().isEmpty()) { Permanent sacrificedPermanen = getPermanents().get(0); Permanent sourcePermanent = game.getPermanent(sourceId); if (sourcePermanent != null && sacrificedPermanen != null) { game.getState().setValue(RAVENOUS_WAMPA_STATE_VALUE_KEY_PREFIX + sourceId + sourcePermanent.getZoneChangeCounter(game), sacrificedPermanen.getToughness().getValue()); } } return result; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent blocker = game.getPermanent(event.getSourceId()); Permanent blocked = game.getPermanent(event.getTargetId()); if (blocker != null && blocked != null) { game.getState().setValue(blocked.toString(), blocked.getZoneChangeCounter(game)); // in case the attacker changes zone game.getState().setValue(blocker.toString(), blocker.getZoneChangeCounter(game)); // in case the blocker changes zone getAllEffects().setTargetPointer(new FixedTarget(blocked.getId())); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null && source.getSourceObjectZoneChangeCounter() == sourcePermanent.getZoneChangeCounter(game) // in case source was blinked after ability was set to stack && !sourcePermanent.isFaceDown(game)) { sourcePermanent.setFaceDown(true, game); } return true; } }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { Permanent attachment = game.getPermanent(source.getSourceId()); if (attachment != null && attachment.getAttachedTo() != null && permanent.getId().equals(attachment.getAttachedTo())) { String key = source.getSourceId().toString() + attachment.getZoneChangeCounter(game) + keyString + game.getTurnNum() + permanent.getControllerId(); return game.getState().getValue(key) == null; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (creature != null) { DelayedTriggeredAbility ability = new TimeToFeedDiesTriggeredAbility(creature.getId(), creature.getZoneChangeCounter(game)); new CreateDelayedTriggeredAbilityEffect(ability, false).apply(game, source); } return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller != null && sourceObject != null) { Integer toughness = (Integer) game.getState().getValue(RAVENOUS_WAMPA_STATE_VALUE_KEY_PREFIX + source.getSourceId() + sourceObject.getZoneChangeCounter(game)); if (toughness != null) { controller.gainLife(toughness, game, source); } return true; } return false; } }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget(); if (creature != null) { creature.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects()); ContinuousEffect effect = new BecomesBlackZombieAdditionEffect(); effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game) + 1)); game.addEffect(effect, source); //discard(); why? } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isCreature() && permanent.isControlledBy(this.controllerId)) { Effect effect = this.getEffects().get(0); // Life is determined during resolution so it has to be retrieved there (e.g. Giant Growth before resolution) effect.setValue("lifeSource", event.getTargetId()); effect.setValue("zoneChangeCounter", permanent.getZoneChangeCounter(game)); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = (RevealTargetFromHandCost) source.getCosts().get(0); Permanent creature = game.getPermanent(targetPointer.getFirst(game, source)); if (cost != null && creature != null) { int cmcBoost = -1 * cost.convertedManaCosts; ContinuousEffect effect = new BoostTargetEffect(cmcBoost, cmcBoost, Duration.EndOfTurn); effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game))); game.addEffect(effect, source); return true; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(((FixedTarget) getEffects().get(0).getTargetPointer()).getTarget()); return permanent != null && permanent.getZoneChangeCounter(game) == ((FixedTarget) getEffects().get(0).getTargetPointer()).getZoneChangeCounter() && permanent.getConvertedManaCost() <= 3; }
@Override public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanent(creatureId); Player player = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (creature != null && creature.getZoneChangeCounter(game) == this.creatureZoneCount && creature.sacrifice(source.getSourceId(), game)) { if (player != null && sourceObject != null && sourceObject.getZoneChangeCounter(game) == this.sourceZoneCount) { player.moveCards(game.getCard(source.getSourceId()), Zone.BATTLEFIELD, source, game); } } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (creature != null && controller != null && sourcePermanent != null) { UUID exileId = CardUtil.getCardExileZoneId(game, source); controller.moveCardToExileWithInfo(creature, exileId, sourcePermanent.getIdName() + " (" + sourcePermanent.getZoneChangeCounter(game) + ')', source.getSourceId(), game, Zone.BATTLEFIELD, true); } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player playerTargetLibrary = game.getPlayer(getTargetPointer().getFirst(game, source)); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller != null && playerTargetLibrary != null && sourcePermanent != null) { UUID exileId = CardUtil.getCardExileZoneId(game, source); controller.moveCardToExileWithInfo(playerTargetLibrary.getLibrary().getFromTop(game), exileId, sourcePermanent.getIdName() + " (" + sourcePermanent.getZoneChangeCounter(game) + ')', source.getSourceId(), game, Zone.BATTLEFIELD, true); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (permanent != null && permanent.destroy(source.getSourceId(), game, false)) { // if not destroyed it returns false if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId()) && game.getState().getZone(permanent.getId()) != Zone.GRAVEYARD) { // A replacement effect has moved the card to another zone as grvayard return true; } new CreateTokenEffect(new KalitasVampireToken(permanent.getPower().getValue(), permanent.getToughness().getValue())).apply(game, source); } return true; }