mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Used new MageObjectReference class for DamagedByWatcher damaged object comparison.
This commit is contained in:
parent
36444b9496
commit
b0a18d4f36
22 changed files with 221 additions and 598 deletions
|
@ -127,7 +127,7 @@ class AggravateRequirementEffect extends RequirementEffect {
|
|||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(permanent.getId());
|
||||
return watcher.wasDamaged(permanent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import mage.constants.Rarity;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -60,8 +61,7 @@ public class PillarOfFlame extends CardImpl {
|
|||
this.getSpellAbility().addEffect(new DamageTargetEffect(2));
|
||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
|
||||
// If a creature dealt damage this way would die this turn, exile it instead.
|
||||
this.getSpellAbility().addEffect(new PillarOfFlameEffect());
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
this.getSpellAbility().addEffect(new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn));
|
||||
}
|
||||
|
||||
public PillarOfFlame(final PillarOfFlame card) {
|
||||
|
|
|
@ -27,9 +27,10 @@
|
|||
*/
|
||||
package mage.sets.betrayersofkamigawa;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
|
@ -123,10 +124,13 @@ class KumanosBlessingEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE) {
|
||||
ZoneChangeEvent zce = (ZoneChangeEvent) event;
|
||||
if (zce.isDiesEvent()) {
|
||||
DamagedByEnchantedWatcher watcher = (DamagedByEnchantedWatcher) game.getState().getWatchers().get("DamagedByEnchantedWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
return watcher.wasDamaged(zce.getTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -136,7 +140,7 @@ class KumanosBlessingEffect extends ReplacementEffectImpl {
|
|||
|
||||
class DamagedByEnchantedWatcher extends Watcher {
|
||||
|
||||
public List<UUID> damagedCreatures = new ArrayList<>();
|
||||
private final Set<MageObjectReference> damagedCreatures = new HashSet<>();
|
||||
|
||||
public DamagedByEnchantedWatcher() {
|
||||
super("DamagedByEnchantedWatcher", WatcherScope.CARD);
|
||||
|
@ -157,8 +161,11 @@ class DamagedByEnchantedWatcher extends Watcher {
|
|||
if (event.getType() == EventType.DAMAGED_CREATURE) {
|
||||
Permanent enchantment = game.getPermanent(this.getSourceId());
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
if (enchantment.getAttachedTo().equals(event.getSourceId()) && !damagedCreatures.contains(event.getTargetId())) {
|
||||
damagedCreatures.add(event.getTargetId());
|
||||
if (enchantment.getAttachedTo().equals(event.getSourceId())) {
|
||||
MageObjectReference mor = new MageObjectReference(event.getTargetId(), game);
|
||||
if (!damagedCreatures.contains(mor)) {
|
||||
damagedCreatures.add(mor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,4 +177,7 @@ class DamagedByEnchantedWatcher extends Watcher {
|
|||
damagedCreatures.clear();
|
||||
}
|
||||
|
||||
public boolean wasDamaged(Permanent permanent) {
|
||||
return damagedCreatures.contains(new MageObjectReference(permanent));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,26 +29,19 @@
|
|||
package mage.sets.championsofkamigawa;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
* @author LevelX
|
||||
|
@ -69,9 +62,8 @@ public class Frostwielder extends CardImpl {
|
|||
ability.addTarget(new TargetCreatureOrPlayer());
|
||||
this.addAbility(ability);
|
||||
// If a creature dealt damage by Frostwielder this turn would die, exile it instead.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new FrostwielderEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DealtDamageToCreatureBySourceDies(this, Duration.WhileOnBattlefield)));
|
||||
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
}
|
||||
|
||||
public Frostwielder(final Frostwielder card) {
|
||||
|
@ -84,47 +76,3 @@ public class Frostwielder extends CardImpl {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class FrostwielderEffect extends ReplacementEffectImpl {
|
||||
|
||||
public FrostwielderEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Exile);
|
||||
staticText = "If a creature dealt damage by {this} this turn would die, exile it instead";
|
||||
}
|
||||
|
||||
public FrostwielderEffect(final FrostwielderEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FrostwielderEffect copy() {
|
||||
return new FrostwielderEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent)event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -31,28 +31,19 @@
|
|||
package mage.sets.championsofkamigawa;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author LevelX
|
||||
|
@ -72,10 +63,10 @@ public class KumanoMasterYamabushi extends CardImpl {
|
|||
// {{1}{R}: Kumano, Master Yamabushi deals 1 damage to target creature or player.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new ManaCostsImpl("{1}{R}") );
|
||||
ability.addTarget(new TargetCreatureOrPlayer());
|
||||
// If a creature dealt damage by Kumano this turn would die, exile it instead.
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KumanaoMasterYamabushiEffect()));
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
// If a creature dealt damage by Kumano this turn would die, exile it instead.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DealtDamageToCreatureBySourceDies(this, Duration.WhileOnBattlefield)));
|
||||
|
||||
}
|
||||
|
||||
public KumanoMasterYamabushi(final KumanoMasterYamabushi card) {
|
||||
|
@ -88,45 +79,3 @@ public class KumanoMasterYamabushi extends CardImpl {
|
|||
}
|
||||
|
||||
}
|
||||
class KumanaoMasterYamabushiEffect extends ReplacementEffectImpl {
|
||||
|
||||
public KumanaoMasterYamabushiEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Exile);
|
||||
staticText = "If a creature dealt damage by {this} this turn would die, exile it instead";
|
||||
}
|
||||
|
||||
public KumanaoMasterYamabushiEffect(final KumanaoMasterYamabushiEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KumanaoMasterYamabushiEffect copy() {
|
||||
return new KumanaoMasterYamabushiEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent)event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -29,24 +29,14 @@
|
|||
package mage.sets.championsofkamigawa;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author LevelX
|
||||
|
@ -63,9 +53,7 @@ public class KumanosPupils extends CardImpl {
|
|||
this.toughness = new MageInt(3);
|
||||
|
||||
// If a creature dealt damage by Kumano's Pupils this turn would die, exile it instead.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KumanosPupilsEffect()));
|
||||
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DealtDamageToCreatureBySourceDies(this, Duration.WhileOnBattlefield)));
|
||||
}
|
||||
|
||||
public KumanosPupils(final KumanosPupils card) {
|
||||
|
@ -78,45 +66,3 @@ public class KumanosPupils extends CardImpl {
|
|||
}
|
||||
|
||||
}
|
||||
class KumanosPupilsEffect extends ReplacementEffectImpl {
|
||||
|
||||
public KumanosPupilsEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Exile);
|
||||
staticText = "If a creature dealt damage by {this} this turn would die, exile it instead";
|
||||
}
|
||||
|
||||
public KumanosPupilsEffect(final KumanosPupilsEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KumanosPupilsEffect copy() {
|
||||
return new KumanosPupilsEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent)event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -36,8 +36,10 @@ import mage.constants.Zone;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
|
@ -46,6 +48,7 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
|
@ -68,10 +71,10 @@ public class NineRingedBo extends CardImpl {
|
|||
// {T}: Nine-Ringed Bo deals 1 damage to target Spirit creature. If that creature would die this turn, exile it instead.
|
||||
Ability ability = new ActivateAsSorceryActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost());
|
||||
ability.addTarget(new TargetCreaturePermanent(filter));
|
||||
ability.addEffect(new NineRingedBoEffect());
|
||||
Effect effect = new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn);
|
||||
effect.setText("If that creature would die this turn, exile it instead");
|
||||
ability.addEffect(effect);
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
}
|
||||
|
||||
public NineRingedBo(final NineRingedBo card) {
|
||||
|
@ -83,45 +86,3 @@ public class NineRingedBo extends CardImpl {
|
|||
return new NineRingedBo(this);
|
||||
}
|
||||
}
|
||||
|
||||
class NineRingedBoEffect extends ReplacementEffectImpl {
|
||||
|
||||
public NineRingedBoEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Exile);
|
||||
staticText = "If that creature would die this turn, exile it instead";
|
||||
}
|
||||
|
||||
public NineRingedBoEffect(final NineRingedBoEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NineRingedBoEffect copy() {
|
||||
return new NineRingedBoEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,21 +30,13 @@
|
|||
package mage.sets.championsofkamigawa;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -62,8 +54,7 @@ public class YamabushisFlame extends CardImpl {
|
|||
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
|
||||
|
||||
// If a creature dealt damage this way would die this turn, exile it instead.
|
||||
this.getSpellAbility().addEffect(new YamabushisFlameEffect());
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
this.getSpellAbility().addEffect(new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn));
|
||||
}
|
||||
|
||||
public YamabushisFlame(final YamabushisFlame card) {
|
||||
|
@ -75,46 +66,3 @@ public class YamabushisFlame extends CardImpl {
|
|||
return new YamabushisFlame(this);
|
||||
}
|
||||
}
|
||||
|
||||
class YamabushisFlameEffect extends ReplacementEffectImpl {
|
||||
|
||||
public YamabushisFlameEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Exile);
|
||||
staticText = "If a creature dealt damage this way would die this turn, exile it instead";
|
||||
}
|
||||
|
||||
public YamabushisFlameEffect(final YamabushisFlameEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YamabushisFlameEffect copy() {
|
||||
return new YamabushisFlameEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent)event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
DamagedByWatcher watcher =
|
||||
(DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null)
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -37,6 +37,7 @@ import mage.constants.Rarity;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageAllEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
|
@ -61,8 +62,7 @@ public class YamabushisStorm extends CardImpl {
|
|||
// Yamabushi's Storm deals 1 damage to each creature.
|
||||
this.getSpellAbility().addEffect(new DamageAllEffect(1, new FilterCreaturePermanent()));
|
||||
// If a creature dealt damage this way would die this turn, exile it instead.
|
||||
this.getSpellAbility().addEffect(new YamabushisStormEffect());
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
this.getSpellAbility().addEffect(new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn));
|
||||
}
|
||||
|
||||
public YamabushisStorm(final YamabushisStorm card) {
|
||||
|
|
|
@ -31,8 +31,10 @@ import java.util.UUID;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
|
@ -40,10 +42,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -60,7 +59,9 @@ public class Disintegrate extends CardImpl {
|
|||
// Disintegrate deals X damage to target creature or player. That creature can't be regenerated this turn. If the creature would die this turn, exile it instead.
|
||||
this.getSpellAbility().addEffect(new DamageTargetEffect(new ManacostVariableValue()));
|
||||
this.getSpellAbility().addEffect(new DisintegrateCantRegenerateEffect());
|
||||
this.getSpellAbility().addEffect(new DisintegrateExileEffect());
|
||||
Effect effect = new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn);
|
||||
effect.setText("If the creature would die this turn, exile it instead");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
|
||||
}
|
||||
|
||||
|
@ -111,45 +112,3 @@ class DisintegrateCantRegenerateEffect extends ReplacementEffectImpl {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class DisintegrateExileEffect extends ReplacementEffectImpl {
|
||||
|
||||
public DisintegrateExileEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Exile);
|
||||
staticText = "If the creature would die this turn, exile it instead";
|
||||
}
|
||||
|
||||
public DisintegrateExileEffect(final DisintegrateExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisintegrateExileEffect copy() {
|
||||
return new DisintegrateExileEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (GameEvent.EventType.ZONE_CHANGE.equals(event.getType()) && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
UUID targetId = getTargetPointer().getFirst(game, source);
|
||||
if (targetId != null) {
|
||||
return targetId.equals(event.getTargetId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -40,7 +40,6 @@ import mage.constants.Rarity;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -28,21 +28,14 @@
|
|||
package mage.sets.mirrodinbesieged;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
|
@ -56,9 +49,10 @@ public class RedSunsZenith extends CardImpl {
|
|||
super(ownerId, 74, "Red Sun's Zenith", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{R}");
|
||||
this.expansionSetCode = "MBS";
|
||||
this.color.setRed(true);
|
||||
|
||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
|
||||
this.getSpellAbility().addEffect(new DamageTargetEffect(new ManacostVariableValue()));
|
||||
this.getSpellAbility().addEffect(new RedSunsZenithEffect());
|
||||
this.getSpellAbility().addEffect(new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn));
|
||||
this.getSpellAbility().addEffect(ShuffleSpellEffect.getInstance());
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
}
|
||||
|
@ -73,45 +67,3 @@ public class RedSunsZenith extends CardImpl {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class RedSunsZenithEffect extends ReplacementEffectImpl {
|
||||
|
||||
public RedSunsZenithEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Exile);
|
||||
staticText = "If a creature dealt damage this way would die this turn, exile it instead";
|
||||
}
|
||||
|
||||
public RedSunsZenithEffect(final RedSunsZenithEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedSunsZenithEffect copy() {
|
||||
return new RedSunsZenithEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent)event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null)
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ import mage.constants.TimingRule;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -60,7 +59,6 @@ public class EngulfingFlames extends CardImpl {
|
|||
this.getSpellAbility().addEffect(new DamageTargetEffect(1));
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
this.getSpellAbility().addEffect(new EngulfingFlamesEffect());
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
// Flashback {3}{R}
|
||||
this.addAbility(new FlashbackAbility(new ManaCostsImpl("{3}{R}"), TimingRule.INSTANT));
|
||||
}
|
||||
|
|
|
@ -30,21 +30,13 @@
|
|||
package mage.sets.returntoravnica;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -62,8 +54,7 @@ public class AnnihilatingFire extends CardImpl {
|
|||
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
|
||||
|
||||
// If a creature dealt damage this way would die this turn, exile it instead.
|
||||
this.getSpellAbility().addEffect(new AnnihilatingFireEffect());
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
this.getSpellAbility().addEffect(new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn));
|
||||
}
|
||||
|
||||
public AnnihilatingFire(final AnnihilatingFire card) {
|
||||
|
@ -75,45 +66,3 @@ public class AnnihilatingFire extends CardImpl {
|
|||
return new AnnihilatingFire(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AnnihilatingFireEffect extends ReplacementEffectImpl {
|
||||
|
||||
public AnnihilatingFireEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Exile);
|
||||
staticText = "If a creature dealt damage this way would die this turn, exile it instead";
|
||||
}
|
||||
|
||||
public AnnihilatingFireEffect(final AnnihilatingFireEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnihilatingFireEffect copy() {
|
||||
return new AnnihilatingFireEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent)event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -28,21 +28,14 @@
|
|||
package mage.sets.shardsofalara;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -60,8 +53,9 @@ public class MagmaSpray extends CardImpl {
|
|||
this.getSpellAbility().addEffect(new DamageTargetEffect(2));
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
// If that creature would die this turn, exile it instead.
|
||||
this.getSpellAbility().addEffect(new MagmaSprayEffect());
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
Effect effect = new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn);
|
||||
effect.setText("If that creature would die this turn, exile it instead");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
}
|
||||
|
||||
public MagmaSpray(final MagmaSpray card) {
|
||||
|
@ -73,45 +67,3 @@ public class MagmaSpray extends CardImpl {
|
|||
return new MagmaSpray(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MagmaSprayEffect extends ReplacementEffectImpl {
|
||||
|
||||
public MagmaSprayEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Exile);
|
||||
staticText = "If that creature would die this turn, exile it instead";
|
||||
}
|
||||
|
||||
public MagmaSprayEffect(final MagmaSprayEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagmaSprayEffect copy() {
|
||||
return new MagmaSprayEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import mage.abilities.effects.common.RegenerateSourceEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
@ -124,10 +125,13 @@ class SkeletonizeDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
if (event.getType().equals(EventType.ZONE_CHANGE)) {
|
||||
ZoneChangeEvent zce = (ZoneChangeEvent) event;
|
||||
if (zce.isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", this.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
return watcher.wasDamaged(zce.getTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -28,14 +28,14 @@
|
|||
package mage.sets.tenth;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
|
@ -70,10 +70,10 @@ public class Incinerate extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class IncinerateEffect extends ReplacementEffectImpl {
|
||||
class IncinerateEffect extends ContinuousRuleModifiyingEffectImpl {
|
||||
|
||||
public IncinerateEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Detriment);
|
||||
super(Duration.EndOfTurn, Outcome.Detriment, true, false);
|
||||
staticText = "A creature dealt damage this way can't be regenerated this turn";
|
||||
}
|
||||
|
||||
|
@ -91,17 +91,12 @@ class IncinerateEffect extends ReplacementEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.REGENERATE) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
return watcher.wasDamaged(event.getTargetId(), game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -28,20 +28,13 @@
|
|||
package mage.sets.theros;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageAllEffect;
|
||||
import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -59,8 +52,7 @@ public class AngerOfTheGods extends CardImpl {
|
|||
this.getSpellAbility().addEffect(new DamageAllEffect(3, new FilterCreaturePermanent()));
|
||||
|
||||
//If a creature dealt damage this way would die this turn, exile it instead.
|
||||
this.getSpellAbility().addEffect(new AngerOfTheGodsEffect());
|
||||
this.addWatcher(new DamagedByWatcher());
|
||||
this.getSpellAbility().addEffect(new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn));
|
||||
}
|
||||
|
||||
public AngerOfTheGods(final AngerOfTheGods card) {
|
||||
|
@ -72,48 +64,3 @@ public class AngerOfTheGods extends CardImpl {
|
|||
return new AngerOfTheGods(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class AngerOfTheGodsEffect extends ReplacementEffectImpl {
|
||||
|
||||
public AngerOfTheGodsEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Exile);
|
||||
staticText = "If a creature dealt damage this way would die this turn, exile it instead";
|
||||
}
|
||||
|
||||
public AngerOfTheGodsEffect(final AngerOfTheGodsEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AngerOfTheGodsEffect copy() {
|
||||
return new AngerOfTheGodsEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent)event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
DamagedByWatcher watcher =
|
||||
(DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null){
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -29,7 +29,7 @@ package mage.sets.theros;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.ScryEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -74,7 +74,7 @@ public class RageOfPurphoros extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class RageOfPurphorosEffect extends ReplacementEffectImpl {
|
||||
class RageOfPurphorosEffect extends ContinuousRuleModifiyingEffectImpl {
|
||||
|
||||
public RageOfPurphorosEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Detriment);
|
||||
|
@ -95,17 +95,12 @@ class RageOfPurphorosEffect extends ReplacementEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.REGENERATE) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
return watcher.wasDamaged(event.getTargetId(), game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -35,6 +35,7 @@ import mage.abilities.common.SimpleActivatedAbility;
|
|||
import mage.abilities.costs.common.DiscardCardCost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.DamageEverythingEffect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
|
@ -111,7 +112,7 @@ public class JayaBallardTaskMage extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class CantRegenerateEffect extends ReplacementEffectImpl {
|
||||
class CantRegenerateEffect extends ContinuousRuleModifiyingEffectImpl {
|
||||
|
||||
public CantRegenerateEffect() {
|
||||
super(Duration.EndOfTurn, Outcome.Detriment);
|
||||
|
@ -132,17 +133,12 @@ class CantRegenerateEffect extends ReplacementEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.REGENERATE) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.damagedCreatures.contains(event.getTargetId());
|
||||
return watcher.wasDamaged(event.getTargetId(), game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common.replacement;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.common.DamagedByWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class DealtDamageToCreatureBySourceDies extends ReplacementEffectImpl {
|
||||
|
||||
public DealtDamageToCreatureBySourceDies(Card card, Duration duration) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Exile);
|
||||
card.addWatcher(new DamagedByWatcher());
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
staticText = "If a creature dealt damage by {this} this turn would die, exile it instead";
|
||||
} else {
|
||||
staticText = "If a creature dealt damage this way would die this turn, exile it instead";
|
||||
}
|
||||
}
|
||||
|
||||
public DealtDamageToCreatureBySourceDies(final DealtDamageToCreatureBySourceDies effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DealtDamageToCreatureBySourceDies copy() {
|
||||
return new DealtDamageToCreatureBySourceDies(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent)event).getTarget();
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && permanent != null) {
|
||||
return controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType().equals(EventType.ZONE_CHANGE)) {
|
||||
ZoneChangeEvent zce = (ZoneChangeEvent) event;
|
||||
if (zce.isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.wasDamaged(zce.getTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -27,23 +27,25 @@
|
|||
*/
|
||||
package mage.watchers.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class DamagedByWatcher extends Watcher {
|
||||
|
||||
public List<UUID> damagedCreatures = new ArrayList<>();
|
||||
public Set<MageObjectReference> damagedCreatures = new HashSet<>();
|
||||
|
||||
public DamagedByWatcher() {
|
||||
super("DamagedByWatcher", WatcherScope.CARD);
|
||||
|
@ -61,9 +63,10 @@ public class DamagedByWatcher extends Watcher {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.DAMAGED_CREATURE) {
|
||||
if (sourceId.equals(event.getSourceId()) && !damagedCreatures.contains(event.getTargetId())) {
|
||||
damagedCreatures.add(event.getTargetId());
|
||||
if (event.getType() == EventType.DAMAGED_CREATURE && sourceId.equals(event.getSourceId())) {
|
||||
MageObjectReference mor = new MageObjectReference(event.getTargetId(), game);
|
||||
if (!damagedCreatures.contains(mor)) {
|
||||
damagedCreatures.add(mor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,4 +77,15 @@ public class DamagedByWatcher extends Watcher {
|
|||
damagedCreatures.clear();
|
||||
}
|
||||
|
||||
public boolean wasDamaged(UUID sourceId, Game game) {
|
||||
MageObject mageObject = game.getObject(sourceId);
|
||||
if (mageObject instanceof Permanent) {
|
||||
return wasDamaged((Permanent) mageObject);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean wasDamaged(Permanent permanent) {
|
||||
return damagedCreatures.contains(new MageObjectReference(permanent));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue