mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
[LTR] Implement Stone of Erech (#10497)
* [LTR] Implement Stone of Erech Grouped together two other recent cards for that exact same replacement effect. * refactor some more This does extend the ReplacementEffect "If ... would die, exile it instead", using a `PermanentFilter`. [[Void Maw]] and [[Lorcan, Warlock Collector]] have thus be refactored to use that instead of a custom replacement effect. Added a static filter `StaticFilters.FILTER_ANOTHER_CREATURE` for Void Maw that is filtering "another creature". Found and refactored cards that were declaring that exact filter locally * [[Flame-Kin War Scout]] * [[Herd Gnarr]] * [[Mogg Bombers]] * [[Timid Drake]] * fix void maw * reverse changes on VoidMaw Void Maw was a linked ability, so not exactly the same replacement effect that was refactored.
This commit is contained in:
parent
311bf2e22e
commit
c92ad45e56
11 changed files with 167 additions and 184 deletions
|
|
@ -0,0 +1,62 @@
|
|||
package mage.abilities.effects.common.replacement;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class CreaturesAreExiledOnDeathReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
private FilterPermanent filter;
|
||||
|
||||
public CreaturesAreExiledOnDeathReplacementEffect(FilterPermanent filter) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Exile);
|
||||
staticText = "If " + CardUtil.addArticle(filter.getMessage()) + " would die, exile it instead";
|
||||
}
|
||||
|
||||
private CreaturesAreExiledOnDeathReplacementEffect(final CreaturesAreExiledOnDeathReplacementEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreaturesAreExiledOnDeathReplacementEffect copy() {
|
||||
return new CreaturesAreExiledOnDeathReplacementEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
((ZoneChangeEvent) event).setToZone(Zone.EXILED);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (!zEvent.isDiesEvent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Permanent permanent = zEvent.getTarget();
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return filter.match(permanent, source.getControllerId(), source, game);
|
||||
}
|
||||
}
|
||||
|
|
@ -560,6 +560,13 @@ public final class StaticFilters {
|
|||
FILTER_OPPONENTS_PERMANENT_ARTIFACT_OR_CREATURE.setLockedFilter(true);
|
||||
}
|
||||
|
||||
public static final FilterCreaturePermanent FILTER_ANOTHER_CREATURE = new FilterCreaturePermanent("another creature");
|
||||
|
||||
static {
|
||||
FILTER_ANOTHER_CREATURE.add(AnotherPredicate.instance);
|
||||
FILTER_ANOTHER_CREATURE.setLockedFilter(true);
|
||||
}
|
||||
|
||||
public static final FilterCreaturePermanent FILTER_ANOTHER_TARGET_CREATURE = new FilterCreaturePermanent("another target creature");
|
||||
|
||||
static {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue