use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.
the class BackgroundChoiceView method applyBackground.
private void applyBackground(Unit hero, ObjType bgType) {
ObjType type = hero.getType();
type.setProperty(G_PROPS.BASE_TYPE, bgType.getName());
type.setProperty(G_PROPS.BACKGROUND_TYPE, bgType.getName());
List<VALUE> backgroundParams = DC_ContentManager.getBackgroundStaticValues();
for (VALUE v : backgroundParams) {
if (v instanceof PARAMETER) {
if (v.isWriteToType()) {
hero.modifyParameter((PARAMETER) v, bgType.getIntParam((PARAMETER) v));
} else {
type.modifyParameter((PARAMETER) v, bgType.getIntParam((PARAMETER) v));
}
// type.multiplyParamByPercent((PARAMETER) v, 50, false);// TODO
// feeble
// fix!
} else if (v instanceof PROPERTY) {
type.setProperty((PROPERTY) v, bgType.getProperty((PROPERTY) v));
}
}
hero.toBase();
}
use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.
the class Loader method createObjects.
private static List<Obj> createObjects(List<String> objectNodes) {
DC_Game game = DC_Game.game;
List<Obj> objects = new ArrayList<>();
// TODO ID ORDER MUST BE PRESERVED! put in parameter?
for (String typesNode : objectNodes) {
Document node = XML_Converter.getDoc(typesNode);
DC_TYPE TYPE = DC_TYPE.getType(node.getNodeName());
for (Node subNode : XML_Converter.getNodeList(node)) {
String sub = XML_Converter.getStringFromXML(subNode);
game.setIdManager(new DC_IdManager(game));
Map<PROPERTY, String> props = getPropsFromNode(sub);
Map<PARAMETER, String> params = getParamsFromNode(sub);
ObjType type = DataManager.getType(subNode.getNodeName(), TYPE);
// preset ID?! init containers by id... including buffs; but first create them
Ref ref = new Ref(game);
Node refNode = XML_Converter.findNode(sub, Saver.OBJ_NODE);
if (refNode != null)
for (String substring : StringMaster.open(refNode.getTextContent())) {
ref.setValue(KEYS.valueOf(substring.split("=")[0].toUpperCase()), substring.split("=")[1]);
}
String ownerName = null;
DC_Player owner = game.getBattleMaster().getPlayerManager().getPlayer(// property?
ownerName);
if (owner == null) {
owner = DC_Player.NEUTRAL;
}
Coordinates c = new Coordinates(params.get(G_PARAMS.POS_X) + "-" + params.get(G_PARAMS.POS_Y));
Obj object = createObj(type, c.x, c.y, owner, game, ref);
object.getPropMap().putAll(props);
object.getParamMap().putAll(params);
object.setId(StringMaster.getInteger(props.get(G_PROPS.ID)));
objects.add(object);
init(object);
}
}
return objects;
}
use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.
the class Loader method getPropsFromNode.
private static Map<PROPERTY, String> getPropsFromNode(String sub) {
Node node = XML_Converter.findNode(sub, TypeBuilder.PROPS_NODE);
Map<PROPERTY, String> map = new XLinkedMap<>();
XML_Converter.getNodeList(node).forEach(subNode -> {
PROPERTY prop = ContentManager.getPROP(subNode.getNodeName());
String value = subNode.getTextContent();
map.put(prop, value);
});
return map;
}
use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.
the class Saver method getObjNodeXml.
private static String getObjNodeXml(DC_GameState state) {
StringBuilder builder = new StringBuilder(80000);
builder.append(XML_Converter.openXml(OBJ_NODE));
for (OBJ_TYPE TYPE : state.getObjMaps().keySet()) {
if (state.getObjMaps().get(TYPE).isEmpty())
continue;
builder.append(XML_Converter.openXml(TYPE.getName()));
for (Integer id : state.getObjMaps().get(TYPE).keySet()) {
Obj obj = state.getObjMaps().get(TYPE).get(id);
obj.setProperty(G_PROPS.ID, id + "");
builder.append(XML_Converter.openXmlFormatted(obj.getName()));
builder.append(XML_Converter.openXml(PROPS_NODE));
for (PROPERTY property : obj.getPropMap().keySet()) {
if (property.isDynamic() || !obj.getProperty(property).equals(obj.getType().getProperty(property))) {
// only write values that aren't at base
builder.append(XML_Formatter.getValueNode(obj, property));
}
}
builder.append(XML_Converter.closeXml(PROPS_NODE));
builder.append(XML_Converter.openXml(PARAMS_NODE));
for (PARAMETER parameter : obj.getParamMap().keySet()) {
if (parameter.isDynamic() || !obj.getParam(parameter).equals(obj.getType().getParam(parameter))) {
// only write values that aren't at base
builder.append(XML_Formatter.getValueNode(obj, parameter));
}
}
builder.append(XML_Converter.closeXml(PARAMS_NODE));
// REF !
builder.append(XML_Converter.closeXmlFormatted(obj.getName()));
}
builder.append(XML_Converter.closeXml(TYPE.getName()));
}
builder.append(XML_Converter.closeXml(OBJ_NODE));
return builder.toString();
}
use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.
the class TextMaster method extractTypeText.
private static void extractTypeText() {
DC_Engine.fullInit();
int i = 0;
for (OBJ_TYPE k : extractedTypes) {
List<String> value = null;
if (extractedTypeGroups.length > i) {
value = StringMaster.openContainer(extractedTypeGroups[i]);
}
extractedTypesMap.put(k, value);
i++;
}
for (PROPERTY prop : extract_props) {
for (OBJ_TYPE t : extractedTypesMap.keySet()) {
List<String> list = extractedTypesMap.get(t);
if (list == null) {
extractTypeText(t, null, prop);
} else {
for (String c : list) {
extractTypeText(t, c, prop);
}
}
}
}
}
Aggregations