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;
}
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;
}
Aggregations