Search in sources :

Example 6 with Cost

use of main.elements.costs.Cost in project Eidolons by IDemiurge.

the class ParamAnalyzer method getCostPriorityFactor.

public int getCostPriorityFactor(Costs cost, Unit unit) {
    // if (!cost.canBePaid(unit.getRef()))
    // return -100;
    int penalty = 0;
    for (Cost c : cost.getCosts()) {
        PARAMETER p = c.getPayment().getParamToPay();
        // return a *formula*
        int base_value = getParamPriority(p, unit);
        // perhaps?
        if (base_value <= 0) {
            continue;
        }
        int perc = DC_MathManager.getCentimalPercentage(c.getPayment().getAmountFormula().getInt(unit.getRef()), unit.getIntParam(p));
        if (perc > 100) {
            // not enough
            if (p != PARAMS.C_N_OF_ACTIONS) {
                // actions can be gained on next  round
                return 0;
            }
        }
        if (perc <= 0) {
            continue;
        }
        // speaking of real numbers, stamina/foc should have a non-linear
        // formula I reckon
        // 
        int amount = MathMaster.getFractionValueCentimal(base_value, perc);
        penalty += (amount);
    }
    return MathMaster.calculateFormula(getCOST_PENALTY_FORMULA(), penalty);
}
Also used : Cost(main.elements.costs.Cost) PARAMETER(main.content.values.parameters.PARAMETER)

Example 7 with Cost

use of main.elements.costs.Cost in project Eidolons by IDemiurge.

the class ExplorationActionHandler method adjustCosts.

private static void adjustCosts(Costs costs) {
    costs.getCosts().removeIf(cost -> ignoredCosts.contains(cost.getCostParam()));
    // for (PARAMETER p :     modifiedCosts) {
    // Cost sub = costs.getCost(p);
    // String modifier=  modifiedCosts.get(p);
    // sub.getPayment().getAmountFormula().append("*"+modifier);
    // }
    Cost sub = costs.getCost(PARAMS.STA_COST);
    if (sub != null)
        sub.getPayment().getAmountFormula().append("*" + STA_MODIFIER);
    sub = costs.getCost(PARAMS.FOC_COST);
    if (sub != null)
        sub.getPayment().getAmountFormula().append("*" + STA_MODIFIER);
}
Also used : Cost(main.elements.costs.Cost)

Example 8 with Cost

use of main.elements.costs.Cost 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

Cost (main.elements.costs.Cost)8 Costs (main.elements.costs.Costs)6 PARAMETER (main.content.values.parameters.PARAMETER)5 ArrayList (java.util.ArrayList)3 CostImpl (main.elements.costs.CostImpl)2 Payment (main.elements.costs.Payment)2 Formula (main.system.math.Formula)2 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 ActivateEffect (eidolons.ability.effects.oneshot.activation.ActivateEffect)1 PARAMS (eidolons.content.PARAMS)1 DC_UnitAction (eidolons.entity.active.DC_UnitAction)1 Abilities (main.ability.Abilities)1 Ability (main.ability.Ability)1 ActiveAbility (main.ability.ActiveAbility)1 Effects (main.ability.effects.Effects)1 XLinkedMap (main.data.XLinkedMap)1 PropCondition (main.elements.conditions.PropCondition)1 CostRequirements (main.elements.costs.CostRequirements)1 AutoTargeting (main.elements.targeting.AutoTargeting)1 Ref (main.entity.Ref)1