use of main.system.math.Formula in project Eidolons by IDemiurge.
the class ConditionMaster method getYLineCondition.
public static Condition getYLineCondition(Obj obj1, Obj obj2, boolean bidirectional) {
Conditions conditions = new Conditions();
if (!bidirectional) {
Condition sideCondition = (!PositionMaster.isAbove(obj1, obj2)) ? new NumericCondition(new Formula("{SOURCE_POS_Y}"), new Formula("{MATCH_POS_Y}"), false) : new NumericCondition(new Formula("{MATCH_POS_Y}"), new Formula("{SOURCE_POS_Y}"), false);
conditions.add(sideCondition);
}
Condition lineCondition = new NumericCondition(new Formula("{SOURCE_POS_X}"), new Formula("{MATCH_POS_X}"), true);
conditions.add(lineCondition);
return conditions;
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class HeroManager method modifyCostParam.
protected Integer modifyCostParam(Unit hero, Entity type, OBJ_TYPE TYPE, boolean selling, PROPERTY p) {
String cost = getCost(type, hero, TYPE, p, !selling);
Integer amount = new Formula(cost).getInt(hero.getRef());
if (!selling) {
amount *= -1;
}
hero.modifyParameter(TYPE.getParam(), amount);
if (!selling) {
amount *= -1;
}
return amount;
// update(hero); TODO
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class HeroManager method getCost.
public static String getCost(Entity type, Entity hero, OBJ_TYPE TYPE, PROPERTY PROP, boolean buying) {
if (TYPE.getParam() == null) {
return "";
}
PARAMETER costParam = ContentManager.getCostParam(TYPE.getParam());
PARAMETER discountParam = DC_ContentManager.getCostReductionParam(costParam, PROP);
Integer value = type.getIntParam(costParam);
Integer mod = hero.getIntParam(discountParam);
Formula costFormula = new Formula("" + value);
if (discountParam != null) {
costFormula.applyFactor((!buying ? "" : "-") + StringMaster.getValueRef(KEYS.SOURCE, discountParam));
}
if (!buying) {
costFormula.applyFactor(-DC_Formulas.getSellingPriceReduction());
}
discountParam = DC_ContentManager.getSpecialCostReductionParam(costParam, PROP);
if (discountParam == null) {
return "" + costFormula;
}
mod = hero.getIntParam(discountParam);
if (mod == 100) {
value = 0;
} else {
costFormula.applyFactor((!buying ? "" : "-") + StringMaster.getValueRef(KEYS.SOURCE, discountParam));
}
return "(" + costFormula + ")";
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class DealDamageEffectTest method dealDamageEffectTest.
@Test
public void dealDamageEffectTest() {
assertTrue(source != null);
assertTrue(target != null);
int origToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
int origEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
Effect eff = new DealDamageEffect(new Formula("50"), GenericEnums.DAMAGE_TYPE.BLUDGEONING.getName(), DAMAGE_MODIFIER.UNBLOCKABLE);
Ref ref = new Ref(source);
ref.setTarget(target.getId());
ref.setID(KEYS.ACTIVE, source.getAction("Attack").getId());
eff.apply(ref);
Integer newToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
Integer newEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
assertTrue(newToughness < origToughness);
assertTrue(newEndurance < origEndurance);
}
use of main.system.math.Formula in project Eidolons by IDemiurge.
the class TextGenerator method generatePerkParamBonuses.
public static String generatePerkParamBonuses(Entity e) {
List<List<VALUE>> pages = ValuePageManager.getValuesForHCInfoPages(e.getOBJ_TYPE_ENUM());
String string = PREFIX;
for (List<VALUE> list : pages) {
boolean prop = false;
for (VALUE v : list) {
if (v instanceof PARAMETER) {
if (!ContentManager.isValueForOBJ_TYPE(DC_TYPE.CHARS, v)) {
continue;
}
String amount = e.getValue(v);
amount = TextParser.parse(amount, e.getRef());
int n = new Formula(amount).getInt(e.getRef());
if (n != 0) {
string += n + " " + v.getName() + ", ";
}
} else {
prop = true;
break;
}
}
if (!prop && !list.equals(pages.get(pages.size() - 1))) {
string += StringMaster.NEW_LINE;
}
}
// StringMaster.replaceLast(" ," "and
string.substring(0, string.length() - 2);
return string;
}
Aggregations