mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 06:22:01 -08:00
Added common interface to conditional effects (#9208)
This commit is contained in:
parent
5c54eccffd
commit
78f3547644
11 changed files with 62 additions and 1 deletions
|
|
@ -95,4 +95,9 @@ public class ConditionalAsThoughEffect extends AsThoughEffectImpl {
|
|||
public ConditionalAsThoughEffect copy() {
|
||||
return new ConditionalAsThoughEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,4 +192,9 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
|
|||
if (this.otherwiseEffect != null) res.add(this.otherwiseEffect);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,4 +125,8 @@ public class ConditionalContinuousRuleModifyingEffect extends ContinuousRuleModi
|
|||
return effect.getInfoMessage(source, event, game); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,4 +83,9 @@ public class ConditionalCostModificationEffect extends CostModificationEffectImp
|
|||
public ConditionalCostModificationEffect copy() {
|
||||
return new ConditionalCostModificationEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,4 +85,9 @@ public class ConditionalManaEffect extends ManaEffect {
|
|||
}
|
||||
return mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,4 +82,9 @@ public class ConditionalOneShotEffect extends OneShotEffect {
|
|||
}
|
||||
return effects.getText(mode) + ". If " + condition.toString() + ", " + otherwiseEffects.getText(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,4 +137,8 @@ public class ConditionalPreventionEffect extends PreventionEffectImpl {
|
|||
return new ConditionalPreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import mage.game.events.GameEvent;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ConditionalReplacementEffect extends ReplacementEffectImpl {
|
||||
public class ConditionalReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
protected ReplacementEffect effect;
|
||||
protected ReplacementEffect otherwiseEffect;
|
||||
|
|
@ -127,4 +127,9 @@ public class ConditionalReplacementEffect extends ReplacementEffectImpl {
|
|||
public ConditionalReplacementEffect copy() {
|
||||
return new ConditionalReplacementEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,4 +150,8 @@ public class ConditionalRequirementEffect extends RequirementEffect {
|
|||
return new ConditionalRequirementEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,4 +149,8 @@ public class ConditionalRestrictionEffect extends RestrictionEffect {
|
|||
return new ConditionalRestrictionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mage.abilities.effects;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.EffectType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
|
@ -67,4 +68,18 @@ public interface Effect extends Serializable, Copyable<Effect> {
|
|||
Effect concatBy(String concatPrefix);
|
||||
|
||||
String getConcatPrefix();
|
||||
|
||||
/**
|
||||
* Used to check if this is a conditional version without needed any Java reflection hacks or chained instanceof checks.
|
||||
* Only conditions on the activation of the ability are checked, and not on how the effects can be used.
|
||||
* E.g. For a conditional mana ability this will only return the condition under which it can be activated,
|
||||
* and NOT the conditions on the mane produced.
|
||||
*
|
||||
* Assumed that if the returned condition is null then this is not a conditional version, or that it does not matter.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public default Condition getCondition() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue