Search in sources :

Example 36 with Formula

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

the class ForceRule method applyPush.

// TODO into PushEffect! With std knockdown on "landing" or damage!
public static void applyPush(int force, DC_ActiveObj attack, BattleFieldObject source, BattleFieldObject target) {
    DIRECTION d = DirectionMaster.getRelativeDirection(source, target);
    if (attack.isSpell()) {
        d = DirectionMaster.getRelativeDirection(attack.getRef().getTargetObj(), target);
    // cell
    }
    int distance = getPushDistance(MathMaster.applyModIfNotZero(force, attack.getFinalModParam(PARAMS.FORCE_PUSH_MOD)), target);
    if (distance == 0) {
        if (isTestMode()) {
            distance = 1;
        } else {
            return;
        }
    }
    if (d.isDiagonal()) {
        distance = (int) Math.round(Math.sqrt(distance));
        if (distance == 0) {
            d = d.rotate90(RandomWizard.random());
            distance = 1;
        }
    }
    // int weight = target.getIntParam(PARAMS.TOTAL_WEIGHT);
    // if (distance == 0)
    // distance = RandomWizard.chance(force * 100 / weight) ? 1 : 0; // TODO
    int x_displacement = BooleanMaster.isTrue(d.growX) ? distance : -distance;
    int y_displacement = BooleanMaster.isTrue(d.growY) ? distance : -distance;
    if (!d.isDiagonal()) {
        if (d.isVertical()) {
            x_displacement = 0;
        } else {
            y_displacement = 0;
        }
    }
    Ref ref = attack.getRef().getCopy();
    ref.setTarget(target.getId());
    new MoveEffect("target", new Formula("" + x_displacement), new Formula("" + y_displacement)).apply(ref);
// roll dexterity against Fall Down
// TODO knock vs push - which is 'critical'?
// maybe just apply a modifier, then calculate if push/knock?
// sometimes it'll be better to be 'weak', eh?
}
Also used : Formula(main.system.math.Formula) Ref(main.entity.Ref) DIRECTION(main.game.bf.Coordinates.DIRECTION) MoveEffect(eidolons.ability.effects.oneshot.move.MoveEffect)

Example 37 with Formula

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

the class DC_RequirementsManager method generateSpellRequirements.

// TODO preCheck upgrade
public Requirements generateSpellRequirements(Entity type, int mode) {
    Requirements req = new Requirements();
    String cost = (mode != NORMAL_MODE) ? HeroManager.getCost(type, getHero(), type.getOBJ_TYPE_ENUM(), PROPS.VERBATIM_SPELLS) : HeroManager.getCost(type, getHero());
    Condition paramCondition = ConditionMaster.getParamCondition(1, PARAMS.XP, PARAMS.XP_COST);
    ((NumericCondition) paramCondition).setComparingValue(new Formula("" + cost));
    Requirement xpReq = new Requirement(paramCondition, InfoMaster.getParamReasonString(type, PARAMS.XP, cost));
    req.add(xpReq);
    PARAMETER spellMastery = ContentManager.getSpellMasteryForSpell(type);
    if (mode != NORMAL_MODE) {
        req.add(new Requirement(ConditionMaster.getParamCondition(spellMastery.getName(), "1", true), InfoMaster.getSpellMasteryReason(spellMastery)));
        if (mode != VERBATIM_MODE) {
            req.add(getParamRequirements(PARAMS.MEMORY_REMAINING, PARAMS.SPELL_DIFFICULTY, type));
        }
        if (type.isUpgrade()) {
            String base = type.getProperty(G_PROPS.BASE_TYPE);
            req.add(new Requirement(ConditionMaster.getPropCondition(KEYS.SOURCE.toString(), PROPS.VERBATIM_SPELLS, base), InfoMaster.SPELL_BASE + base));
        }
        return req;
    }
    if (spellMastery != null) {
        String amount = "" + new Formula("2*" + StringMaster.getValueRef(KEYS.SOURCE, PARAMS.SPELL_DIFFICULTY)).getInt(type.getRef());
        req.add(new Requirement(getTotalCondition(amount, spellMastery, PARAMS.INTELLIGENCE), // PARAMS.SPELL_DIFFICULTY)),
        InfoMaster.getTotalReasonString(// getOrParamReasonString
        amount, PARAMS.INTELLIGENCE, spellMastery)));
    }
    // req.add(new Requirement(new NotCondition(new
    // NumericCondition(StringMaster.getValueRef(
    // KEYS.MATCH, PARAMS.SPELL_DIFFICULTY), "0", true)),
    // InfoMaster.UNDER_CONSTRUCTION));
    Requirement unknownReq = new Requirement(new NotCondition(ConditionMaster.getPropCondition(PROPS.KNOWN_SPELLS, G_PROPS.NAME, KEYS.SOURCE.toString(), KEYS.MATCH.toString())), InfoMaster.SPELL_KNOWN);
    req.add(unknownReq);
    return req;
}
Also used : ClassTreeCondition(eidolons.ability.conditions.req.ClassTreeCondition) SkillPointCondition(eidolons.ability.conditions.req.SkillPointCondition) ValueGroupCondition(eidolons.ability.conditions.req.ValueGroupCondition) MultiClassCondition(eidolons.ability.conditions.req.MultiClassCondition) Formula(main.system.math.Formula) PARAMETER(main.content.values.parameters.PARAMETER)

