use of main.content.values.parameters.PARAMETER 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.parameters.PARAMETER 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.parameters.PARAMETER 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.parameters.PARAMETER in project Eidolons by IDemiurge.
the class DualAttackMaster method checkCostsCanMerge.
private static boolean checkCostsCanMerge(DC_UnitAction main, DC_UnitAction offhand) {
Costs costsMain = main.getCosts();
costsMain = DC_CostsFactory.getCostsForAction(main);
Costs costsOffhand = offhand.getCosts();
costsOffhand = DC_CostsFactory.getCostsForAction(offhand);
for (Cost cost : costsMain.getCosts()) {
PARAMETER p = cost.getPayment().getParamToPay();
Cost cost2 = costsOffhand.getCost(p);
Integer value1 = cost.getPayment().getAmountFormula().getInt();
Integer value2 = (cost2 == null) ? 0 : cost2.getPayment().getAmountFormula().getInt();
Boolean mode = getMinMaxOrAverage((PARAMS) p);
if (!checkCost(value1, value2, mode))
return false;
}
return true;
}
use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.
the class DualAttackMaster method getDualCosts.
private static Costs getDualCosts(DC_UnitAction main, DC_UnitAction offhand) {
List<Cost> list = new ArrayList<>();
Costs costsMain = main.getCosts();
// if (costsMain == null)
costsMain = DC_CostsFactory.getCostsForAction(main);
Costs costsOffhand = offhand.getCosts();
// if (costsOffhand == null)
costsOffhand = DC_CostsFactory.getCostsForAction(offhand);
for (Cost cost : costsMain.getCosts()) {
PARAMETER p = cost.getPayment().getParamToPay();
Cost cost2 = costsOffhand.getCost(p);
Integer value1 = cost.getPayment().getAmountFormula().getInt();
Integer value2 = (cost2 == null) ? 0 : cost2.getPayment().getAmountFormula().getInt();
Boolean mode = getMinMaxOrAverage((PARAMS) p);
Integer value = MathMaster.getTotalOrMinMax(mode, value1, value2);
list.add(new CostImpl(new Payment(p, value), cost.getCostParam()));
}
Costs costsDual = new Costs(list);
Integer focReq = 25;
list.add(new CostImpl(new Payment(PARAMS.FOC_REQ, focReq)));
return costsDual;
}
Aggregations