Search in sources :

Example 11 with Formula

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

the class ActivesConstructor method wrapEffects.

public static Effect wrapEffects(TARGETING_MODE mode, Effect effects, DC_ActiveObj entity) {
    Formula radius = new Formula(entity.getParam(G_PARAMS.RADIUS));
    Formula range = new Formula(entity.getParam(PARAMS.RANGE));
    Boolean allyOrEnemyOnly = null;
    if (entity.checkBool(GenericEnums.STD_BOOLS.NO_FRIENDLY_FIRE)) {
        allyOrEnemyOnly = false;
    }
    if (entity.checkBool(GenericEnums.STD_BOOLS.NO_ENEMY_FIRE)) {
        allyOrEnemyOnly = true;
    }
    boolean notSelf = entity.checkBool(GenericEnums.STD_BOOLS.NO_SELF_FIRE);
    switch(mode) {
        case SPRAY:
            effects = new WaveEffect(effects, radius, range, allyOrEnemyOnly, true, false, entity.checkBool(GenericEnums.STD_BOOLS.APPLY_THRU) ? C_OBJ_TYPE.BF : C_OBJ_TYPE.BF_OBJ);
            break;
        case WAVE:
            effects = new WaveEffect(effects, radius, range, allyOrEnemyOnly, true, true, // expanding
            entity.checkBool(GenericEnums.STD_BOOLS.APPLY_THRU) ? C_OBJ_TYPE.BF : C_OBJ_TYPE.BF_OBJ);
            // modifier?
            break;
        case RAY:
            effects = new RayEffect(effects);
            // ++ special conditions for allyOrEnemyOnly
            break;
        case DOUBLE:
            break;
        case MULTI:
            break;
        case TRIPPLE:
            break;
        case BLAST:
            if (// ideally, I
            entity.getIntParam(G_PARAMS.RADIUS) > 0) // shouldn't mix
            // up targeting
            // and effect
            // wrapping
            {
                effects = new ZoneEffect(effects, radius, allyOrEnemyOnly, notSelf);
            }
            break;
        case NOVA:
            // TODO
            effects = new Effects(new ZoneEffect(effects, radius, allyOrEnemyOnly, true));
            break;
        case SINGLE:
            break;
        case TRAP:
            break;
        default:
            break;
    }
    return effects;
}
Also used : RayEffect(eidolons.ability.effects.containers.customtarget.RayEffect) Formula(main.system.math.Formula) WaveEffect(eidolons.ability.effects.containers.customtarget.WaveEffect) Effects(main.ability.effects.Effects) ZoneEffect(eidolons.ability.effects.containers.customtarget.ZoneEffect)

Example 12 with Formula

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

the class ActivesConstructor method wrapEffects.

public static Effect wrapEffects(EFFECTS_WRAP wrap, Effect effects, Entity entity) {
    Formula radius = new Formula(entity.getParam(G_PARAMS.RADIUS));
    Boolean allyOrEnemyOnly = null;
    if (entity.checkBool(GenericEnums.STD_BOOLS.NO_FRIENDLY_FIRE)) {
        allyOrEnemyOnly = false;
    }
    if (entity.checkBool(GenericEnums.STD_BOOLS.NO_ENEMY_FIRE)) {
        allyOrEnemyOnly = true;
    }
    boolean notSelf = entity.checkBool(GenericEnums.STD_BOOLS.NO_SELF_FIRE);
    switch(wrap) {
        case CHAIN:
            break;
        case CUSTOM_ZONE_CROSS:
            break;
        case CUSTOM_ZONE_STAR:
            // };
            break;
        case ZONE:
            effects = new Effects(new ZoneEffect(effects, radius, allyOrEnemyOnly, notSelf));
            break;
        case SINGLE_BUFF:
            Effects buffEffects = new Effects();
            if (effects instanceof Effects) {
                for (Effect effect : (Effects) effects) {
                    if (effect instanceof AddBuffEffect) {
                        buffEffects.add(((AddBuffEffect) effect).getEffect());
                    } else {
                        buffEffects.add(effect);
                    }
                }
            } else {
                buffEffects.add(effects);
            }
            String buffName = entity.getProperty(PROPS.BUFF_NAME);
            if (buffName == null) {
            }
            effects = new AddBuffEffect(buffName, buffEffects);
            break;
        default:
            break;
    }
    return effects;
}
Also used : Formula(main.system.math.Formula) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) DC_Effect(eidolons.ability.effects.DC_Effect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) RollEffect(eidolons.ability.effects.oneshot.mechanic.RollEffect) Effect(main.ability.effects.Effect) RayEffect(eidolons.ability.effects.containers.customtarget.RayEffect) WaveEffect(eidolons.ability.effects.containers.customtarget.WaveEffect) ZoneEffect(eidolons.ability.effects.containers.customtarget.ZoneEffect) Effects(main.ability.effects.Effects) ZoneEffect(eidolons.ability.effects.containers.customtarget.ZoneEffect)

Example 13 with Formula

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

the class DC_CostsFactory method getCost.

public static Cost getCost(Entity obj, PARAMS cost_param, PARAMS pay_param) {
    String paramValue = obj.getParam(cost_param);
    Formula formula;
    boolean var;
    int amount = StringMaster.getInteger(paramValue);
    if (amount == 0) {
        return null;
    }
    formula = new Formula(amount + "");
    var = false;
    Cost cost = new CostImpl(new Payment(pay_param, formula), cost_param);
    cost.setVariable(var);
    return cost;
}
Also used : Formula(main.system.math.Formula)

