Search in sources :

Example 51 with Formula

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

the class BuffRulesTest method buffRuleTest.

@Test
public void buffRuleTest() {
    // root_params
    int i = 0;
    for (PARAMS root_param : root_params) {
        // also test rule's state?
        Integer initial = entity.getIntParam(reduced_params[i]);
        entity.setParam(root_param, new Formula(value_low[i]).getInt(new Ref(entity)));
        game.getStateManager().reset(entity);
        Integer reduced = entity.getIntParam(reduced_params[i]);
        if (isReductionOn(root_param)) {
            printingAsserts.assertGreaterThanAndLog(initial, reduced, root_param + " rule");
        }
        if (!isIncreaseOn(root_param)) {
            i++;
            continue;
        }
        if (reduced_params[i] != increased_params[i]) {
            initial = entity.getIntParam(increased_params[i]);
        }
        entity.setParam(root_param, new Formula(value_high[i]).getInt(new Ref(entity)));
        game.getStateManager().reset(entity);
        Integer increased = entity.getIntParam(increased_params[i]);
        printingAsserts.assertGreaterThanAndLog(increased, initial, root_param + " rule");
        i++;
    }
}
Also used : Formula(main.system.math.Formula) Ref(main.entity.Ref) PARAMS(eidolons.content.PARAMS) CreateUnitTest(tests.entity.CreateUnitTest) Test(org.junit.Test)

Example 52 with Formula

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

the class DC_CostsFactory method getCostsForSpell.

public static Costs getCostsForSpell(DC_ActiveObj spell, boolean isSpell) {
    List<Cost> costs = new ArrayList<>();
    Cost cost = null;
    if (!DC_Engine.isAtbMode()) {
        cost = getCost(spell, PARAMS.AP_COST, PARAMS.C_N_OF_ACTIONS);
        if (cost != null) {
            costs.add(cost);
        }
    }
    cost = getCost(spell, PARAMS.ENERGY_COST, PARAMS.C_ENERGY);
    if (cost != null) {
        costs.add(cost);
    }
    // cost = getCost(spell, PARAMS.ATP_COST, PARAMS.C_N_OF_ATTACKS);
    // if (cost != null)
    // costs.add(cost);
    cost = getCost(spell, PARAMS.CP_COST, PARAMS.C_N_OF_COUNTERS);
    if (cost != null) {
        costs.add(cost);
    }
    // cost = getCost(spell, PARAMS.MP_COST, PARAMS.C_N_OF_MOVES);
    // if (cost != null)
    // costs.add(cost);
    cost = getCost(spell, PARAMS.ESS_COST, PARAMS.C_ESSENCE);
    if (cost != null) {
        costs.add(cost);
    }
    cost = getCost(spell, PARAMS.STA_COST, PARAMS.C_STAMINA);
    if (cost != null) {
        costs.add(cost);
    }
    cost = getCost(spell, PARAMS.FOC_COST, PARAMS.C_FOCUS);
    if (cost != null) {
        costs.add(cost);
    }
    cost = getCost(spell, PARAMS.ENDURANCE_COST, PARAMS.C_ENDURANCE);
    if (cost != null) {
        costs.add(cost);
    }
    // if (spell.getIntParam(PARAMS.FOC_REQ) == 0)
    // return new Costs(costs);
    String s = "" + Math.max(spell.getIntParam(PARAMS.FOC_REQ), spell.getIntParam(PARAMS.FOC_COST));
    CostRequirements requirements = new CostRequirements(new Payment(PARAMS.C_FOCUS, new Formula(s)));
    if (!DC_Engine.isAtbMode())
        requirements.add(new Requirement(new NumericCondition("1", StringMaster.getValueRef(KEYS.ACTIVE, PARAMS.C_COOLDOWN)), InfoMaster.COOLDOWN_REASON));
    addSpecialRequirements(requirements, spell);
    return (isSpell) ? new DC_SpellCosts(requirements, costs) : new DC_ActionCosts(requirements, costs);
}
Also used : Formula(main.system.math.Formula) Requirement(main.elements.conditions.Requirement) ArrayList(java.util.ArrayList) NumericCondition(main.elements.conditions.NumericCondition)

Example 53 with Formula

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

the class ActiveInitializer method initCosts.

public void initCosts(boolean anim) {
    Costs costs = null;
    if (getEntity().isFree()) {
        costs = new Costs(new ArrayList<>());
    } else {
        try {
            costs = DC_CostsFactory.getCostsForSpell(getEntity(), getChecker().isSpell());
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
        Cost cp_cost = costs.getCost(PARAMS.C_N_OF_COUNTERS);
        Formula ap_cost = DC_Engine.isAtbMode() ? new Formula(getParam(PARAMS.AP_COST)) : costs.getCost(PARAMS.C_N_OF_ACTIONS).getPayment().getAmountFormula();
        boolean noCounterCost = cp_cost == null;
        if (!noCounterCost) {
            noCounterCost = cp_cost.getPayment().getAmountFormula().toString().isEmpty() || cp_cost.getPayment().getAmountFormula().toString().equals("0");
        }
        if (noCounterCost) {
            // if not specifically set...
            if (getHandler().isExtraAttackMode()) {
                cp_cost = new CostImpl(new Payment(PARAMS.C_N_OF_COUNTERS, (ap_cost)));
                cp_cost.getPayment().getAmountFormula().applyModifier(getEntity().getOwnerObj().getIntParam(PARAMS.EXTRA_ATTACKS_POINT_COST_MOD));
                cp_cost.setCostParam(PARAMS.CP_COST);
            }
        } else {
            if (!(getHandler().isExtraAttackMode())) {
                costs.getCosts().remove(cp_cost);
            }
        }
        if (!DC_Engine.isAtbMode())
            if (getHandler().isAttackOfOpportunityMode()) {
                // TODO only if watched? better
                // here perhaps!
                cp_cost.addAltCost(new CostImpl(new Payment(PARAMS.C_N_OF_ACTIONS, ap_cost)));
            }
        costs.removeCost(getHandler().isExtraAttackMode() ? PARAMS.C_N_OF_ACTIONS : PARAMS.C_N_OF_COUNTERS);
    }
    if (anim) {
    // getAnimator().  addCostAnim();
    }
    costs.setActive(getEntity());
    // TODO what for?
    // if (!getHandler().isInstantMode() || getHandler().isCounterMode()) {
    // getHandler().getActivator().setCanActivate(costs.canBePaid(getRef()));
    // }
    costs.setActiveId(getId());
    if (getEntity().isAttackAny())
        if (getEntity().isExtraAttackMode())
            applyDynamicCostMods(costs);
    getEntity().setCosts(costs);
}
Also used : Formula(main.system.math.Formula) Costs(main.elements.costs.Costs) Payment(main.elements.costs.Payment) ArrayList(java.util.ArrayList) CostImpl(main.elements.costs.CostImpl) Cost(main.elements.costs.Cost)

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