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