Search in sources :

Example 31 with Formula

use of main.system.math.Formula in project Eidolons by IDemiurge.

the class IlluminationRule method getLightEmissionEffect.

public LightEmittingEffect getLightEmissionEffect(DC_Obj source) {
    LightEmittingEffect effect = effectCache.get(source);
    if (effect == null) {
        int value = getLightEmission(source);
        if (value <= 0) {
            return null;
        }
        Boolean circular = true;
        if (source instanceof Unit)
            circular = false;
        else if (source.checkBool(GenericEnums.STD_BOOLS.SPECTRUM_LIGHT)) {
            circular = false;
        } else if (EntityCheckMaster.isOverlaying(source)) {
            BattleFieldObject dc_Obj = (BattleFieldObject) source;
            if (dc_Obj.getDirection() != null) {
                circular = false;
            }
        }
        effect = new LightEmittingEffect(("" + value), circular);
        effect.setRef(new Ref(source));
        effectCache.put(source, effect);
    } else
        effect.getEffects().setFormula(new Formula("" + getLightEmission(source)));
    return effect;
}
Also used : Formula(main.system.math.Formula) Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Unit(eidolons.entity.obj.unit.Unit) LightEmittingEffect(eidolons.ability.effects.common.LightEmittingEffect)

Example 32 with Formula

use of main.system.math.Formula in project Eidolons by IDemiurge.

the class DiseaseRule method getSpecialRoundEffects.

@Override
protected Effect getSpecialRoundEffects() {
    // spread effects could go here! :)
    ModifyValueEffect modifyValueEffect = new ModifyValueEffect(PARAMS.C_STAMINA, MOD.MODIFY_BY_CONST, getCounterRef() + "*" + STAMINA_PER_COUNTER);
    modifyValueEffect.setMin_max_formula(new Formula("0"));
    Effects effects = new Effects(modifyValueEffect);
    return effects;
}
Also used : Formula(main.system.math.Formula) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) Effects(main.ability.effects.Effects)

Example 33 with Formula

use of main.system.math.Formula in project Eidolons by IDemiurge.

the class FilterMaster method filter.

public static Collection<?> filter(Collection<?> list, String valueName, String value, OBJ_TYPE TYPE, boolean prop, boolean filterOut, Boolean strict_or_greater_less_equal) {
    List<Object> filteredList = new ArrayList<>();
    for (Object l : list) {
        Entity entity;
        if (l instanceof Entity) {
            entity = (Entity) l;
        } else {
            entity = DataManager.getType(l.toString(), TYPE);
        }
        if (entity == null) {
            continue;
        }
        boolean result;
        if (prop) {
            PROPERTY property = ContentManager.getPROP(valueName);
            if (property.isContainer()) // if (!BooleanMaster.isFalse(strict_or_greater_less_equal))
            {
                result = entity.checkContainerProp(property, value, strict_or_greater_less_equal == null);
            } else {
                result = StringMaster.compareByChar(entity.getProperty(property), value, BooleanMaster.isTrue(strict_or_greater_less_equal));
            }
        // entity.checkProperty();
        } else {
            PARAMETER param = ContentManager.getPARAM(valueName);
            int amount = new Formula(value).getInt(new Ref(entity));
            if (strict_or_greater_less_equal == null) {
                result = entity.getIntParam(param) == amount;
            } else {
                result = entity.checkParam(param, "" + amount);
                if (!strict_or_greater_less_equal) {
                    result = !result;
                }
            }
        }
        if (filterOut) {
            if (result) {
                filteredList.add(l);
            }
        } else if (!result) {
            filteredList.add(l);
        }
    }
    for (Object l : filteredList) {
        list.remove(l);
    }
    return list;
}
Also used : Entity(main.entity.Entity) Formula(main.system.math.Formula) Ref(main.entity.Ref) PROPERTY(main.content.values.properties.PROPERTY) ArrayList(java.util.ArrayList) PARAMETER(main.content.values.parameters.PARAMETER)

Example 34 with Formula

use of main.system.math.Formula 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;
}
Also used : Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) Formula(main.system.math.Formula) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Obj(main.entity.obj.Obj) DC_Effect(eidolons.ability.effects.DC_Effect) Effect(main.ability.effects.Effect) DequeImpl(main.system.datatypes.DequeImpl)

Example 35 with Formula

use of main.system.math.Formula in project Eidolons by IDemiurge.

the class RestEffect method getRestedBuffEffect.

private Effect getRestedBuffEffect() {
    Effects effects = new Effects();
    effects.add(new ModifyValueEffect(PARAMS.STAMINA, MOD.MODIFY_BY_PERCENT, "25"));
    effects.add(new ModifyValueEffect(PARAMS.ESSENCE, MOD.MODIFY_BY_PERCENT, "25"));
    effects.add(new ModifyValueEffect(PARAMS.WILLPOWER, MOD.MODIFY_BY_PERCENT, "25"));
    effects.add(new ModifyValueEffect(PARAMS.AGILITY, MOD.MODIFY_BY_PERCENT, "25"));
    effects.add(new ModifyValueEffect(PARAMS.DEXTERITY, MOD.MODIFY_BY_PERCENT, "25"));
    effects.add(new ModifyValueEffect(PARAMS.SPELLPOWER, MOD.MODIFY_BY_PERCENT, "25"));
    effects.add(new ModifyValueEffect(PARAMS.STRENGTH, MOD.MODIFY_BY_PERCENT, "25"));
    return new AddBuffEffect("Rested", effects, new Formula("10"));
}
Also used : AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Formula(main.system.math.Formula) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) Effects(main.ability.effects.Effects)

Aggregations

Formula (main.system.math.Formula)53 PARAMETER (main.content.values.parameters.PARAMETER)12 Ref (main.entity.Ref)11 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)8 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)8 Effects (main.ability.effects.Effects)7 SkillPointCondition (eidolons.ability.conditions.req.SkillPointCondition)5 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)5 ArrayList (java.util.ArrayList)5 Effect (main.ability.effects.Effect)5 ClassTreeCondition (eidolons.ability.conditions.req.ClassTreeCondition)4 MultiClassCondition (eidolons.ability.conditions.req.MultiClassCondition)4 ValueGroupCondition (eidolons.ability.conditions.req.ValueGroupCondition)4 Unit (eidolons.entity.obj.unit.Unit)4 ObjType (main.entity.type.ObjType)4 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)3 RemoveBuffEffect (eidolons.ability.effects.oneshot.buff.RemoveBuffEffect)3 RollEffect (eidolons.ability.effects.oneshot.mechanic.RollEffect)3 SummonEffect (eidolons.ability.effects.oneshot.unit.SummonEffect)3 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)3