Search in sources :

Example 11 with Condition

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

the class ModeEffect method addRemoveTrigger.

private void addRemoveTrigger() {
    REMOVE_EVENT = mode.getRemoveEvent();
    if (REMOVE_EVENT == null) {
        return;
    }
    Condition c = null;
    if (REMOVE_EVENT == STANDARD_EVENT_TYPE.UNIT_TURN_STARTED) {
        c = new RefCondition(KEYS.EVENT_SOURCE, KEYS.MATCH);
    // ++ remove disable actions?!
    }
    addBuffEffect.addEffect(new DelayedEffect(REMOVE_EVENT, new RemoveBuffEffect(addBuffEffect.getBuffTypeName()), c));
// .apply(ref);
}
Also used : Condition(main.elements.conditions.Condition) RefCondition(main.elements.conditions.RefCondition) RemoveBuffEffect(eidolons.ability.effects.oneshot.buff.RemoveBuffEffect) RefCondition(main.elements.conditions.RefCondition)

Example 12 with Condition

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

the class DC_StateManager method checkCellBuffs.

private void checkCellBuffs() {
    for (BattleFieldObject unit : getGame().getBfObjects()) {
        if (unit.isDead()) {
            continue;
        }
        Obj cell = game.getCellByCoordinate(unit.getCoordinates());
        if (cell == null) {
            continue;
        }
        if (cell.getBuffs() == null) {
            continue;
        }
        for (BuffObj buff : game.getCellByCoordinate(unit.getCoordinates()).getBuffs()) {
            if (unit.hasBuff(buff.getName())) {
                continue;
            }
            if (buff.isAppliedThrough()) {
                Condition retainCondition = new PositionCondition(KEYS.SOURCE.toString(), cell);
                getGame().getManager().copyBuff(buff, unit, retainCondition);
            }
        }
    }
}
Also used : PositionCondition(main.elements.conditions.standard.PositionCondition) Condition(main.elements.conditions.Condition) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) BuffObj(main.entity.obj.BuffObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) BuffObj(main.entity.obj.BuffObj) PositionCondition(main.elements.conditions.standard.PositionCondition)

Example 13 with Condition

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

the class ActivesConstructor method addTargetingMods.

