use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.
the class BattleStatManager method modifyUnitModStat.
private void modifyUnitModStat(boolean hostile, String stat, Unit sourceObj, int mod) {
PARAMETER p = ContentManager.getPARAM(stat);
Map<PARAMETER, Integer> map = hostile ? stats.getUnitStats(sourceObj).getEnemyModMap() : stats.getUnitStats(sourceObj).getAllyModMap();
MapMaster.addToIntegerMap(map, p, mod);
}
use of main.content.values.parameters.PARAMETER in project Eidolons by IDemiurge.
the class HeroManager method getCost.
public static String getCost(Entity type, Entity hero, OBJ_TYPE TYPE, PROPERTY PROP, boolean buying) {
if (TYPE.getParam() == null) {
return "";
}
PARAMETER costParam = ContentManager.getCostParam(TYPE.getParam());
PARAMETER discountParam = DC_ContentManager.getCostReductionParam(costParam, PROP);
Integer value = type.getIntParam(costParam);
Integer mod = hero.getIntParam(discountParam);
Formula costFormula = new Formula("" + value);
if (discountParam != null) {
costFormula.applyFactor((!buying ? "" : "-") + StringMaster.getValueRef(KEYS.SOURCE, discountParam));
}
if (!buying) {
costFormula.applyFactor(-DC_Formulas.getSellingPriceReduction());
}
discountParam = DC_ContentManager.getSpecialCostReductionParam(costParam, PROP);
if (discountParam == null) {
return "" + costFormula;
}
mod = hero.getIntParam(discountParam);
if (mod == 100) {
value = 0;
} else {
costFormula.applyFactor((!buying ? "" : "-") + StringMaster.getValueRef(KEYS.SOURCE, discountParam));
}
return "(" + costFormula + ")";
}
use of main.content.values.parameters.PARAMETER 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.parameters.PARAMETER 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.parameters.PARAMETER 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();
}
Aggregations