Search in sources :

Example 26 with Formula

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

the class ModelManager method autoAdjustSkill.

private static void autoAdjustSkill(ObjType type) {
    int sd = type.getIntParam(PARAMS.SKILL_DIFFICULTY);
    if (sd == 0) {
        sd = DC_Formulas.getSkillDifficultyForXpCost(type.getIntParam(PARAMS.XP_COST));
        type.setParam(PARAMS.SKILL_DIFFICULTY, sd);
    }
    String reqs = type.getProperty(PROPS.REQUIREMENTS);
    if (reqs.contains("Principles")) {
        String cleanedReqs = reqs;
        for (String sub : StringMaster.open(reqs)) {
            if (!sub.contains("Principles")) {
                continue;
            }
            cleanedReqs = cleanedReqs.replace(sub, "");
            cleanedReqs = cleanedReqs.replace(";;", ";");
        }
        type.setProperty(PROPS.REQUIREMENTS, cleanedReqs);
        LogMaster.log(1, reqs + "; cleanedReqs =" + cleanedReqs);
    }
    ObjType parent = DataManager.getParent(type);
    if (parent != null && parent != type) {
        autoAdjustSkill(parent);
        Integer parentSd = parent.getIntParam(PARAMS.SKILL_DIFFICULTY);
        if (type.getIntParam(PARAMS.CIRCLE) - parent.getIntParam(PARAMS.CIRCLE) != 1) {
            String childSd = "2*x-sqrt(x)-0.01*x^2";
            childSd = childSd.replace("x", parent.getParam(PARAMS.SKILL_DIFFICULTY));
            Formula formula = new Formula(childSd);
            sd = formula.getInt();
            while (getMinCircle(sd) - getMinCircle(parentSd) < 1) {
                sd++;
            }
            while (getMinCircle(sd) - getMinCircle(parentSd) > 1) {
                sd--;
            }
            LogMaster.setOff(false);
            LogMaster.log(1, type.getName() + "'s difficulty auto-set: " + sd + " from " + parent.getName() + "'s " + parentSd);
            type.setParam(PARAMS.SKILL_DIFFICULTY, sd);
        }
    }
    int xpCost = DC_Formulas.calculateFormula(DC_Formulas.XP_COST_PER_SKILL_DIFFICULTY, sd);
    xpCost = xpCost - xpCost % 5;
    type.setParam(PARAMS.XP_COST, xpCost);
    int circle = getMinCircle(sd);
    type.setParam(PARAMS.CIRCLE, circle);
    resetAltBaseTypes(type);
    if (!type.getParamMap().get(PARAMS.RANK_MAX.getName()).isEmpty()) {
        return;
    }
    // updated?
    if (circle == 0) {
        type.setParam(PARAMS.RANK_MAX, 5);
    } else if (circle == 1) {
        type.setParam(PARAMS.RANK_MAX, 3);
    } else if (circle == 2) {
        type.setParam(PARAMS.RANK_MAX, 2);
    }
}
Also used : Formula(main.system.math.Formula) ObjType(main.entity.type.ObjType)

Example 27 with Formula

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

the class CostRequirements method initConditions.

private void initConditions(List<Payment> toPay, Ref ref) {
    reqMap.clear();
    reqMap.putAll(additionalReqList);
    for (Payment payment : toPay) {
        if (payment.getAmountFormula().toString().equals("0")) {
            continue;
        }
        Formula amountFormula = payment.getAmountFormula();
        if (amountFormula.toString().contains(StringMaster.FORMULA_FUNC_OPEN_CHAR)) {
            continue;
        }
        String value = "" + amountFormula.getInt(ref);
        String r = InfoMaster.getParamReasonString(value, payment.getParamToPay());
        Condition c = new NumericCondition(false, StringMaster.getValueRef(KEYS.SOURCE.toString(), payment.getParamToPay().toString()), value);
        reqMap.put(r, c);
    }
}
Also used : NumericCondition(main.elements.conditions.NumericCondition) Condition(main.elements.conditions.Condition) Formula(main.system.math.Formula) NumericCondition(main.elements.conditions.NumericCondition)

Example 28 with Formula

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

the class ModeEffect method addPeriodicEffect.

