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