Added possibility to set a flag for effects that causes to call game.applyEffects() after the effect is resolved.

This commit is contained in:
LevelX2 2013-07-17 11:45:22 +02:00
parent 2bfc5373fe
commit b93ff11aeb
3 changed files with 22 additions and 0 deletions

View file

@ -156,6 +156,10 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
else {
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;

View file

@ -54,6 +54,8 @@ public interface Effect<T extends Effect<T>> extends Serializable {
TargetPointer getTargetPointer();
void setValue(String key, Object value);
Object getValue(String key);
void setApplyEffectsAfter();
boolean applyEffectsAfter();
T copy();

View file

@ -51,6 +51,7 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
protected TargetPointer targetPointer = FirstTargetPointer.getInstance();
protected String staticText = "";
protected Map<String, Object> values;
protected boolean applyEffectsAfter = false;
public EffectImpl(Outcome outcome) {
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());
}
}
this.applyEffectsAfter = effect.applyEffectsAfter;
}
@Override
@ -133,4 +135,18 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
}
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;
}
}