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