Expanded DoUnlessTargetPlayerOrTargetsControllerPaysEffect

This commit is contained in:
Zzooouhh 2017-12-17 19:41:22 +01:00 committed by GitHub
parent 5c48d54916
commit aa7231bec0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,6 +50,7 @@ import mage.util.CardUtil;
public class DoUnlessTargetPlayerOrTargetsControllerPaysEffect extends OneShotEffect {
protected Effects executingEffects = new Effects();
private Effect otherwiseEffect;
private Cost cost;
private DynamicValue genericMana;
private String chooseUseText;
@ -59,8 +60,13 @@ public class DoUnlessTargetPlayerOrTargetsControllerPaysEffect extends OneShotEf
}
public DoUnlessTargetPlayerOrTargetsControllerPaysEffect(Effect effect, Cost cost, String chooseUseText) {
this(effect, null, cost, chooseUseText);
}
public DoUnlessTargetPlayerOrTargetsControllerPaysEffect(Effect effect, Effect otherwiseEffect, Cost cost, String chooseUseText) {
super(Outcome.Detriment);
this.executingEffects.add(effect);
this.otherwiseEffect = otherwiseEffect;
this.cost = cost;
this.chooseUseText = chooseUseText;
}
@ -74,6 +80,7 @@ public class DoUnlessTargetPlayerOrTargetsControllerPaysEffect extends OneShotEf
public DoUnlessTargetPlayerOrTargetsControllerPaysEffect(final DoUnlessTargetPlayerOrTargetsControllerPaysEffect effect) {
super(effect);
this.executingEffects = effect.executingEffects.copy();
this.otherwiseEffect = effect.otherwiseEffect;
if (effect.cost != null) {
this.cost = effect.cost.copy();
}
@ -135,6 +142,13 @@ public class DoUnlessTargetPlayerOrTargetsControllerPaysEffect extends OneShotEf
game.addEffect((ContinuousEffect) effect, source);
}
}
} else if (otherwiseEffect != null) {
otherwiseEffect.setTargetPointer(this.targetPointer);
if (otherwiseEffect instanceof OneShotEffect) {
result &= otherwiseEffect.apply(game, source);
} else {
game.addEffect((ContinuousEffect) otherwiseEffect, source);
}
}
return result;
}