Search in sources :

Example 61 with PARAMETER

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);
}
Also used : PARAMETER(main.content.values.parameters.PARAMETER)

Example 62 with PARAMETER

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 + ")";
}
Also used : Formula(main.system.math.Formula) PARAMETER(main.content.values.parameters.PARAMETER)

Example 63 with PARAMETER

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();
}
Also used : ObjType(main.entity.type.ObjType) PROPERTY(main.content.values.properties.PROPERTY) VALUE(main.content.VALUE) PARAMETER(main.content.values.parameters.PARAMETER)

Example 64 with PARAMETER

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;
}
Also used : DC_TYPE(main.content.DC_TYPE) PROPERTY(main.content.values.properties.PROPERTY) Node(org.w3c.dom.Node) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) DC_Game(eidolons.game.core.game.DC_Game) Document(org.w3c.dom.Document) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player) Ref(main.entity.Ref) DC_IdManager(eidolons.entity.DC_IdManager) ObjType(main.entity.type.ObjType) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) DC_BuffObj(eidolons.entity.obj.attach.DC_BuffObj) DC_FeatObj(eidolons.entity.obj.attach.DC_FeatObj) DC_JewelryObj(eidolons.entity.item.DC_JewelryObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) Obj(main.entity.obj.Obj) DC_ArmorObj(eidolons.entity.item.DC_ArmorObj) PARAMETER(main.content.values.parameters.PARAMETER)

Example 65 with PARAMETER

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();
}
Also used : OBJ_TYPE(main.content.OBJ_TYPE) Obj(main.entity.obj.Obj) PROPERTY(main.content.values.properties.PROPERTY) PARAMETER(main.content.values.parameters.PARAMETER)

Aggregations

PARAMETER (main.content.values.parameters.PARAMETER)136 PROPERTY (main.content.values.properties.PROPERTY)22 ObjType (main.entity.type.ObjType)13 ArrayList (java.util.ArrayList)12 Formula (main.system.math.Formula)12 Ref (main.entity.Ref)9 VALUE (main.content.VALUE)7 Obj (main.entity.obj.Obj)7 PARAMS (eidolons.content.PARAMS)6 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)5 Cost (main.elements.costs.Cost)5 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)4 G_Panel (main.swing.generic.components.G_Panel)4 Node (org.w3c.dom.Node)4 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)3 HashMap (java.util.HashMap)3 DAMAGE_TYPE (main.content.enums.GenericEnums.DAMAGE_TYPE)3 Costs (main.elements.costs.Costs)3 Entity (main.entity.Entity)3 GraphicComponent (main.swing.generic.components.misc.GraphicComponent)3