invertika_game.Game.ItemManager.readEffectNode C# (CSharp) Method

readEffectNode() private method

private readEffectNode ( ) : void
return void
        void readEffectNode()
        {
            //std::pair<ItemTriggerType, ItemTriggerType> triggerTypes;
            //{
            //    const std::string triggerName = XML::getProperty(
            //                effectNode, "trigger", std::string());
            //    const std::string dispellTrigger = XML::getProperty(
            //                effectNode, "dispell", std::string());
            //    // label . { trigger (apply), trigger (cancel (default)) }
            //    // The latter can be overridden.
            //    static std::map<const std::string,
            //                    std::pair<ItemTriggerType, ItemTriggerType> >
            //                    triggerTable;
            //    if (triggerTable.empty())
            //    {
            //        /*
            //         * The following is a table of all triggers for item
            //         *     effects.
            //         * The first element defines the trigger used for this
            //         *     trigger, and the second defines the default
            //         *     trigger to use for dispelling.
            //         */
            //        triggerTable["in-inventory"].first         = ITT_IN_INVY;
            //        triggerTable["in-inventory"].second        = ITT_LEAVE_INVY;
            //        triggerTable["activation"].first        = ITT_ACTIVATE;
            //        triggerTable["activation"].second       = ITT_NULL;
            //        triggerTable["equip"].first             = ITT_EQUIP;
            //        triggerTable["equip"].second            = ITT_UNEQUIP;
            //        triggerTable["leave-inventory"].first   = ITT_LEAVE_INVY;
            //        triggerTable["leave-inventory"].second  = ITT_NULL;
            //        triggerTable["unequip"].first           = ITT_UNEQUIP;
            //        triggerTable["unequip"].second          = ITT_NULL;
            //        triggerTable["equip-change"].first      = ITT_EQUIPCHG;
            //        triggerTable["equip-change"].second     = ITT_NULL;
            //        triggerTable["null"].first              = ITT_NULL;
            //        triggerTable["null"].second             = ITT_NULL;
            //    }
            //    std::map<const std::string, std::pair<ItemTriggerType,
            //                                ItemTriggerType> >::iterator
            //             it = triggerTable.find(triggerName);

            //    if (it == triggerTable.end()) {
            //        LOG_WARN("Item Manager: Unable to find effect trigger type \""
            //                 << triggerName << "\", skipping!");
            //        return;
            //    }
            //    triggerTypes = it.second;
            //    if (!dispellTrigger.empty())
            //    {
            //        if ((it = triggerTable.find(dispellTrigger)) == triggerTable.end())
            //            LOG_WARN("Item Manager: Unable to find dispell effect "
            //                     "trigger type \"" << dispellTrigger << "\"!");
            //        else
            //            triggerTypes.second = it.second.first;
            //    }
            //}

            //for_each_xml_child_node(subNode, effectNode)
            //{
            //    if (xmlStrEqual(subNode.name, BAD_CAST "modifier"))
            //    {
            //        std::string tag = XML::getProperty(subNode, "attribute", std::string());
            //        if (tag.empty())
            //        {
            //            LOG_WARN("Item Manager: Warning, modifier found "
            //                     "but no attribute specified!");
            //            continue;
            //        }
            //        unsigned int duration = XML::getProperty(subNode,
            //                                                 "duration",
            //                                                 0);
            //        ModifierLocation location = attributeManager.getLocation(tag);
            //        double value = XML::getFloatProperty(subNode, "value", 0.0);
            //        item.addEffect(new ItemEffectAttrMod(location.attributeId,
            //                                              location.layer,
            //                                              value,
            //                                              item.getDatabaseID(),
            //                                              duration),
            //                        triggerTypes.first, triggerTypes.second);
            //    }
            //    else if (xmlStrEqual(subNode.name, BAD_CAST "autoattack"))
            //    {
            //        // TODO - URGENT
            //    }
            //    // Having a dispell for the next three is nonsensical.
            //    else if (xmlStrEqual(subNode.name, BAD_CAST "cooldown"))
            //    {
            //        LOG_WARN("Item Manager: Cooldown property not implemented yet!");
            //        // TODO: Also needs unique items before this action will work
            //    }
            //    else if (xmlStrEqual(subNode.name, BAD_CAST "g-cooldown"))
            //    {
            //        LOG_WARN("Item Manager: G-Cooldown property not implemented yet!");
            //        // TODO
            //    }
            //    else if (xmlStrEqual(subNode.name, BAD_CAST "consumes"))
            //    {
            //        item.addEffect(new ItemEffectConsumes(), triggerTypes.first);
            //    }
            //    else if (xmlStrEqual(subNode.name, BAD_CAST "script"))
            //    {
            //        std::string activateFunctionName = XML::getProperty(subNode,
            //                                                            "function",
            //                                                            std::string());
            //        if (activateFunctionName.empty())
            //        {
            //            LOG_WARN("Item Manager: Empty function definition "
            //                     "for script effect, skipping!");
            //            continue;
            //        }

            //        std::string src = XML::getProperty(subNode, "src", std::string());
            //        if (src.empty())
            //        {
            //            LOG_WARN("Item Manager: Empty src definition for script effect,"
            //                     " skipping!");
            //            continue;
            //        }
            //        std::stringstream filename;
            //        filename << "scripts/items/" << src;
            //        if (!ResourceManager::exists(filename.str()))
            //        {
            //            LOG_WARN("Could not find script file \"" << filename.str()
            //                     << "\" for item #" << item.mDatabaseID);
            //            continue;
            //        }

            //        LOG_INFO("Loading item script: " << filename.str());

            //        std::string engineName =
            //                Script::determineEngineByFilename(filename.str());
            //        Script *script = Script::create(engineName);
            //        if (!script.loadFile(filename.str()))
            //        {
            //            // Delete the script as it's invalid.
            //            delete script;

            //            LOG_WARN("Could not load script file \"" << filename.str()
            //                      << "\" for item #" << item.mDatabaseID);
            //            continue;
            //        }

            //        for_each_xml_child_node(scriptSubNode, subNode)
            //        {
            //            // TODO: Load variables from variable subnodes
            //        }
            //        std::string dispellFunctionName = XML::getProperty(subNode,
            //                                                         "dispell-function",
            //                                                         std::string());

            //        item.addEffect(new ItemEffectScript(item.mDatabaseID, script,
            //                                             activateFunctionName,
            //                                             dispellFunctionName),
            //                                             triggerTypes.first,
            //                                             triggerTypes.second);
            //    }
            //}
        }