Search in sources :

Example 6 with STANDARD_EVENT_TYPE

use of main.game.logic.event.Event.STANDARD_EVENT_TYPE in project Eidolons by IDemiurge.

the class ScriptParser method parseEvent.

public static STANDARD_EVENT_TYPE parseEvent(String eventPart) {
    STANDARD_EVENT_TYPE eventType = getEventByShortcut(eventPart);
    if (eventType != null)
        return eventType;
    eventType = new EnumMaster<STANDARD_EVENT_TYPE>().retrieveEnumConst(STANDARD_EVENT_TYPE.class, eventPart);
    if (eventType != null)
        return eventType;
    return STANDARD_EVENT_TYPE.GAME_STARTED;
}
Also used : EnumMaster(main.system.auxiliary.EnumMaster) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE)

Example 7 with STANDARD_EVENT_TYPE

use of main.game.logic.event.Event.STANDARD_EVENT_TYPE 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)

Aggregations

STANDARD_EVENT_TYPE (main.game.logic.event.Event.STANDARD_EVENT_TYPE)7 Conditions (main.elements.conditions.Conditions)3 Ref (main.entity.Ref)3 Unit (eidolons.entity.obj.unit.Unit)2 Abilities (main.ability.Abilities)2 Condition (main.elements.conditions.Condition)2 RefCondition (main.elements.conditions.RefCondition)2 AddTriggerEffect (eidolons.ability.effects.attachment.AddTriggerEffect)1 DealDamageEffect (eidolons.ability.effects.oneshot.DealDamageEffect)1 RemoveBuffEffect (eidolons.ability.effects.oneshot.buff.RemoveBuffEffect)1 AlteringEffect (eidolons.ability.effects.oneshot.misc.AlteringEffect)1 EndGameEffect (eidolons.ability.effects.special.meta.EndGameEffect)1 Dungeon (eidolons.game.battlecraft.logic.dungeon.universal.Dungeon)1 Ability (main.ability.Ability)1 AbilityImpl (main.ability.AbilityImpl)1 ActiveAbility (main.ability.ActiveAbility)1 Effects (main.ability.effects.Effects)1 CustomTargetEffect (main.ability.effects.continuous.CustomTargetEffect)1 GroupCondition (main.elements.conditions.standard.GroupCondition)1 NonTriggeredEventCondition (main.elements.conditions.standard.NonTriggeredEventCondition)1