Search in sources :

Example 21 with Formula

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;
}
Also used : ClassificationCondition(main.elements.conditions.standard.ClassificationCondition) DynamicCondition(main.elements.conditions.standard.DynamicCondition) OwnershipCondition(main.elements.conditions.standard.OwnershipCondition) Formula(main.system.math.Formula)

Example 22 with Formula

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
}
Also used : Formula(main.system.math.Formula)

Example 23 with Formula

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 + ")";
}
Also used : Formula(main.system.math.Formula) PARAMETER(main.content.values.parameters.PARAMETER)

Example 24 with Formula

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);
}
Also used : Formula(main.system.math.Formula) Ref(main.entity.Ref) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) FastDcTest(tests.FastDcTest) Test(org.junit.Test)

Example 25 with Formula

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;
}
Also used : Formula(main.system.math.Formula) List(java.util.List) VALUE(main.content.VALUE) PARAMETER(main.content.values.parameters.PARAMETER)

Aggregations

Formula (main.system.math.Formula)53 PARAMETER (main.content.values.parameters.PARAMETER)12 Ref (main.entity.Ref)11 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)8 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)8 Effects (main.ability.effects.Effects)7 SkillPointCondition (eidolons.ability.conditions.req.SkillPointCondition)5 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)5 ArrayList (java.util.ArrayList)5 Effect (main.ability.effects.Effect)5 ClassTreeCondition (eidolons.ability.conditions.req.ClassTreeCondition)4 MultiClassCondition (eidolons.ability.conditions.req.MultiClassCondition)4 ValueGroupCondition (eidolons.ability.conditions.req.ValueGroupCondition)4 Unit (eidolons.entity.obj.unit.Unit)4 ObjType (main.entity.type.ObjType)4 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)3 RemoveBuffEffect (eidolons.ability.effects.oneshot.buff.RemoveBuffEffect)3 RollEffect (eidolons.ability.effects.oneshot.mechanic.RollEffect)3 SummonEffect (eidolons.ability.effects.oneshot.unit.SummonEffect)3 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)3