Search in sources :

Example 1 with CostImpl

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

the class DualAttackMaster method getDualCosts.

private static Costs getDualCosts(DC_UnitAction main, DC_UnitAction offhand) {
    List<Cost> list = new ArrayList<>();
    Costs costsMain = main.getCosts();
    // if (costsMain == null)
    costsMain = DC_CostsFactory.getCostsForAction(main);
    Costs costsOffhand = offhand.getCosts();
    // if (costsOffhand == null)
    costsOffhand = DC_CostsFactory.getCostsForAction(offhand);
    for (Cost cost : costsMain.getCosts()) {
        PARAMETER p = cost.getPayment().getParamToPay();
        Cost cost2 = costsOffhand.getCost(p);
        Integer value1 = cost.getPayment().getAmountFormula().getInt();
        Integer value2 = (cost2 == null) ? 0 : cost2.getPayment().getAmountFormula().getInt();
        Boolean mode = getMinMaxOrAverage((PARAMS) p);
        Integer value = MathMaster.getTotalOrMinMax(mode, value1, value2);
        list.add(new CostImpl(new Payment(p, value), cost.getCostParam()));
    }
    Costs costsDual = new Costs(list);
    Integer focReq = 25;
    list.add(new CostImpl(new Payment(PARAMS.FOC_REQ, focReq)));
    return costsDual;
}
Also used : Costs(main.elements.costs.Costs) Payment(main.elements.costs.Payment) ArrayList(java.util.ArrayList) CostImpl(main.elements.costs.CostImpl) Cost(main.elements.costs.Cost) PARAMETER(main.content.values.parameters.PARAMETER)

Example 2 with CostImpl

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

ArrayList (java.util.ArrayList)2 Cost (main.elements.costs.Cost)2 CostImpl (main.elements.costs.CostImpl)2 Costs (main.elements.costs.Costs)2 Payment (main.elements.costs.Payment)2 PARAMETER (main.content.values.parameters.PARAMETER)1 Formula (main.system.math.Formula)1