private void addPeriodicEffect() {
    String periodicValues = mode.getPeriodicValues();
    if (periodicValues == null)
        return;
    for (String substring : StringMaster.openContainer(periodicValues)) {
        String amount = VariableManager.getVar(substring, 0);
        String maxAmount = VariableManager.getVar(substring, 1);
        String periodicValue = VariableManager.removeVarPart(substring);
        String period = mode.getPeriod();
        Formula max = new Formula(maxAmount);
        Formula formula = new Formula(amount);
        Effect effect = new ModifyValueEffect(periodicValue, MOD.MODIFY_BY_CONST, formula, max);
        Effect fx = new PeriodicEffect(period, effect);
        fx.setRef(Ref.getSelfTargetingRefCopy(ref.getSourceObj()));
        addBuffEffect.addEffect(fx);
    }
}
Also used : PeriodicEffect(main.ability.effects.periodic.PeriodicEffect) Formula(main.system.math.Formula) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) DivinationEffect(eidolons.ability.effects.oneshot.spell.DivinationEffect) SetCustomModeEffect(eidolons.ability.effects.continuous.SetCustomModeEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) ModifyPropertyEffect(eidolons.ability.effects.common.ModifyPropertyEffect) PeriodicEffect(main.ability.effects.periodic.PeriodicEffect) RemoveBuffEffect(eidolons.ability.effects.oneshot.buff.RemoveBuffEffect) ImmobilizeEffect(eidolons.ability.effects.oneshot.status.ImmobilizeEffect)

Example 29 with Formula

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

the class ModeEffect method addEndTurnEffect.

private void addEndTurnEffect() {
    Condition condition = new StringComparison(prop, mode.toString(), true);
    if (mode == STD_MODES.DIVINATION) {
        Effect effect = new DivinationEffect();
        addBuffEffect.addEffect(new DelayedEffect(effect, condition));
        return;
    }
    String formula = mode.getFormula();
    if (ref.getActive() instanceof DC_ActiveObj) {
        DC_ActiveObj activeObj = (DC_ActiveObj) ref.getActive();
        if (activeObj.getParam(PARAMS.FORMULA).contains(StringMaster.MOD)) {
            formula = StringMaster.wrapInParenthesis(formula) + "*" + activeObj.getParam(PARAMS.FORMULA) + "/100";
        } else if (activeObj.getIntParam(PARAMS.FORMULA) != 0) {
            formula += "+" + activeObj.getIntParam(PARAMS.FORMULA);
        }
    }
    ModifyValueEffect effect = new ModifyValueEffect(mode.getParameter(), MOD.MODIFY_BY_CONST, new Formula("min(0, " + formula + ")"));
    PARAMETER param = ContentManager.getPARAM(mode.getParameter());
    effect.setParam(param);
    effect.setMaxParam(ContentManager.getBaseParameterFromCurrent(param));
    Formula appendedByModifier = new Formula(formula).getAppendedByModifier(timeModifier);
    effect.setFormula(appendedByModifier);
    addBuffEffect.addEffect(new DelayedEffect(effect, condition));
// new DelayedEffect(effect, condition).apply(ref);
}
Also used : Condition(main.elements.conditions.Condition) RefCondition(main.elements.conditions.RefCondition) Formula(main.system.math.Formula) StringComparison(main.elements.conditions.StringComparison) DivinationEffect(eidolons.ability.effects.oneshot.spell.DivinationEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) DivinationEffect(eidolons.ability.effects.oneshot.spell.DivinationEffect) SetCustomModeEffect(eidolons.ability.effects.continuous.SetCustomModeEffect) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) ModifyPropertyEffect(eidolons.ability.effects.common.ModifyPropertyEffect) PeriodicEffect(main.ability.effects.periodic.PeriodicEffect) RemoveBuffEffect(eidolons.ability.effects.oneshot.buff.RemoveBuffEffect) ImmobilizeEffect(eidolons.ability.effects.oneshot.status.ImmobilizeEffect) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) PARAMETER(main.content.values.parameters.PARAMETER)

Example 30 with Formula

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

the class UpkeepRule method checkCanUpkeep.

private boolean checkCanUpkeep(Unit unit, Obj payObj) {
    if (unit.isDead()) // if (payObj.checkBool(DISPEL_ON_DEATH)) //only those with upkeep,
    // never fear!
    {
        return false;
    }
    for (PARAMETER p : ValuePages.UPKEEP_PARAMETERS) {
        PARAMETER payParamFromUpkeep = DC_ContentManager.getPayParamFromUpkeep(p);
        Integer amount = new Formula(payObj.getParam(p)).getAppendedByModifier(StringMaster.getValueRef(KEYS.SUMMONER, PARAMS.UPKEEP_MOD)).getInt(unit.getRef());
        if (amount <= 0) {
            continue;
        }
        String param = amount + "";
        if (!unit.checkParam(payParamFromUpkeep, param)) {
            return false;
        }
    }
    return true;
}
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