use of main.ability.effects.Effect in project Eidolons by IDemiurge.
the class StateCloner method cloneEffect.
private Effect cloneEffect(Effect e) {
Effect cloneEffect = null;
if (e.getConstruct() != null) {
cloneEffect = (Effect) e.getConstruct().construct();
} else {
// TODO
}
if (e instanceof ContinuousEffect) {
e = ((ContinuousEffect) e).getEffect();
if (e.getConstruct() == null) {
return ContinuousEffect.transformEffectToContinuous(e);
}
cloneEffect = (Effect) e.getConstruct().construct();
cloneEffect = ContinuousEffect.transformEffectToContinuous(cloneEffect);
}
if (cloneEffect == null) {
return e;
}
return cloneEffect;
}
use of main.ability.effects.Effect in project Eidolons by IDemiurge.
the class ActivesConstructor method constructActive.
public static void constructActive(TARGETING_MODE mode, DC_ActiveObj entity) {
if (mode == AbilityEnums.TARGETING_MODE.MULTI) {
addMultiTargetingMods(entity);
return;
}
if (entity.checkBool(GenericEnums.STD_BOOLS.MULTI_TARGETING)) {
// constructMultiAbilities(entity);
return;
}
if (entity.getActives() == null) {
return;
}
List<ActiveObj> list = new ArrayList<>(entity.getActives());
Effects effects = new Effects();
for (Active active : list) {
for (Ability abil : ((AbilityObj) active).getAbilities().getAbils()) {
for (Effect effect : abil.getEffects().getEffects()) {
// anything?
if (effect instanceof DC_Effect) {
DC_Effect effect2 = (DC_Effect) effect;
effect2.setAnimationActive(entity);
}
effects.add(effect);
}
}
}
// TODO what if the effects should have different targetings like in
// damage+light?
String saveRoll = entity.getProperty(PROPS.ROLL_TYPES_TO_SAVE);
if (!StringMaster.isEmpty(saveRoll)) {
wrapInSaveRollEffect(effects, saveRoll);
}
String wrap = entity.getProperty(PROPS.EFFECTS_WRAP);
Effect wrappedEffect;
if (StringMaster.isEmpty(wrap)) {
wrappedEffect = wrapEffects(mode, effects, entity);
} else {
EFFECTS_WRAP WRAP = new EnumMaster<EFFECTS_WRAP>().retrieveEnumConst(EFFECTS_WRAP.class, wrap);
wrappedEffect = wrapEffects(WRAP, effects, entity);
}
Targeting targeting = getTargeting(mode, entity);
if (targeting == null) {
try {
targeting = entity.getActives().get(0).getActives().get(0).getTargeting();
} catch (Exception e) {
// targeting = getDefaultSingleTargeting(entity);TODO necessary?
}
}
if (targeting != null)
entity.setTargeting(targeting);
Abilities abilities = new Abilities();
abilities.add(new ActiveAbility(null, wrappedEffect));
entity.setAbilities(abilities);
// TODO wrapping in RollEffect - each single effect or the resulting
// wrapped Effects?
}
use of main.ability.effects.Effect in project Eidolons by IDemiurge.
the class SpectrumEffect method applyThis.
public boolean applyThis() {
if (range == null)
range = new Formula(rangeFormula).getInt(ref);
Integer backwardRange = 0;
Integer sidePenalty = 0;
if (vision) {
range = new Formula(StringMaster.getValueRef(KEYS.SOURCE, PARAMS.SIGHT_RANGE)).getInt(ref);
// TODO
backwardRange = null;
// will be taken from unit
sidePenalty = null;
}
if (ref.getObj(source) instanceof BattleFieldObject)
bfObj = ((BattleFieldObject) ref.getObj(source));
else {
// TODO
}
FACING_DIRECTION facing = bfObj.getFacing();
if (circular) {
backwardRange = range;
facing = FACING_DIRECTION.NORTH;
} else {
sidePenalty = 1;
}
List<Coordinates> coordinates = new ArrayList<>(getGame().getVisionMaster().getSightMaster().getSpectrumCoordinates(range, sidePenalty, backwardRange, bfObj, vision, facing));
// boolean x-ray ++ tall/short/etc
if (effects == null) {
initEffects();
}
for (Coordinates c : coordinates) {
// TODO WHAT IF IT'S ON A DIFFERENT Z-LEVEL?
// applyThrough = true; // ?
// if (!applyThrough)
// if (!(getGame().getObjectByCoordinate(c, true) instanceof
// DC_Cell))
// continue;
DequeImpl<? extends Obj> objects = new DequeImpl<>(getGame().getObjectsOnCoordinate(getGame().getDungeon().getZ(), c, null, true, applyThrough));
if (applyThrough) {
objects.addCast(getGame().getCellByCoordinate(c));
}
for (Obj o : objects) {
ref.setMatch(o.getId());
if (filterConditions != null) {
if (!filterConditions.preCheck(ref)) {
continue;
}
}
Integer target = o.getId();
// target = getGame().getCellByCoordinate(c).getId();
if (getGame().getObjectById(target) == null) {
continue;
}
for (Effect effect : effects.getEffects()) {
Ref REF = Ref.getCopy(ref);
REF.setTarget(target);
if (reductionForDistance != null) {
// for the first time
effect.resetOriginalFormula();
// to set original
effect.resetOriginalFormula();
String reduction = reductionForDistance;
if (reductionForDistanceModifier != null)
reduction += (reductionForDistanceModifier);
Formula effectFormula = effect.getFormula();
reduction = reduction.replace(X, effectFormula.toString());
int distance = PositionMaster.getDistance(REF.getSourceObj(), REF.getTargetObj());
reduction = reduction.replace("distance", distance + "");
effectFormula.append(reduction);
// TODO
Integer amount = effectFormula.getInt(ref);
if (amount < 0) {
effect.setAmount(amount);
}
effect.setAmount(amount);
}
effect.apply(REF);
}
}
}
return true;
}
use of main.ability.effects.Effect in project Eidolons by IDemiurge.
the class DuplicateEffect method applyThis.
@Override
public boolean applyThis() {
Effect copy;
if (event) {
copy = ref.getEvent().getRef().getEffect().getCopy();
} else {
copy = ref.getEffect().getCopy();
}
// !
copy.setAltered(true);
return copy.apply(ref);
}
use of main.ability.effects.Effect in project Eidolons by IDemiurge.
the class ForceRule method addForceEffects.
public static void addForceEffects(DC_ActiveObj action) {
if (!isForceEnabled(action)) {
return;
}
if (!(action.getRef().getTargetObj() instanceof BattleFieldObject)) {
return;
}
BattleFieldObject source = action.getOwnerObj();
BattleFieldObject target = (BattleFieldObject) action.getRef().getTargetObj();
Damage dmg = getDamageObject(action, source, target);
Effect effects = getForceEffects(action);
if (effects != null) {
action.addSpecialEffect(action.isSpell() ? SPECIAL_EFFECTS_CASE.SPELL_IMPACT : SPECIAL_EFFECTS_CASE.ON_ATTACK, effects);
}
if (dmg != null) {
action.addBonusDamage(action.isSpell() ? DAMAGE_CASE.SPELL : DAMAGE_CASE.ATTACK, dmg);
}
}
Aggregations