- RegenerateSourceEffect() will now be discarded if the source permanent is blinked or changes zone.

This commit is contained in:
jeffwadsworth 2020-08-01 16:11:55 -05:00
parent 2b82785e4a
commit 2a35f833a7

View file

@ -37,8 +37,10 @@ public class RegenerateSourceEffect extends ReplacementEffectImpl {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
//20110204 - 701.11 //20110204 - 701.11
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && permanent.regenerate(source, game)) { if (permanent != null
&& permanent.regenerate(source, game)) {
this.used = true; this.used = true;
discard();
return true; return true;
} }
return false; return false;
@ -63,13 +65,22 @@ public class RegenerateSourceEffect extends ReplacementEffectImpl {
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DESTROY_PERMANENT; return event.getType() == GameEvent.EventType.DESTROY_PERMANENT
|| event.getType() == GameEvent.EventType.ZONE_CHANGE;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
// The regeneration shield is discarded if the permanent is blinked or changes zone
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
&& event.getTargetId() == source.getSourceId()) {
discard();
return false;
}
//20110204 - 701.11c - event.getAmount() is used to signal if regeneration is allowed //20110204 - 701.11c - event.getAmount() is used to signal if regeneration is allowed
return event.getAmount() == 0 && event.getTargetId().equals(source.getSourceId()) && !this.used; return event.getAmount() == 0
&& event.getTargetId().equals(source.getSourceId())
&& !this.used;
} }
public static void initRegenerationInfo(Game game, Ability source, UUID permanentId) { public static void initRegenerationInfo(Game game, Ability source, UUID permanentId) {
@ -99,7 +110,6 @@ public class RegenerateSourceEffect extends ReplacementEffectImpl {
} }
} }
enum RegeneratingCanBeUsedCondition implements Condition { enum RegeneratingCanBeUsedCondition implements Condition {
instance; instance;