Exemplo n.º 1
0
        static int getTalentPointsFromTree(SavedVariablesDictionary talent_tree, string spec, TalentDataAttribute talent)
        {
            int points = 0;

            if (talent_tree.ContainsKey(spec))
            {
                SavedVariablesDictionary spec_tree = talent_tree[spec] as SavedVariablesDictionary;

                if (spec_tree.ContainsKey(talent.Name))
                {
                    SavedVariablesDictionary talent_info = spec_tree[talent.Name] as SavedVariablesDictionary;

                    string rank_info = talent_info["Rank"] as string;

                    int    split_pos  = rank_info.IndexOf(':');
                    string points_str = rank_info.Remove(split_pos);

                    points = (int)Int32.Parse(points_str);
                }
                else
                {
                    Debug.WriteLine("Talent Not Found: " + talent);
                }
            }
            else
            {
                // we're most likely dealing with non-English data, try to determine by position in tree
                foreach (SavedVariablesDictionary tree in talent_tree.Values)
                {
                    if ((long)tree["Order"] == talent.Tree + 1)
                    {
                        string loc = talent.Row + ":" + talent.Column;
                        foreach (object t in tree.Values)
                        {
                            SavedVariablesDictionary td = t as SavedVariablesDictionary;
                            if (td != null)
                            {
                                if ((string)td["Location"] == loc)
                                {
                                    string rank_info = td["Rank"] as string;

                                    int    split_pos  = rank_info.IndexOf(':');
                                    string points_str = rank_info.Remove(split_pos);

                                    points = (int)Int32.Parse(points_str);
                                    return(points);
                                }
                            }
                        }
                    }
                }
                Debug.WriteLine("Talent Tree Not Found: " + spec);
            }

            return(points);
        }
Exemplo n.º 2
0
        static int getEnchantBySlot(SavedVariablesDictionary characterInfo, string sSlot)
        {
            SavedVariablesDictionary equipment = (SavedVariablesDictionary)characterInfo["Equipment"];

            if (equipment.ContainsKey(sSlot))
            {
                SavedVariablesDictionary item = equipment[sSlot] as SavedVariablesDictionary;
                return(getEnchant(item));
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 3
0
        static string getGearStringBySlot(SavedVariablesDictionary characterInfo, string sSlot)
        {
            SavedVariablesDictionary equipment = (SavedVariablesDictionary)characterInfo["Equipment"];

            if (equipment.ContainsKey(sSlot))
            {
                SavedVariablesDictionary item = equipment[sSlot] as SavedVariablesDictionary;
                return(getGearString(item));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        static string getGearString(SavedVariablesDictionary item, bool replaceAsterisks)
        {
            string sItemString = item["Item"] as string;

            char[]   acSplitCharacters = { ':' };
            string[] asItemElements    = sItemString.Split(acSplitCharacters);

            if (item.ContainsKey("Gem"))
            {
                SavedVariablesDictionary gems = item["Gem"] as SavedVariablesDictionary;

                string sItemSlotString = "";
                for (long lGemSlot = 1; lGemSlot <= 3; lGemSlot++)
                {
                    sItemSlotString += ".";

                    if (gems.ContainsKey(lGemSlot))
                    {
                        string sGemItemString = (gems[lGemSlot] as SavedVariablesDictionary)["Item"] as string;
                        sItemSlotString += sGemItemString.Split(acSplitCharacters)[0];
                    }
                    else
                    {
                        sItemSlotString += "0";
                    }
                }

                if (replaceAsterisks && sItemSlotString == ".0.0.0")
                {
                    return(asItemElements[0] + ".*.*.*");
                }
                else
                {
                    return(asItemElements[0] + sItemSlotString);
                }
            }
            else
            {
                if (replaceAsterisks)
                {
                    return(asItemElements[0] + ".*.*.*");
                }
                else
                {
                    return(asItemElements[0] + ".0.0.0");
                }
            }
        }
Exemplo n.º 5
0
        /*
         * This function is used to help populate the optimizer list.
         * Rather than add every item in every bag slot, this filter is used
         * to try to limit the items only to equippable ones.
         * Note however that the current implentation is a bit of a hack
         * that involves searching item Tooltips.
         * Returns true if the item is equippable.
         */
        static bool isEquippable(SavedVariablesDictionary itemInfo)
        {
            if (itemInfo != null && itemInfo.ContainsKey("Tooltip"))
            {
                string sTooltip = itemInfo["Tooltip"] as string;

                foreach (string sNeedle in s_asEquippableTooltipKeywords)
                {
                    if (sTooltip.IndexOf(sNeedle) != -1)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        static string getGearStringBySlot(SavedVariablesDictionary characterInfo, string sSlot, bool replaceAsterisks)
        {
            SavedVariablesDictionary equipment = (SavedVariablesDictionary)characterInfo["Equipment"];

            if (equipment.ContainsKey(sSlot))
            {
                SavedVariablesDictionary item = equipment[sSlot] as SavedVariablesDictionary;
                string enchant = getEnchant(item).ToString();
                if (enchant == "0" && replaceAsterisks)
                {
                    enchant = "*";
                }
                return(getGearString(item, replaceAsterisks) + "." + enchant);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 7
0
        static void addPossessionsForOptimization(List <string> asOptimizableItems,
                                                  SavedVariablesDictionary characterInfo)
        {
            string[] asSources = { "Inventory", "Bank" };

            foreach (string sSource in asSources)
            {
                if (characterInfo.ContainsKey(sSource))
                {
                    SavedVariablesDictionary bags = characterInfo[sSource] as SavedVariablesDictionary;

                    foreach (object oBag in bags.Values)
                    {
                        SavedVariablesDictionary bag      = oBag as SavedVariablesDictionary;
                        SavedVariablesDictionary contents = bag["Contents"] as SavedVariablesDictionary;

                        foreach (object oItem in contents.Values)
                        {
                            SavedVariablesDictionary item = oItem as SavedVariablesDictionary;

                            if (isEquippable(item))
                            {
                                string enchant = getEnchant(item).ToString();
                                if (enchant == "0")
                                {
                                    enchant = "*";
                                }
                                string   item2             = getGearString(item, true) + "." + enchant;
                                char[]   acSplitCharacters = { '.' };
                                string[] asItemElements    = item2.Split(acSplitCharacters);
                                if (item2.Substring(asItemElements[0].Length) == ".*.*.*.*")
                                {
                                    item2 = asItemElements[0];
                                }
                                asOptimizableItems.Add(item2);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        public CharacterProfilerData(string sFileName)
        {
            SavedVariablesDictionary savedVariables = SavedVariablesParser.parse(sFileName);

            // TODO: check the version

            if (!savedVariables.ContainsKey("myProfile"))
            {
                throw new InvalidDataException("Expected myProfile variable in file.");
            }

            SavedVariablesDictionary realms = (SavedVariablesDictionary)savedVariables["myProfile"];

            foreach (string sRealm in realms.Keys)
            {
                bool bHaveCharacters = false;

                CharacterProfilerRealm realm = new CharacterProfilerRealm(sRealm);

                SavedVariablesDictionary characterContainer = (SavedVariablesDictionary)realms[sRealm];
                SavedVariablesDictionary characters         = (SavedVariablesDictionary)characterContainer["Character"];

                foreach (string sCharacter in characters.Keys)
                {
                    try {
                        SavedVariablesDictionary   characterInfo = (SavedVariablesDictionary)characters[sCharacter];
                        CharacterProfilerCharacter character     = new CharacterProfilerCharacter(sCharacter, sRealm, characterInfo);
                        realm.Characters.Add(character);
                        bHaveCharacters = true;
                    } catch (Exception error) {
                        m_errors.Add(new CharacterProfilerFailedImport(sRealm, sCharacter, error.ToString()));
                    }
                }

                if (bHaveCharacters)
                {
                    m_realms.Add(realm);
                }
            }
        }