Search in sources :

Example 1 with Formula

use of main.system.math.Formula in project Eidolons by IDemiurge.

the class ListSizeCondition method check.

@Override
public boolean check(Ref ref) {
    OBJ_TYPE TYPE = C_OBJ_TYPE.BF;
    if (bfObj) {
        TYPE = C_OBJ_TYPE.BF_OBJ;
    }
    if (filter == null) {
        filter = new Filter<>(ref, c, TYPE);
    } else {
        filter.setRef(ref);
    }
    int size = new Formula(sizeFormula).getInt(ref);
    return filter.getObjects().size() >= size;
}
Also used : Formula(main.system.math.Formula) C_OBJ_TYPE(main.content.C_OBJ_TYPE) OBJ_TYPE(main.content.OBJ_TYPE)

Example 2 with Formula

use of main.system.math.Formula in project Eidolons by IDemiurge.

the class FearsomeEffect method applyThis.

@Override
public boolean applyThis() {
    super.applyThis();
    Formula buffer = new Formula(formula.toString());
    formula = formula.getAppendedByFactor(-0.5);
    try {
        for (Unit unit : ((DC_Game) game).getUnits()) {
            if (!friendlyFire) {
                if (unit.getOwner().equals(ref.getSourceObj().getOwner())) {
                    continue;
                }
            }
            if (!unit.checkInSightForUnit((Unit) ref.getSourceObj())) {
                continue;
            }
            ref.setTarget(unit.getId());
            super.applyThis();
        }
    } catch (Exception ignored) {
    } finally {
        formula = buffer;
    }
    return true;
}
Also used : Formula(main.system.math.Formula) DC_Game(eidolons.game.core.game.DC_Game) Unit(eidolons.entity.obj.unit.Unit)

Example 3 with Formula

use of main.system.math.Formula in project Eidolons by IDemiurge.

the class DrainEffect method applyRestoration.

private void applyRestoration() {
    ref.setTarget(source);
    formula = formula.getNegative();
    setMaxParam(getMaxParameter(param));
    if (!alwaysRestoreFull) {
        buffer = formula;
        formula = new Formula("" + -amount_modified);
    }
    super.applyThis();
}
Also used : Formula(main.system.math.Formula)

Example 4 with Formula

use of main.system.math.Formula in project Eidolons by IDemiurge.

the class CadenceRule method checkDualAttackCadence.

public static void checkDualAttackCadence(DC_UnitAction action, Unit unit) {
    if (action.getActionGroup() != ActionEnums.ACTION_TYPE_GROUPS.ATTACK) {
        return;
    }
    boolean singleCadence = checkSingleWeaponCadence(unit, action);
    if (!UnitAnalyzer.checkDualWielding(unit) && !UnitAnalyzer.checkDualNaturalWeapons(unit) && !singleCadence) // || checkSingleCadence(action)
    {
        return;
    }
    Boolean offhand = null;
    if (action.checkProperty(PROP, MAIN_HAND)) {
        offhand = false;
    } else if (action.checkProperty(PROP, OFF_HAND)) {
        offhand = true;
    } else if (singleCadence) // offhand = !action.isOffhand();
    {
        offhand = false;
    }
    if (offhand == null) {
        return;
    }
    Ref ref = new Ref(unit.getGame(), unit.getId());
    DC_WeaponObj weapon = unit.getActiveWeapon(offhand);
    List<Obj> targets = new ArrayList<>();
    if (unit.getWeapon(!offhand) != null) {
        targets.add(unit.getWeapon(!offhand));
    }
    if (unit.getNaturalWeapon(!offhand) != null) {
        targets.add(unit.getNaturalWeapon(!offhand));
    }
    GroupImpl group = new GroupImpl(targets);
    LogMaster.log(LogMaster.RULES_DEBUG, "Cadence Rule applies to " + group);
    ref.setGroup(group);
    if (checkFocusBonusApplies(unit, action, singleCadence)) {
        Integer amount = action.getOwnerObj().getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
        amount += action.getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
        amount += action.getOwnerObj().getActiveWeapon(!offhand).getIntParam(PARAMS.CADENCE_FOCUS_BOOST);
        action.getOwnerObj().modifyParameter(PARAMS.C_FOCUS, amount, 100);
    }
    // INIT COST CADENCE EFFECTS
    Effects effects = new Effects();
    String cadence = unit.getParam(PARAMS.CADENCE_AP_MOD);
    if (cadence.isEmpty()) {
        cadence = DC_Formulas.DEFAULT_CADENCE_AP_MOD + "";
    }
    ModifyValueEffect valueEffect = new ModifyValueEffect(PARAMS.ATTACK_AP_PENALTY, MOD.MODIFY_BY_CONST, cadence);
    valueEffect.appendFormulaByMod(100 + weapon.getIntParam(PARAMS.CADENCE_BONUS));
    effects.add(valueEffect);
    cadence = unit.getParam(PARAMS.CADENCE_STA_MOD);
    if (cadence.isEmpty()) {
        cadence = DC_Formulas.DEFAULT_CADENCE_STA_MOD + "";
    }
    valueEffect = new ModifyValueEffect(PARAMS.ATTACK_STA_PENALTY, MOD.MODIFY_BY_CONST, cadence);
    valueEffect.appendFormulaByMod(100 + weapon.getIntParam(PARAMS.CADENCE_BONUS));
    effects.add(valueEffect);
    if (unit.getIntParam(PARAMS.CADENCE_DAMAGE_MOD) > 0) {
        effects.add(new ModifyValueEffect(PARAMS.DAMAGE_MOD, MOD.MODIFY_BY_CONST, unit.getParam(PARAMS.CADENCE_DAMAGE_MOD)));
    }
    if (unit.getIntParam(PARAMS.CADENCE_ATTACK_MOD) > 0) {
        effects.add(new ModifyValueEffect(PARAMS.ATTACK_MOD, MOD.MODIFY_BY_CONST, unit.getParam(PARAMS.CADENCE_ATTACK_MOD)));
    }
    String buffTypeName = (!offhand) ? buffTypeNameOffHand : buffTypeNameMainHand;
    // ADD REMOVE TRIGGER
    int percentage = 100 - unit.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE) - action.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE) - weapon.getIntParam(PARAMS.CADENCE_RETAINMENT_CHANCE);
    Conditions conditions = new Conditions(new RefCondition(KEYS.EVENT_SOURCE, KEYS.SOURCE));
    if (percentage != 100) {
        conditions.add(new ChanceCondition(new Formula("" + percentage)));
    }
    effects.add(new AddTriggerEffect(STANDARD_EVENT_TYPE.UNIT_ACTION_COMPLETE, conditions, new ActiveAbility(new FixedTargeting(KEYS.BASIS), new RemoveBuffEffect(buffTypeName))));
    // effect = new AddBuffEffect(buffTypeName, effects, DURATION);
    // Condition condition = new StringComparison(StringMaster.getValueRef(KEYS.MATCH, PROP),
    // (offhand) ? MAIN_HAND : OFF_HAND, false);
    // retain condition - hero hasBuff()
    // add remove trigger on attack? either off/main hand, so there is no
    // stacking...
    // linked buffs?
    // effect.setIrresistible(false);
    AddBuffEffect addBuffEffect = new AddBuffEffect(buffTypeName, // new TemplateAutoTargeting(AUTO_TARGETING_TEMPLATES.ACTIONS, condition),
    effects, DURATION);
    // preCheck perk
    addBuffEffect.addEffect(new // what about
    AddTriggerEffect(// counters/AoO?
    STANDARD_EVENT_TYPE.UNIT_ACTION_COMPLETE, new RefCondition(KEYS.EVENT_SOURCE, KEYS.SOURCE), new ActiveAbility(new FixedTargeting(KEYS.SOURCE), new RemoveBuffEffect(buffTypeName))));
    Integer param = unit.getIntParam(PARAMS.CADENCE_DEFENSE_MOD);
    if (param != 0) {
        addBuffEffect.addEffect(new ModifyValueEffect(PARAMS.DEFENSE_MOD, MOD.MODIFY_BY_CONST, "" + param));
    }
    addBuffEffect.setIrresistible(true);
    addBuffEffect.apply(ref);
