Fix Redirection effects ending early (#9191)

This commit is contained in:
sprangg 2022-07-02 20:33:02 +03:00 committed by GitHub
parent 1e220d9f77
commit 7bed65e8ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 5 deletions

View file

@ -56,7 +56,7 @@ class CaptainsManeuverEffect extends RedirectionEffect {
protected MageObjectReference redirectToObject;
public CaptainsManeuverEffect() {
super(Duration.EndOfTurn, Integer.MAX_VALUE, UsageType.ONE_USAGE_ABSOLUTE);
super(Duration.EndOfTurn, Integer.MAX_VALUE, UsageType.ACCORDING_DURATION);
staticText = "The next X damage that would be dealt to target creature, planeswalker, or player this turn is dealt to another target creature, planeswalker, or player instead.";
}

View file

@ -46,7 +46,7 @@ class HarmsWayPreventDamageTargetEffect extends RedirectionEffect {
private final TargetSource damageSource;
public HarmsWayPreventDamageTargetEffect() {
super(Duration.EndOfTurn, 2, UsageType.ONE_USAGE_ABSOLUTE);
super(Duration.EndOfTurn, 2, UsageType.ACCORDING_DURATION);
staticText = "The next 2 damage that a source of your choice would deal to you and/or permanents you control this turn is dealt to any target instead";
this.damageSource = new TargetSource();
}

View file

@ -66,7 +66,7 @@ class HazduhrTheAbbotRedirectDamageEffect extends RedirectionEffect {
private static FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
public HazduhrTheAbbotRedirectDamageEffect(Duration duration) {
super(duration, 0, UsageType.ONE_USAGE_ABSOLUTE);
super(duration, 0, UsageType.ACCORDING_DURATION);
this.staticText = "The next X damage that would be dealt this turn to target white creature you control is dealt to {this} instead";
}

View file

@ -81,7 +81,7 @@ class RaziaBorosArchangelEffect extends RedirectionEffect {
protected MageObjectReference redirectToObject;
public RaziaBorosArchangelEffect(Duration duration, int amount) {
super(duration, 3, UsageType.ONE_USAGE_ABSOLUTE);
super(duration, amount, UsageType.ACCORDING_DURATION);
staticText = "The next " + amount + " damage that would be dealt to target creature you control this turn is dealt to another target creature instead";
}

View file

@ -62,7 +62,7 @@ class ShimianNightStalkerRedirectDamageEffect extends RedirectionEffect {
private static FilterCreaturePermanent filter = new FilterCreaturePermanent();
public ShimianNightStalkerRedirectDamageEffect() {
super(Duration.EndOfTurn, Integer.MAX_VALUE, UsageType.ONE_USAGE_ABSOLUTE);
super(Duration.EndOfTurn, Integer.MAX_VALUE, UsageType.ACCORDING_DURATION);
this.staticText = "All damage that would be dealt to you this turn by target attacking creature is dealt to {this} instead";
}

View file

@ -85,6 +85,12 @@ public abstract class RedirectionEffect extends ReplacementEffectImpl {
applyEffectsCounter = game.getState().getApplyEffectsCounter();
}
}
if (usageType == UsageType.ACCORDING_DURATION) {
amountToRedirect -= damageEvent.getAmount();
if (amountToRedirect <= 0) {
this.discard();
}
}
Permanent permanent = game.getPermanent(redirectTarget.getFirstTarget());
if (permanent != null) {
permanent.damage(damageToRedirect, event.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());