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);
}
}
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);
}
}
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);
}
}
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);
}
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;
}
Aggregations