Example 38 with Formula

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

the class DC_RequirementsManager method generateItemRequirements.

private Requirements generateItemRequirements(Entity type, int mode) {
    // str/agi/int req!
    Requirement paramRequirements = getParamRequirements(PARAMS.GOLD, PARAMS.GOLD_COST, type);
    ((NumericCondition) paramRequirements.getCondition()).setComparingValue(new Formula("" + HeroManager.getCost(type, getHero())));
    return new Requirements(paramRequirements);
}
Also used : Formula(main.system.math.Formula)

Example 39 with Formula

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

the class DC_RequirementsManager method modifyRankReq.

private Requirements modifyRankReq(Entity feat, Requirements reqs, String tip, Map<String, Condition> reqMap, Condition condition, int rank) {
    if (condition instanceof Conditions) {
        Conditions conditions = (Conditions) condition;
        OrConditions orCondition = null;
        String[] tipParts = null;
        if (tip.contains(" or ")) {
            orCondition = new OrConditions();
            tipParts = tip.split(" or ");
        }
        String reqTip = tip;
        int i = 0;
        String prevValue = null;
        for (Condition c : conditions) {
            if (orCondition != null) {
                if (reqTip.equals(tip)) {
                    reqTip = "";
                }
                Requirements modifiedReqs = modifyRankReq(feat, reqs, tipParts[i], new HashMap<>(), c, rank);
                for (String t : modifiedReqs.getReqMap().keySet()) {
                    Condition c2 = modifiedReqs.getReqMap().get(t);
                    orCondition.add(c2);
                    // if (prevValue != null)
                    // if (!prevValue.equals(value))
                    reqTip += t + " or ";
                }
                i++;
            // prevValue = value;
            } else {
                modifyRankReq(feat, reqs, reqTip, reqMap, c, rank);
            }
        }
        if (orCondition != null) {
            reqMap.put(StringMaster.cropLast(reqTip, 4), orCondition);
        }
    } else if (condition instanceof NumericCondition) {
        NumericCondition numericCondition = (NumericCondition) condition;
        Formula f = new Formula(numericCondition.getComparingValue().toString());
        String originalValue = "" + f.getInt();
        Integer mod = (rank + 1) * feat.getIntParam(PARAMS.RANK_SD_MOD);
        if (tip.contains("Xp")) {
            f.applyModifier(feat.getIntParam(PARAMS.RANK_XP_MOD));
        } else {
            f.applyFactor(mod);
        }
        String value = "" + f.getInt();
        // }
        if (// total...
        tip.contains("otal ")) {
            tip.replace(originalValue, value);
        }
        tip = tip.replace(originalValue, value);
        LogMaster.log(1, tip + " for " + feat + " = " + value);
        numericCondition.setComparingValue(new Formula(value));
        reqs = new Requirements(new Requirement(numericCondition, tip));
        reqMap.put(tip, condition);
    }
    return reqs;
}
Also used : ClassTreeCondition(eidolons.ability.conditions.req.ClassTreeCondition) SkillPointCondition(eidolons.ability.conditions.req.SkillPointCondition) ValueGroupCondition(eidolons.ability.conditions.req.ValueGroupCondition) MultiClassCondition(eidolons.ability.conditions.req.MultiClassCondition) Formula(main.system.math.Formula)

Example 40 with Formula

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

the class DC_MathManager method evaluateSummonEnergyCost.

@Override
public Integer evaluateSummonEnergyCost(Entity obj, String s) {
    // 5+5*level +(level^2 -1)
    Formula formula = new Formula("4+ 5*{SOURCE_LEVEL}+{SOURCE_LEVEL}*{SOURCE_LEVEL}");
    Integer cost = formula.getInt(obj.getRef());
    return cost;
}
Also used : Formula(main.system.math.Formula)

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