use of main.system.util.Refactor in project Eidolons by IDemiurge.
the class LocationBuilder method constructBlock.
@Refactor
public static // TODO the way it's done, we can't have Structures in non-Location dungeons!!!
MapBlock constructBlock(Node node, int id, MapZone zone, DungeonPlan map, Dungeon dungeon) {
List<Coordinates> coordinates = new ArrayList<>();
Map<Coordinates, ? extends Obj> objectMap = new HashMap<>();
MapBlock b = new MapBlock(id, null, zone, map, coordinates);
// TODO b-data, coordinates, objects
for (Node subNode : XML_Converter.getNodeList(node)) {
if (StringMaster.compareByChar(subNode.getNodeName(), COORDINATES_NODE)) {
coordinates = CoordinatesMaster.getCoordinatesFromString(subNode.getTextContent());
} else if (StringMaster.compareByChar(subNode.getNodeName(), OBJ_NODE)) {
// TODO BETTER IN TYPES?
objectMap = DC_ObjInitializer.initMapBlockObjects(dungeon, b, subNode.getTextContent());
// TODO encounters?
} else {
// BLOCK TYPE
if (StringMaster.compareByChar(subNode.getNodeName(), BLOCK_TYPE_NODE)) {
BLOCK_TYPE type = new EnumMaster<BLOCK_TYPE>().retrieveEnumConst(BLOCK_TYPE.class, subNode.getTextContent());
b.setType(type);
}
if (StringMaster.compareByChar(subNode.getNodeName(), ROOM_TYPE_NODE)) {
ROOM_TYPE type = new EnumMaster<ROOM_TYPE>().retrieveEnumConst(ROOM_TYPE.class, subNode.getTextContent());
b.setRoomType(type);
}
}
}
b.setCoordinates(coordinates);
if (objectMap == null) {
return b;
}
b.getMap().putAll(objectMap);
b.getObjects().addAll(objectMap.values());
return b;
}
use of main.system.util.Refactor in project Eidolons by IDemiurge.
the class Spawner method spawn.
@Refactor
public void spawn() {
// initFacing(units, player, mode);
for (Object player1 : getBattleMaster().getPlayerManager().getPlayers()) {
DC_Player player = (DC_Player) player1;
if (player.isNeutral()) {
continue;
}
UnitData data = player.getUnitData();
if (data == null)
data = generateData("", player, null);
spawn(data, player, getSpawnMode(player, true));
}
spawnDone();
// initEmblem
}
use of main.system.util.Refactor 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