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