Search in sources :

Example 1 with Condition

use of main.elements.conditions.Condition in project Eidolons by IDemiurge.

the class TurnSequenceConstructor method getTurnSequence.

public List<Action> getTurnSequence(Action action) {
    Conditions conditions = (action.getTargeting().getFilter().getConditions());
    FacingCondition condition = null;
    FACING_SINGLE template = null;
    DC_Obj target = action.getTarget();
    Unit source = (Unit) action.getRef().getSourceObj();
    for (Condition c : conditions) {
        if (c instanceof FacingCondition) {
            condition = (FacingCondition) c;
            break;
        }
        List<Object> list = ClassMaster.getInstances(c, FacingCondition.class);
        if (!list.isEmpty()) {
            List<Action> front_sequence = getTurnSequence(FACING_SINGLE.IN_FRONT, source, target.getCoordinates());
            List<Action> side_sequence = null;
            if (action.getSource().hasBroadReach() || action.getActive().checkPassive(UnitEnums.STANDARD_PASSIVES.BROAD_REACH)) // front_sequence.remove(front_sequence.size() - 1);
            {
                side_sequence = getTurnSequence(FACING_SINGLE.TO_THE_SIDE, source, target.getCoordinates());
            }
            List<Action> hind_sequence = null;
            if (action.getSource().hasHindReach() || action.getActive().checkPassive(UnitEnums.STANDARD_PASSIVES.HIND_REACH)) {
                hind_sequence = getTurnSequence(FACING_SINGLE.BEHIND, source, target.getCoordinates());
            }
            return new ListMaster<Action>().getSmallest(front_sequence, hind_sequence, side_sequence);
        }
    }
    // }
    if (condition == null) {
        return new ArrayList<>();
    }
    if (ArrayMaster.isNotEmpty(condition.getTemplate())) {
        template = condition.getTemplate()[0];
    }
    return getTurnSequence(template, source, target.getCoordinates());
}
Also used : FacingCondition(eidolons.ability.conditions.FacingCondition) Condition(main.elements.conditions.Condition) DC_Obj(eidolons.entity.obj.DC_Obj) Action(eidolons.game.battlecraft.ai.elements.actions.Action) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ArrayList(java.util.ArrayList) FacingCondition(eidolons.ability.conditions.FacingCondition) Unit(eidolons.entity.obj.unit.Unit) Conditions(main.elements.conditions.Conditions) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Example 2 with Condition

use of main.elements.conditions.Condition in project Eidolons by IDemiurge.

the class Filter method getObjects.

public Set<T> getObjects() {
    if (isDebug()) {
        ArrayList<Obj> list = new ArrayList<>(getFilteredObjectPool());
        Set<Obj> set = new HashSet<>();
        loop: for (Obj obj : list) {
            for (Condition c : getConditions()) {
                if (!match(c, obj.getId())) {
                    if (conditionDebugCache != null)
                        conditionDebugCache.put(obj.getId(), c);
                    continue loop;
                }
            }
            set.add(obj);
        }
        return (Set<T>) new HashSet<>(set);
    }
    Collection<Obj> pool = getFilteredObjectPool();
    Set<T> filteredSet = (Set<T>) new HashSet<>(pool);
    ArrayList<Obj> list = new ArrayList<>(pool);
    for (Condition c : getConditions()) {
        for (Obj obj : list) {
            if (!match(c, obj.getId())) {
                filteredSet.remove(obj);
            }
        }
    }
    return filteredSet;
// TODO sort out; use cache
}
Also used : FilteringCondition(main.elements.conditions.FilteringCondition) Condition(main.elements.conditions.Condition) Obj(main.entity.obj.Obj)

Example 3 with Condition

use of main.elements.conditions.Condition in project Eidolons by IDemiurge.

the class ModeEffect method addDispelOnHitTrigger.

