mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Added possibility to set a flag for effects that causes to call game.applyEffects() after the effect is resolved.
This commit is contained in:
parent
2bfc5373fe
commit
b93ff11aeb
3 changed files with 22 additions and 0 deletions
|
@ -156,6 +156,10 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
else {
|
else {
|
||||||
game.addEffect((ContinuousEffect) effect, this);
|
game.addEffect((ContinuousEffect) effect, this);
|
||||||
}
|
}
|
||||||
|
// some effects must be applied before next effect is resolved, because effect is dependend.
|
||||||
|
if (effect.applyEffectsAfter()) {
|
||||||
|
game.applyEffects();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -54,6 +54,8 @@ public interface Effect<T extends Effect<T>> extends Serializable {
|
||||||
TargetPointer getTargetPointer();
|
TargetPointer getTargetPointer();
|
||||||
void setValue(String key, Object value);
|
void setValue(String key, Object value);
|
||||||
Object getValue(String key);
|
Object getValue(String key);
|
||||||
|
void setApplyEffectsAfter();
|
||||||
|
boolean applyEffectsAfter();
|
||||||
|
|
||||||
T copy();
|
T copy();
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
||||||
protected TargetPointer targetPointer = FirstTargetPointer.getInstance();
|
protected TargetPointer targetPointer = FirstTargetPointer.getInstance();
|
||||||
protected String staticText = "";
|
protected String staticText = "";
|
||||||
protected Map<String, Object> values;
|
protected Map<String, Object> values;
|
||||||
|
protected boolean applyEffectsAfter = false;
|
||||||
|
|
||||||
public EffectImpl(Outcome outcome) {
|
public EffectImpl(Outcome outcome) {
|
||||||
this.id = UUID.randomUUID();
|
this.id = UUID.randomUUID();
|
||||||
|
@ -70,6 +71,7 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
||||||
values.put(entry.getKey(), entry.getValue());
|
values.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.applyEffectsAfter = effect.applyEffectsAfter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -133,4 +135,18 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
||||||
}
|
}
|
||||||
return values.get(key);
|
return values.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set, the game.applyEffects() method will be called to apply the effects before the
|
||||||
|
* next effect (of the same ability) will resolve.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setApplyEffectsAfter() {
|
||||||
|
applyEffectsAfter = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applyEffectsAfter() {
|
||||||
|
return applyEffectsAfter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue