Search in sources :

Example 1 with PROPERTY

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

Example 2 with PROPERTY

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

Example 3 with PROPERTY

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

Example 4 with PROPERTY

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;
}
Also used : AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Ref(main.entity.Ref) RandomWizard(main.system.auxiliary.RandomWizard) PROPERTY(main.content.values.properties.PROPERTY) Obj(main.entity.obj.Obj) DC_Effect(eidolons.ability.effects.DC_Effect) AddBuffEffect(eidolons.ability.effects.attachment.AddBuffEffect) Effect(main.ability.effects.Effect) Effects(main.ability.effects.Effects) PARAMETER(main.content.values.parameters.PARAMETER)

Example 5 with PROPERTY

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

Aggregations

PROPERTY (main.content.values.properties.PROPERTY)57 PARAMETER (main.content.values.parameters.PARAMETER)23 ObjType (main.entity.type.ObjType)17 OBJ_TYPE (main.content.OBJ_TYPE)6 ArrayList (java.util.ArrayList)5 VALUE (main.content.VALUE)5 Ref (main.entity.Ref)5 DC_TYPE (main.content.DC_TYPE)4 Node (org.w3c.dom.Node)4 DC_SpellObj (eidolons.entity.active.DC_SpellObj)3 Unit (eidolons.entity.obj.unit.Unit)3 XLinkedMap (main.data.XLinkedMap)3 Obj (main.entity.obj.Obj)3 EnumMaster (main.system.auxiliary.EnumMaster)3 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)2 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)2 File (java.io.File)2 List (java.util.List)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 MOD_PROP_TYPE (main.ability.effects.Effect.MOD_PROP_TYPE)2