private void addDispelOnHitTrigger() {
    Effects effects = new Effects(new RemoveBuffEffect(addBuffEffect.getBuffTypeName()));
    if (!mode.equals(STD_MODES.ALERT)) {
        effects.add(InterruptRule.getEffect());
    } else {
        effects.add(AlertRule.getInterruptEffect());
    }
    if (mode.equals(STD_MODES.CHANNELING)) {
        effects.add(new EffectImpl() {

            @Override
            public boolean applyThis() {
                ChannelingRule.channelingInterrupted((Unit) getRef().getSourceObj());
                return true;
            }
        });
    }
    // TODO
    STANDARD_EVENT_TYPE event_type = STANDARD_EVENT_TYPE.UNIT_IS_DEALT_TOUGHNESS_DAMAGE;
    Condition conditions = (mode.equals(STD_MODES.ALERT)) ? InterruptRule.getConditionsAlert() : InterruptRule.getConditions();
    addBuffEffect.addEffect(new DelayedEffect(event_type, effects, conditions));
}
Also used : Condition(main.elements.conditions.Condition) RefCondition(main.elements.conditions.RefCondition) RemoveBuffEffect(eidolons.ability.effects.oneshot.buff.RemoveBuffEffect) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE) Unit(eidolons.entity.obj.unit.Unit)

Example 4 with Condition

use of main.elements.conditions.Condition in project Eidolons by IDemiurge.

the class PartyHelper method getPrincipleConditions.

public static Conditions getPrincipleConditions(Party party) {
    Conditions principlesConditions = new Conditions();
    for (Unit m : party.getMembers()) {
        String principles = m.getProperty(G_PROPS.PRINCIPLES);
        Condition principlesCondition = new PrinciplesCondition(principles, "{MATCH_" + G_PROPS.PRINCIPLES + "}", true);
        principlesConditions.add(principlesCondition);
    }
    return principlesConditions;
}
Also used : PrinciplesCondition(main.elements.conditions.PrinciplesCondition) Condition(main.elements.conditions.Condition) Unit(eidolons.entity.obj.unit.Unit) PrinciplesCondition(main.elements.conditions.PrinciplesCondition) Conditions(main.elements.conditions.Conditions)

Example 5 with Condition

use of main.elements.conditions.Condition in project Eidolons by IDemiurge.

the class AddBuffEffect method initRetainConditions.

private void initRetainConditions() {
    if (ref.getActive() == null) {
        return;
    }
    String prop = ref.getActive().getProperty(PROPS.RETAIN_CONDITIONS, false);
    for (String s : StringMaster.open(prop)) {
        RETAIN_CONDITIONS template = new EnumMaster<RETAIN_CONDITIONS>().retrieveEnumConst(RETAIN_CONDITIONS.class, s);
        Condition condition;
        if (template != null) {
            condition = DC_ConditionMaster.getRetainConditionsFromTemplate(template, ref);
        } else {
            condition = ConditionMaster.toConditions(s);
        }
        if (condition != null) {
            getRetainConditions().add(condition);
        }
    }
}
Also used : RETAIN_CONDITIONS(main.content.CONTENT_CONSTS.RETAIN_CONDITIONS) Condition(main.elements.conditions.Condition)

Aggregations

Condition (main.elements.conditions.Condition)17 Conditions (main.elements.conditions.Conditions)7 Ref (main.entity.Ref)4 RemoveBuffEffect (eidolons.ability.effects.oneshot.buff.RemoveBuffEffect)3 Unit (eidolons.entity.obj.unit.Unit)3 RefCondition (main.elements.conditions.RefCondition)3 FacingCondition (eidolons.ability.conditions.FacingCondition)2 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)2 DC_Obj (eidolons.entity.obj.DC_Obj)2 ArrayList (java.util.ArrayList)2 NumericCondition (main.elements.conditions.NumericCondition)2 Obj (main.entity.obj.Obj)2 STANDARD_EVENT_TYPE (main.game.logic.event.Event.STANDARD_EVENT_TYPE)2 FileChooser (main.swing.generic.components.editors.FileChooser)2 Formula (main.system.math.Formula)2 VisibilityCondition (eidolons.ability.conditions.VisibilityCondition)1 GraveCondition (eidolons.ability.conditions.special.GraveCondition)1 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1