// TODO defense mod effect
}
Also used : ChanceCondition(main.elements.conditions.standard.ChanceCondition) ActiveAbility(main.ability.ActiveAbility) ArrayList(java.util.ArrayList) RefCondition(main.elements.conditions.RefCondition) ModifyValueEffect(eidolons.ability.effects.common.ModifyValueEffect) Effects(main.ability.effects.Effects) Conditions(main.elements.conditions.Conditions) AddTriggerEffect(eidolons.ability.effects.attachment.AddTriggerEffect) Formula(main.system.math.Formula) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Ref(main.entity.Ref) RemoveBuffEffect(eidolons.ability.effects.oneshot.buff.RemoveBuffEffect) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) FixedTargeting(main.elements.targeting.FixedTargeting) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) BuffObj(main.entity.obj.BuffObj) Obj(main.entity.obj.Obj) GroupImpl(main.entity.group.GroupImpl)

Example 5 with Formula

use of main.system.math.Formula in project Eidolons by IDemiurge.

the class ActionAnimation method drawCosts.

protected boolean drawCosts(AnimPhase phase) {
    int base = getDefaultIconMapOffsetY();
    boolean invert = false;
    Boolean edge;
    boolean positive;
    if (getTarget() == source || phase.isDrawOnSource()) {
        edge = game.getBattleField().getGrid().isOnEdgeY(source.getCoordinates());
        // TODO
        positive = BooleanMaster.isTrue(edge) || edge == null;
        base = getOffsetBase(positive);
        if (base < 0) {
            invert = true;
        }
    }
    if (getTarget().getCoordinates().isAdjacent(source.getCoordinates())) {
        if (PositionMaster.inLine(source, target)) {
            if (PositionMaster.isAbove(target, source)) {
                invert = true;
            }
            if (PositionMaster.isAbove(source, target)) {
                invert = false;
            }
        }
    }
    Costs costs = (Costs) phase.getArgs()[0];
    Map<Image, String> map = new XLinkedMap<>();
    for (Cost s : costs.getCosts()) {
        if (s.isPaidAlt()) {
            s = s.getAltCost();
        }
        Formula formula = s.getPayment().getAmountFormula();
        PARAMETER param = s.getPayment().getParamToPay();
        Image image = ImageManager.getValueIcon(param);
        if (image == null) {
            continue;
        }
        String string = "" + (-s.getPayment().getLastPaid());
        map.put(image, string);
        List<String> list = new ArrayList<>();
        list.add(string);
        getSubPhaseTooltipMap().put(image, list);
    }
    drawIconMap(map, false, true, base, invert);
    return true;
}
Also used : Costs(main.elements.costs.Costs) XLinkedMap(main.data.XLinkedMap) Cost(main.elements.costs.Cost) Formula(main.system.math.Formula) 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