use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.
the class DC_HeroItemObj method apply.
@Override
public void apply() {
super.apply();
applyDurability();
for (PROPERTY prop : props) {
initProp(prop);
}
for (PARAMETER param : params) {
initParam(param);
}
// hero.modifyParameter(PARAMS.CARRYING_WEIGHT, getWeight());
getHero().setDirty(true);
}
use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.
the class XML_Reader method createCustomTypeList.
public static List<ObjType> createCustomTypeList(String xml, OBJ_TYPE TYPE, Game game, boolean overwrite, boolean incompleteTypes, boolean wrap) {
List<ObjType> types = new ArrayList<>();
if (wrap) {
xml = XML_Converter.wrap("wrapped", xml);
}
Document doc = XML_Converter.getDoc(xml);
List<Node> nodes = XML_Converter.getNodeList(XML_Converter.getNodeList(doc).get(0));
for (Node node : nodes) {
// typeName = node.getNodeName();
ObjType type = TypeBuilder.buildType(node, TYPE.toString());
game.initType(type);
if (incompleteTypes) {
ObjType parent = DataManager.getType(type.getProperty(G_PROPS.PARENT_TYPE), type.getOBJ_TYPE_ENUM());
if (parent != null) {
type.setType(parent);
for (PROPERTY prop : parent.getPropMap().keySet()) {
if (type.getProperty(prop).isEmpty()) {
type.setProperty(prop, parent.getProperty(prop));
}
}
for (PARAMETER param : parent.getParamMap().keySet()) {
if (type.getParam(param).isEmpty()) {
type.setParam(param, parent.getParam(param));
}
}
}
}
if (overwrite) {
DataManager.overwriteType(type);
}
types.add(type);
}
return types;
}
use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.
the class XML_Writer method getTypeXML_Builder.
public static StringBuilder getTypeXML_Builder(Entity type, StringBuilder builder, Entity parent) {
if (type.getName().isEmpty()) {
return builder;
}
builder.append(openXML(type.getName()));
builder.append("<params>");
for (PARAMETER param : type.getParamMap().keySet()) {
if (param == null) {
continue;
}
String value = XML_Formatter.formatXmlTextContent(type.getParamMap().get(param), param);
if (parent != null) {
if (parent.getParam(param).equals(value)) {
continue;
}
}
if (!checkWriteValue(param, value, type.getOBJ_TYPE_ENUM())) {
continue;
}
appendLeafNode(builder, StringMaster.capitalizeFirstLetter(param.getName()), value);
}
builder.append("</params>");
builder.append("<props>");
for (PROPERTY prop : type.getPropMap().keySet()) {
String value = XML_Formatter.formatXmlTextContent(type.getPropMap().get(prop), prop);
if (parent != null) {
// don't duplicate
if (parent.getProperty(prop).equals(value)) {
continue;
}
}
if (prop == null) {
LogMaster.log(1, "null key! ; value = " + type.getPropMap().get(prop));
}
appendLeafNode(builder, StringMaster.capitalizeFirstLetter(prop.getName()), value);
}
builder.append("</props>");
return builder.append(closeXML(type.getName()));
}
use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.
the class HeroObjectModifyingEffect method applyThis.
/**
* Modstring format: valueName(value);valueName2(value2);... Use [mod],
* [set], [remove] to change the default ADD function of modstring
*/
public boolean applyThis() {
if (ref.getTargetObj().isDead() || ref.getSourceObj().isDead()) {
removeEffects();
return false;
}
if (game.isSimulation()) {
if (!checkApplyInSimulation()) {
return true;
}
}
// what if the group has changed? perhaps there should be a map...
if (prop) {
if (propMap == null) {
propMap = new RandomWizard<PROPERTY>().constructStringWeightMap(modString, PROPERTY.class);
} else {
LogMaster.log(1, "prop map " + propMap.toString());
}
} else if (// TODO support PROPERTY?
map == null) {
map = new RandomWizard<PARAMETER>().constructStringWeightMap(modString, PARAMETER.class);
} else {
LogMaster.log(0, "map " + map.toString());
}
List<? extends Obj> list = getObjectsToModify();
LogMaster.log(0, "list " + list.toString());
LogMaster.log(0, "effects " + effects.toString());
for (Obj obj : list) {
if (obj == null) {
continue;
}
if (obj.isDead()) {
// TODO clean up for owner is dead!
continue;
}
Effect effect = effects.get(obj);
if (effect != null) {
// if (isPermanent() && isApplied())
// continue;
effect.applyThis();
applied = true;
continue;
}
Ref REF = ref.getCopy();
REF.setTarget(obj.getId());
// map = new MapMaster<PARAMETER, String>().constructVarMap(
// modString, PARAMETER.class);
Effects modEffects = new Effects();
if (map != null) {
EffectFinder.initParamModEffects(modEffects, map, ref);
} else if (propMap != null) {
EffectFinder.initPropModEffects(modEffects, propMap, ref);
}
applied = true;
for (Effect e : modEffects.getEffects()) {
e.resetOriginalFormula();
e.appendFormulaByMod(getFormula().toString());
}
if (buff) {
AddBuffEffect buffEffect = new AddBuffEffect(buffName, modEffects);
// TODO LAYER?
buffEffect.setForcedLayer(getModEffectLayer());
modEffects.setForcedLayer(getModEffectLayer());
if (isPermanent()) {
buffEffect.setDuration(ContentManager.INFINITE_VALUE);
}
if (!game.isSimulation()) {
effects.put(obj, buffEffect);
}
buffEffect.apply(REF);
} else {
if (!game.isSimulation()) {
effects.put(obj, modEffects);
}
modEffects.apply(REF);
}
}
return true;
}
use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.
the class HqShop method initItems.
private void initItems() {
items = new ArrayList<>();
if (isPreset()) {
items = DataManager.toTypeList(StringMaster.openContainer(getProperty(PROPS.SHOP_ITEMS)), C_OBJ_TYPE.ITEMS);
return;
}
List<ObjType> templates = DataManager.toTypeList(StringMaster.openContainer(getProperty(PROPS.SHOP_ITEM_TEMPLATES)), C_OBJ_TYPE.ITEMS);
items = getItemsFromTemplates(templates);
if (getShopType() == null)
return;
// addStandardItems(); then randomize
PROPERTY prop = getShopType().getFilterProp();
int i = 0;
String[] item_groups = getShopType().getItem_groups();
for (String group : item_groups) {
List<ObjType> pool;
if (prop == null) {
pool = DataManager.toTypeList(DataManager.getTypesSubGroupNames(C_OBJ_TYPE.ITEMS, group), C_OBJ_TYPE.ITEMS);
} else {
pool = ItemGenerator.getBaseTypes(C_OBJ_TYPE.ITEMS);
FilterMaster.filter(pool, new PropCondition(prop, group));
}
pool = constructPool(pool);
pool.addAll(getSpecialItems(group));
i++;
if (!isRandomized()) {
for (ObjType item : pool) {
buyItem(item, 0);
}
// buyAll();
continue;
}
//
goldToSpend = (100 - spareGold - i * 5) / item_groups.length;
// some params from Shop ObjType?
Loop.startLoop(ShopMaster.getMaxItemsPerGroup(this));
while (!Loop.loopEnded() && !pool.isEmpty()) {
int randomListIndex = RandomWizard.getRandomListIndex(pool);
ObjType t = pool.get(randomListIndex);
if (t == null) {
continue;
}
if (!buyItem(t)) {
// second loop based on cheapest items?
break;
}
}
}
}
Aggregations