Example 14 with Formula

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

the class TextParser method parseRef.

// perhaps I should refactor into method per parse_type!
private static String parseRef(String ref_substring, Ref ref) {
    if (ref == null) {
        return parseVarRef(ref_substring);
    }
    String value = StringMaster.cropRef(ref_substring);
    if (!StringMaster.isInteger(value)) {
        if (isAbilityParsing()) {
            return ref_substring;
        }
    }
    int id = 0;
    if (isActiveParsing()) {
        id = ref.getId(KEYS.ACTIVE);
    } else {
        try {
            id = ref.getId(KEYS.INFO);
        } catch (Exception e) {
        }
    }
    Game game = ref.getGame();
    // if (id == 0) {
    // if (game.isRunning()) {
    // id = game.getManager().getInfoObj().getId();
    // }
    // }
    // else if (CharacterCreator.isRunning())
    String replacement = ref_substring;
    Entity entity = ref.getInfoEntity();
    if (entity == null) {
        if (game.isSimulation() && !isBuffParsing() && !isAbilityParsing()) {
            entity = game.getTypeById(id);
        } else {
            entity = game.getObjectById(id);
        }
    }
    if (entity == null) {
        return ref_substring;
    }
    if (entity instanceof AbilityObj) {
        entity = entity.getType();
    }
    if (StringMaster.isInteger(value)) {
        int index = StringMaster.getInteger(value) - 1;
        String varProp = entity.getProperty(G_PROPS.VARIABLES);
        if (StringMaster.isEmpty(varProp)) {
            varProp = DEFAULT_VARS;
        }
        boolean containerFormula = false;
        if (!entity.getParam("FORMULA").isEmpty()) {
            // StringMaster.compare(varProp.replace(";", ""), "FORMULA",
            // true)) {
            varProp = entity.getParam("FORMULA");
            containerFormula = true;
        }
        List<String> openContainer = StringMaster.openContainer(varProp);
        if (openContainer.size() > index) {
            VALUE val = null;
            if (!containerFormula && !isBuffParsing()) {
                val = ContentManager.getValue(openContainer.get(index));
                replacement = entity.getValue(val);
            } else {
                replacement = openContainer.get(index);
            }
            if (containerFormula || val instanceof PARAMETER) {
                if (StringMaster.isInteger(replacement)) {
                    return replacement;
                }
                try {
                    if (isAbilityParsing()) // if (replacement.contains(",")) {
                    // // TODO all function names!
                    // if (replacement.toLowerCase().contains("min")
                    // || replacement.toLowerCase().contains(
                    // "max")) {
                    // // get the insides of the formula?
                    // // parts = replacement.split(regex);
                    // // parts[1] = parts[1].
                    // //
                    // // replacement = parts[0] + parts[1];
                    // return replacement.replace(",",
                    // StringMaster.COMMA_CODE);
                    // }
                    // } else
                    {
                        return replacement.replace(",", StringMaster.COMMA_CODE);
                    }
                    if (game.isSimulation()) {
                        replacement = new Formula(replacement).getInt(ref) + " (" + formatFormula(replacement) + ")";
                    } else {
                        replacement = new Formula(replacement).getInt(ref) + "";
                    }
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            } else {
                String result = new Property(true, replacement).getStr(ref);
                if (StringMaster.isEmpty(result)) {
                    replacement = new Parameter(replacement).getInt(ref) + "";
                } else {
                    replacement = result;
                }
            }
        }
    } else {
        if (!isAbilityParsing()) {
            if (StringMaster.isInteger(replacement)) {
                return replacement;
            }
            if (game.isSimulation() && !tooltipParsing) {
                Integer VAL = new Formula(replacement).getInt(ref);
                replacement = VAL + " (" + replacement + ")";
            } else {
                // TODO
                replacement = new Formula(replacement).getInt(ref) + "";
            }
        // props!
        }
    }
    return replacement;
}
Also used : Entity(main.entity.Entity) VALUE(main.content.VALUE) AbilityObj(main.ability.AbilityObj) Formula(main.system.math.Formula) Game(main.game.core.game.Game) Parameter(main.system.math.Parameter) Property(main.system.math.Property) PARAMETER(main.content.values.parameters.PARAMETER)

Example 15 with Formula

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

the class UpkeepRule method subtractUpkeep.

public void subtractUpkeep(Unit unit, Obj payObj) {
    for (PARAMETER p : ValuePages.UPKEEP_PARAMETERS) {
        PARAMETER payParam = DC_ContentManager.getPayParamFromUpkeep(p);
        int amount = new Formula(payObj.getParam(p)).getAppendedByModifier(StringMaster.getValueRef(KEYS.SOURCE, PARAMS.UPKEEP_MOD)).getInt(unit.getRef());
        if (amount <= 0) {
            return;
        }
        unit.modifyParameter(payParam, -amount);
        unit.getGame().getLogManager().log(payObj.getName() + "'s " + ContentManager.getBaseParameterFromCurrent(p).getName() + " upkeep paid: " + amount);
    }
}
Also used : Formula(main.system.math.Formula) PARAMETER(main.content.values.parameters.PARAMETER)

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