public static void addTargetingMods(Targeting targeting, DC_ActiveObj obj) {
    Conditions c = new Conditions();
    String property = obj.getProperty(PROPS.TARGETING_MODIFIERS);
    if (obj.getActionGroup() == ActionEnums.ACTION_TYPE_GROUPS.MOVE) {
        // SPELL_TAGS.TELEPORT
        if (!obj.checkProperty(G_PROPS.ACTION_TAGS, ActionEnums.ACTION_TAGS.FLYING.toString())) {
            if (!obj.checkProperty(PROPS.TARGETING_MODIFIERS, AbilityEnums.TARGETING_MODIFIERS.CLEAR_SHOT.toString())) {
                property += AbilityEnums.TARGETING_MODIFIERS.CLEAR_SHOT.toString();
            }
            if (!obj.checkProperty(PROPS.TARGETING_MODIFIERS, AbilityEnums.TARGETING_MODIFIERS.SPACE.toString())) {
                property += AbilityEnums.TARGETING_MODIFIERS.SPACE.toString();
            }
        }
    }
    if (StringMaster.isEmpty(property)) {
        return;
    }
    for (String mod : StringMaster.open(property)) {
        Condition targetingModConditions;
        TARGETING_MODIFIERS MOD = new EnumMaster<TARGETING_MODIFIERS>().retrieveEnumConst(TARGETING_MODIFIERS.class, mod);
        if (MOD == null) {
            targetingModConditions = ConditionMaster.toConditions(mod);
        } else {
            targetingModConditions = DC_ConditionMaster.getTargetingModConditions(MOD);
        }
        if (targetingModConditions != null) {
            if (!c.contains(targetingModConditions)) // if (ConditionMaster.contains(c,
            // targetingModConditions.getClass())) //you sure?
            {
                c.add(targetingModConditions);
            }
        }
    }
    if (targeting instanceof TemplateSelectiveTargeting) {
        TemplateSelectiveTargeting tst = (TemplateSelectiveTargeting) targeting;
        if (tst.getTemplate() == SELECTIVE_TARGETING_TEMPLATES.GRAVE_CELL) {
            // TODO
            if (tst.getConditions() != null) {
                try {
                    ((GraveCondition) tst.getConditions().get(0)).getConditions().add(c);
                } catch (Exception e) {
                    main.system.auxiliary.log.LogMaster.log(1, tst.getConditions().get(0) + " in " + obj);
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            }
        }
    }
    if (!c.isEmpty()) {
        targeting.getFilter().addCondition(c);
    }
    targeting.setModsAdded(true);
}
Also used : Condition(main.elements.conditions.Condition) GraveCondition(eidolons.ability.conditions.special.GraveCondition) TARGETING_MODIFIERS(main.content.enums.entity.AbilityEnums.TARGETING_MODIFIERS) TemplateSelectiveTargeting(eidolons.ability.targeting.TemplateSelectiveTargeting) Conditions(main.elements.conditions.Conditions)

Example 14 with Condition

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

the class ScriptParser method parseScript.

public static <T> ScriptTrigger parseScript(String script, DC_Game game, ScriptExecutor<T> executor, Class<T> funcClass) {
    // TODO
    script = ScriptMaster.getScriptByName(script);
    // non-trigger scripts?
    String originalText = script;
    String processedPart = StringMaster.getFirstItem(script, ScriptSyntax.PART_SEPARATOR);
    STANDARD_EVENT_TYPE event_type = parseEvent(processedPart);
    script = StringMaster.cropFirstSegment(script, ScriptSyntax.PART_SEPARATOR);
    Condition condition = null;
    condition = getDefaultCondition(event_type, VariableManager.getVars(processedPart));
    if (condition != null) {
        condition.setXml(XML_Converter.wrap("ScriptedCondition", XML_Converter.wrap("STANDARD_EVENT_TYPE", event_type.toString()) + XML_Converter.wrap("STRING", VariableManager.getVars(processedPart))));
    } else {
        String conditionPart = StringMaster.getFirstItem(script, ScriptSyntax.PART_SEPARATOR);
        condition = parseConditions(conditionPart);
        condition.setXml(conditionPart);
    }
    boolean isRemove = true;
    // if (contains("cyclic"))remove = false;
    Ability abilities = null;
    // TODO Global
    Ref ref = new Ref(game);
    script = StringMaster.getLastPart(script, ScriptSyntax.PART_SEPARATOR);
    String funcPart = VariableManager.removeVarPart(script);
    @Refactor T // TODO this won't work in generic way!!!!
    func = new EnumMaster<T>().retrieveEnumConst(funcClass, funcPart);
    if (func != null) {
        // TODO for multiple scripts, need another SEPARATOR!
        String separator = executor.getSeparator(func);
        List<String> strings = StringMaster.openContainer(VariableManager.getVars(script), separator);
        String[] args = strings.toArray(new String[strings.size()]);
        abilities = new AbilityImpl() {

            @Override
            public boolean activatedOn(Ref ref) {
                executor.execute(func, ref, args);
                // reset after? not like normal action certainly...
                return true;
            }
        };
    } else {
        abilities = AbilityConstructor.getAbilities(script, ref);
        if (abilities.getEffects().getEffects().isEmpty()) {
            main.system.auxiliary.log.LogMaster.log(1, "SCRIPT NOT FOUND: " + funcPart);
            return null;
        }
    }
    abilities.setRef(ref);
    ScriptTrigger trigger = new ScriptTrigger(originalText, event_type, condition, abilities);
    trigger.setRemoveAfterTriggers(isRemove);
    return trigger;
}
Also used : Condition(main.elements.conditions.Condition) Ability(main.ability.Ability) AbilityImpl(main.ability.AbilityImpl) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE) Refactor(main.system.util.Refactor) Ref(main.entity.Ref)

Example 15 with Condition

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

the class SpeechBuilder method processText.

protected String processText(String text, Speech speech) {
    try {
        Condition reqs = DialogueSyntax.getConditions(text);
        speech.setConditions(reqs);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    try {
        Abilities abils = DialogueSyntax.getAbilities(text);
        speech.setAbilities(abils);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    try {
        String script = DialogueSyntax.getScript(text);
        speech.setScript(script);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    return DialogueSyntax.getRawText(text);
}
Also used : Condition(main.elements.conditions.Condition) Abilities(main.ability.Abilities)

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