mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 13:32:06 -08:00
* Threshold abilities - fixed that restriction part of ability is not apply in some cards (#5738);
This commit is contained in:
parent
0aeab75552
commit
14274d8eaf
7 changed files with 66 additions and 62 deletions
|
|
@ -49,11 +49,12 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
|
|||
this.staticText = text;
|
||||
|
||||
// checks for compatibility
|
||||
if (effect != null && !effect.getEffectType().equals(EffectType.CONTINUOUS)) {
|
||||
Assert.fail("ConditionalContinuousEffect supports only " + EffectType.CONTINUOUS.toString() + " but found " + effect.getEffectType().toString());
|
||||
EffectType needType = EffectType.CONTINUOUS;
|
||||
if (effect != null && !effect.getEffectType().equals(needType)) {
|
||||
Assert.fail("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString());
|
||||
}
|
||||
if (otherwiseEffect != null && !otherwiseEffect.getEffectType().equals(EffectType.CONTINUOUS)) {
|
||||
Assert.fail("ConditionalContinuousEffect supports only " + EffectType.CONTINUOUS.toString() + " but found " + effect.getEffectType().toString());
|
||||
if (otherwiseEffect != null && !otherwiseEffect.getEffectType().equals(needType)) {
|
||||
Assert.fail("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString());
|
||||
}
|
||||
if (effect != null && otherwiseEffect != null && !effect.getEffectType().equals(otherwiseEffect.getEffectType())) {
|
||||
Assert.fail("ConditionalContinuousEffect must be same but found " + effect.getEffectType().toString() + " and " + otherwiseEffect.getEffectType().toString());
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.abilities.decorator;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.FixedCondition;
|
||||
|
|
@ -12,12 +10,13 @@ import mage.constants.EffectType;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class ConditionalRequirementEffect extends RequirementEffect {
|
||||
public class ConditionalRequirementEffect extends RequirementEffect {
|
||||
|
||||
protected RequirementEffect effect;
|
||||
protected RequirementEffect otherwiseEffect;
|
||||
|
|
@ -27,7 +26,14 @@ public class ConditionalRequirementEffect extends RequirementEffect {
|
|||
protected boolean initDone = false;
|
||||
|
||||
public ConditionalRequirementEffect(RequirementEffect effect, Condition condition) {
|
||||
this(Duration.WhileOnBattlefield, effect, condition, null, false);
|
||||
this(effect, condition, null);
|
||||
}
|
||||
|
||||
public ConditionalRequirementEffect(RequirementEffect effect, Condition condition, String text) {
|
||||
this(effect.getDuration(), effect, condition, null, false);
|
||||
if (text != null) {
|
||||
setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public ConditionalRequirementEffect(Duration duration, RequirementEffect effect, Condition condition, RequirementEffect otherwiseEffect, boolean lockedInCondition) {
|
||||
|
|
@ -75,7 +81,7 @@ public class ConditionalRequirementEffect extends RequirementEffect {
|
|||
conditionState = condition.apply(game, source);
|
||||
if (conditionState) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
return effect.applies(permanent, source,game);
|
||||
return effect.applies(permanent, source, game);
|
||||
} else if (otherwiseEffect != null) {
|
||||
otherwiseEffect.setTargetPointer(this.targetPointer);
|
||||
return otherwiseEffect.applies(permanent, source, game);
|
||||
|
|
@ -138,7 +144,7 @@ public class ConditionalRequirementEffect extends RequirementEffect {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ConditionalRequirementEffect copy() {
|
||||
return new ConditionalRequirementEffect(this);
|
||||
|
|
|
|||
|
|
@ -22,14 +22,25 @@ public class ConditionalRestrictionEffect extends RestrictionEffect {
|
|||
protected boolean initDone = false;
|
||||
|
||||
public ConditionalRestrictionEffect(RestrictionEffect effect, Condition condition) {
|
||||
this(Duration.WhileOnBattlefield, effect, condition, null);
|
||||
this(effect, condition, null);
|
||||
}
|
||||
|
||||
public ConditionalRestrictionEffect(RestrictionEffect effect, Condition condition, String text) {
|
||||
this(effect.getDuration(), effect, condition, null, text);
|
||||
}
|
||||
|
||||
public ConditionalRestrictionEffect(Duration duration, RestrictionEffect effect, Condition condition, RestrictionEffect otherwiseEffect) {
|
||||
this(duration, effect, condition, otherwiseEffect, null);
|
||||
}
|
||||
|
||||
public ConditionalRestrictionEffect(Duration duration, RestrictionEffect effect, Condition condition, RestrictionEffect otherwiseEffect, String text) {
|
||||
super(duration);
|
||||
this.effect = effect;
|
||||
this.baseCondition = condition;
|
||||
this.otherwiseEffect = otherwiseEffect;
|
||||
if (text != null) {
|
||||
this.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public ConditionalRestrictionEffect(final ConditionalRestrictionEffect effect) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue