Search in sources :

Example 16 with PROPERTY

use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.

the class AE_Manager method saveTreeIntoXML.

public static void saveTreeIntoXML(ObjType type) {
    if (type == null) {
        cacheMap.remove(type.getName());
    }
    PROPERTY XML_PROP;
    if (!ArcaneVault.isMacroMode()) {
        XML_PROP = G_PROPS.ABILITIES;
    } else {
        XML_PROP = MACRO_PROPS.DIALOGUE_TREE;
    }
    saveTreeIntoXML(type.getOBJ_TYPE_ENUM(), XML_PROP, type);
}
Also used : PROPERTY(main.content.values.properties.PROPERTY)

Example 17 with PROPERTY

use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.

the class TypeBuilder method setProps.

private static void setProps(DataModel type, NodeList childNodes) {
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node child = childNodes.item(i);
        if (child.getNodeName().equals(XML_Converter.TEXT_NODE)) {
            continue;
        }
        if ((type) instanceof XmlHoldingType) {
            if (StringMaster.getWellFormattedString(child.getNodeName()).equals(((XmlHoldingType) (type)).getXmlProperty().getName())) {
                child = XML_Converter.getAbilitiesDoc(child);
                type.setProperty(ContentManager.getPROP(child.getNodeName()), XML_Converter.getStringFromXML(child, false));
                ((XmlDocHolder) type).setDoc(child);
                continue;
            }
        }
        PROPERTY prop = ContentManager.getPROP(child.getNodeName());
        if (prop == null) {
            LogMaster.log(1, "no such prop: " + child.getNodeName());
            prop = ContentManager.getPROP(child.getNodeName());
            continue;
        }
        type.setProperty(prop, getTextFromXml(child));
    }
}
Also used : PROPERTY(main.content.values.properties.PROPERTY) Node(org.w3c.dom.Node) XmlHoldingType(main.entity.type.XmlHoldingType) XmlDocHolder(main.data.ability.construct.XmlDocHolder)

Example 18 with PROPERTY

use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.

the class TypeBuilder method getAlteredValuesXml.

public static String getAlteredValuesXml(DataModel entity, ObjType type) {
    StringBuilder xmlBuilder = new StringBuilder();
    xmlBuilder.append(XML_Converter.openXml(PROPS_NODE));
    for (PROPERTY sub : entity.getPropMap().keySet()) {
        if (sub.isDynamic() || !entity.getProperty(sub).equalsIgnoreCase(type.getProperty(sub)))
            xmlBuilder.append(XML_Formatter.getValueNode(entity, (sub)));
    }
    xmlBuilder.append(XML_Converter.closeXml(PROPS_NODE));
    xmlBuilder.append(XML_Converter.openXml(PARAMS_NODE));
    for (PARAMETER sub : entity.getParamMap().keySet()) {
        if (sub.isDynamic() || !entity.getParam(sub).equals(type.getParam(sub)))
            xmlBuilder.append(XML_Formatter.getValueNode(entity, (sub)));
    }
    xmlBuilder.append(XML_Converter.closeXml(PARAMS_NODE));
    return xmlBuilder.toString();
}
Also used : PROPERTY(main.content.values.properties.PROPERTY) PARAMETER(main.content.values.parameters.PARAMETER)

Example 19 with PROPERTY

use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.

the class Shop method initItems.

private void initItems() {
    if (!getProperty(MACRO_PROPS.SHOP_ITEMS).isEmpty()) {
        DataManager.toTypeList(StringMaster.openContainer(getProperty(MACRO_PROPS.SHOP_ITEMS)), C_OBJ_TYPE.ITEMS);
    }
    if (getIntParam(PARAMS.GOLD) == 0) {
        setParam(PARAMS.GOLD, ShopMaster.getBaseGold(this));
    }
    if (getIntParam(PARAMS.GOLD_MOD) == 0) {
        setParam(PARAMS.GOLD_MOD, ShopMaster.getBaseGoldCostMod(this), true);
    }
    if (getIntParam(MACRO_PARAMS.SHOP_INCOME) == 0) {
        setParam(MACRO_PARAMS.SHOP_INCOME, ShopMaster.getBaseGoldIncome(this), true);
    }
    items = new ArrayList<>();
    // addStandardItems(); then randomize
    PROPERTY prop = getShopType().getFilterProp();
    int i = 0;
    String[] item_groups = getShopType().getItem_groups();
    // Up to 4 item groups!
    if (item_groups.length > MAX_ITEM_GROUPS) {
        List<String> list = new ArrayList<>(Arrays.asList(item_groups));
        item_groups = new String[MAX_ITEM_GROUPS];
        int j = 0;
        while (j < MAX_ITEM_GROUPS) {
            String e = list.get(RandomWizard.getRandomListIndex(list));
            list.remove(e);
            item_groups[j] = e;
            j++;
        }
    }
    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++;
        // 
        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) ArrayList(java.util.ArrayList) PropCondition(main.elements.conditions.PropCondition)

Example 20 with PROPERTY

use of main.content.values.properties.PROPERTY in project Eidolons by IDemiurge.

the class AV_Tree method build.

private DefaultMutableTreeNode build(List<String> typesDoc, String group) {
    DefaultMutableTreeNode result = new DefaultMutableTreeNode(group);
    List<String> subGroups = new ArrayList<>();
    // if (workspace!=null) workspace.getGrouping() ;
    if (!StringMaster.isEmpty(group)) {
        try {
            Set<String> groups = XML_Reader.getTreeSubGroupMap().get(group);
            if (groups == null) {
                groups = XML_Reader.getTreeSubGroupMap(!XML_Reader.isMacro()).get(group);
            }
            subGroups = new ArrayList<>(groups);
            Class<?> ENUM = EnumMaster.getEnumClass(type.getSubGroupingKey().getName());
            if (ENUM != null) {
                Collections.sort(subGroups, new EnumMaster<>().getEnumSorter(ENUM));
            }
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    } else if (workspace != null) {
        subGroups = workspace.getSubgroups();
        if (subGroups == null) // TODO custom *grouping* -> enum class + property!
        {
            if (workspace.isSearch()) {
                subGroups = ListMaster.toStringList(DC_TYPE.values());
            } else {
                subGroups = ListMaster.toStringList(MetaEnums.WORKSPACE_GROUP.values());
                subGroups.add("");
            }
        }
    // subGroups = workspace.getSubgroups();
    // subGroups = workspace.getSubgroups();
    }
    // TODO filter generic groups
    if (subGroups.size() <= 1) {
        return buildSimple(typesDoc, group);
    }
    for (String subGroup : subGroups) {
        DefaultMutableTreeNode subNode = new DefaultMutableTreeNode(subGroup);
        List<String> upgrades = new ArrayList<>();
        List<String> list;
        if (workspace == null) {
            // Set<String> c = XML_Reader.getTreeSubGroupedTypeMap(XML_Reader.isMacro()).get(
            // subGroup);
            // if (!ListMaster.isNotEmpty(c)) {
            // c = XML_Reader.getTreeSubGroupedTypeMap(!XML_Reader.isMacro()).get(subGroup);
            // }
            // list = new ArrayList<>(c);
            // list.removeIf(t-> t==null );
            list = StringMaster.toNameList(main.system.entity.FilterMaster.getFilteredTypeList(type, type.getSubGroupingKey(), subGroup));
            try {
                Collections.sort(list, getComparator());
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        } else {
            if (workspace.isSearch()) {
                list = DataManager.toStringList(new Filter<ObjType>().filter(workspace.getTypeList(), G_PROPS.TYPE, subGroup));
                try {
                    Collections.sort(list, new EnumMaster<>().getEnumSorter(DC_TYPE.class));
                } catch (Exception e) {
                    try {
                        Collections.sort(list, new EnumMaster<>().getEnumSorter(EnumMaster.getEnumClass(type.getGroupingKey().getName())));
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            } else {
                PROPERTY filterValue = G_PROPS.WORKSPACE_GROUP;
                if (workspace.getSubgroupingProp() != null) {
                    filterValue = workspace.getSubgroupingProp();
                }
                list = DataManager.toStringList(new Filter<ObjType>().filter(workspace.getTypeList(), filterValue, subGroup));
                try {
                    Collections.sort(list, new EnumMaster<>().getEnumSorter(WORKSPACE_GROUP.class));
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            }
        }
        for (String typeName : list) {
            if (!typesDoc.contains(typeName)) {
                continue;
            }
            addNode(subNode, typeName, upgrades);
        }
        if (!subNode.isLeaf()) {
            result.add(subNode);
        }
        // TODO is it ok?
        DefaultMutableTreeNode subNode2 = subNode;
        if (isFullNodeStructureOn()) {
            // ???
            for (String typeName : upgrades) {
                subNode.add(new DefaultMutableTreeNode(typeName));
            }
        } else {
            // add upgrade nodes - works only for 3 levels
            while (true) {
                List<String> upgrades2 = new ArrayList<>(upgrades);
                for (String typeName : upgrades2) {
                    // Node!
                    if (addUpgradeNode(subNode2, typeName)) {
                        upgrades.remove(typeName);
                    }
                }
                if (upgrades.isEmpty()) {
                    parent = null;
                    i = 0;
                    break;
                }
                /*
                     * basically, it seems that root type count limits depth
					 * the preCheck
					 *
					 *
					 */
                if (parent == null) {
                    if (subNode2 == null) {
                        parent = subNode2;
                    } else {
                        parent = subNode;
                    }
                }
                subNode2 = getNextNode();
                if (subNode2 == null) {
                    parent = null;
                    i = 0;
                    LogMaster.log(1, upgrades + " remain, parent=" + parent + i);
                    for (String typeName : upgrades) {
                        subNode.add(new DefaultMutableTreeNode(typeName));
                    }
                    break;
                }
            // tr
            }
        }
    }
    // return (DefaultMutableTreeNode) result.getFirstChild();
    return result;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DC_TYPE(main.content.DC_TYPE) PROPERTY(main.content.values.properties.PROPERTY) WORKSPACE_GROUP(main.content.enums.system.MetaEnums.WORKSPACE_GROUP) EnumMaster(main.system.auxiliary.EnumMaster) ObjType(main.entity.type.ObjType)

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