Beispiel #1
0
        private static List <string> GetSavedChannels(string playerAndServer)
        {
            string playerDir = ConfigUtil.GetArchiveDir() + playerAndServer;
            var    file      = playerDir + @"\channels.txt";

            return(ConfigUtil.ReadList(file));
        }
Beispiel #2
0
        internal static List <string> GetPlayers(string playerAndServer)
        {
            string playerDir = ConfigUtil.GetArchiveDir() + playerAndServer;
            var    file      = playerDir + @"\players.txt";

            return(ConfigUtil.ReadList(file));
        }
Beispiel #3
0
        private static List <string> GetSelectedChannels(string playerAndServer)
        {
            List <string> result    = null; // throw null to check case where file has never existed vs empty content
            var           playerDir = ConfigUtil.GetArchiveDir() + playerAndServer;
            string        fileName  = playerDir + @"\" + SELECTED_CHANNELS_FILE;

            if (File.Exists(fileName))
            {
                result = ConfigUtil.ReadList(fileName);
            }
            return(result);
        }
Beispiel #4
0
        private PlayerManager()
        {
            AddMultiCase(new string[] { "you", "your", "yourself" }, SecondPerson);
            AddMultiCase(new string[] { "himself", "herself", "itself" }, ThirdPerson);

            // populate ClassNames from SpellClass enum and resource table
            foreach (var item in Enum.GetValues(typeof(SpellClass)))
            {
                ClassNames[(SpellClass)item] = Properties.Resources.ResourceManager.GetString(Enum.GetName(typeof(SpellClass), item), CultureInfo.CurrentCulture);
            }

            // Populate generated pets
            ConfigUtil.ReadList(@"data\petnames.txt").ForEach(line => GameGeneratedPets[line.TrimEnd()] = 1);
        }
Beispiel #5
0
        private DataManager()
        {
            DictionaryListHelper <string, SpellData> helper = new DictionaryListHelper <string, SpellData>();
            var spellList = new List <SpellData>();

            ConfigUtil.ReadList(@"data\spells.txt").ForEach(line =>
            {
                try
                {
                    var spellData = TextFormatUtils.ParseCustomSpellData(line);
                    if (spellData != null)
                    {
                        spellList.Add(spellData);
                        SpellsNameDB[spellData.Name] = spellData;

                        if (!SpellsAbbrvDB.ContainsKey(spellData.NameAbbrv))
                        {
                            SpellsAbbrvDB[spellData.NameAbbrv] = spellData;
                        }
                        else if (string.Compare(SpellsAbbrvDB[spellData.NameAbbrv].Name, spellData.Name, true, CultureInfo.CurrentCulture) < 0)
                        {
                            // try to keep the newest version
                            SpellsAbbrvDB[spellData.NameAbbrv] = spellData;
                        }

                        if (spellData.LandsOnOther.StartsWith("'s ", StringComparison.Ordinal))
                        {
                            spellData.LandsOnOther = spellData.LandsOnOther.Substring(3);
                            helper.AddToList(PosessiveLandsOnOthers, spellData.LandsOnOther, spellData);
                        }
                        else if (spellData.LandsOnOther.Length > 1)
                        {
                            spellData.LandsOnOther = spellData.LandsOnOther.Substring(1);
                            helper.AddToList(NonPosessiveLandsOnOthers, spellData.LandsOnOther, spellData);
                        }

                        if (spellData.LandsOnYou.Length > 0) // just do stuff in common
                        {
                            helper.AddToList(LandsOnYou, spellData.LandsOnYou, spellData);
                        }
                    }
                }
                catch (OverflowException ex)
                {
                    LOG.Error("Error reading spell data", ex);
                }
            });

            // sort by duration for the timeline to pick better options
            foreach (var key in NonPosessiveLandsOnOthers.Keys)
            {
                NonPosessiveLandsOnOthers[key].Sort((a, b) =>
                {
                    int result = b.Duration.CompareTo(a.Duration);
                    return(result != 0 ? result : b.ID.CompareTo(a.ID));
                });
            }

            foreach (var key in PosessiveLandsOnOthers.Keys)
            {
                PosessiveLandsOnOthers[key].Sort((a, b) =>
                {
                    int result = b.Duration.CompareTo(a.Duration);
                    return(result != 0 ? result : b.ID.CompareTo(a.ID));
                });
            }

            foreach (var key in LandsOnYou.Keys)
            {
                LandsOnYou[key].Sort((a, b) =>
                {
                    int result = b.Duration.CompareTo(a.Duration);
                    return(result != 0 ? result : b.ID.CompareTo(a.ID));
                });
            }

            Dictionary <string, byte> keepOut = new Dictionary <string, byte>();
            var classEnums = Enum.GetValues(typeof(SpellClass)).Cast <SpellClass>().ToList();

            spellList.ForEach(spell =>
            {
                // exact match meaning class-only spell that are of certain target types
                var tgt = (SpellTarget)spell.Target;
                if ((tgt == SpellTarget.SELF || (spell.Level <= 250 && (tgt == SpellTarget.SINGLETARGET || tgt == SpellTarget.LOS))) && classEnums.Contains((SpellClass)spell.ClassMask))
                {
                    // these need to be unique and keep track if a conflict is found
                    if (SpellsToClass.ContainsKey(spell.Name))
                    {
                        SpellsToClass.Remove(spell.Name);
                        keepOut[spell.Name] = 1;
                    }
                    else if (!keepOut.ContainsKey(spell.Name))
                    {
                        SpellsToClass[spell.Name] = (SpellClass)spell.ClassMask;
                    }
                }
            });

            // load NPCs
            ConfigUtil.ReadList(@"data\npcs.txt").ForEach(line => AllNpcs[line.Trim()] = 1);

            PlayerManager.Instance.EventsNewTakenPetOrPlayerAction += (sender, name) => RemoveFight(name);
            PlayerManager.Instance.EventsNewVerifiedPlayer         += (sender, name) => RemoveFight(name);
            PlayerManager.Instance.EventsNewVerifiedPet            += (sender, name) => RemoveFight(name);
        }
Beispiel #6
0
        private DataManager()
        {
            DictionaryListHelper <string, SpellData> helper = new DictionaryListHelper <string, SpellData>();
            var spellList = new List <SpellData>();

            // build ranks cache
            Enumerable.Range(1, 9).ToList().ForEach(r => RanksCache[r.ToString(CultureInfo.CurrentCulture)] = "");
            Enumerable.Range(1, 200).ToList().ForEach(r => RanksCache[TextFormatUtils.IntToRoman(r)]        = "");
            RanksCache["Third"]  = "Root";
            RanksCache["Fifth"]  = "Root";
            RanksCache["Octave"] = "Root";

            ConfigUtil.ReadList(@"data\spells.txt").ForEach(line =>
            {
                try
                {
                    var spellData = ParseCustomSpellData(line);
                    if (spellData != null)
                    {
                        spellList.Add(spellData);
                        SpellsNameDB[spellData.Name] = spellData;

                        if (!SpellsAbbrvDB.ContainsKey(spellData.NameAbbrv))
                        {
                            SpellsAbbrvDB[spellData.NameAbbrv] = spellData;
                        }
                        else if (string.Compare(SpellsAbbrvDB[spellData.NameAbbrv].Name, spellData.Name, true, CultureInfo.CurrentCulture) < 0)
                        {
                            // try to keep the newest version
                            SpellsAbbrvDB[spellData.NameAbbrv] = spellData;
                        }

                        if (spellData.LandsOnOther.StartsWith("'s ", StringComparison.Ordinal))
                        {
                            spellData.LandsOnOther = spellData.LandsOnOther.Substring(3);
                            helper.AddToList(PosessiveLandsOnOthers, spellData.LandsOnOther, spellData);
                        }
                        else if (!string.IsNullOrEmpty(spellData.LandsOnOther))
                        {
                            spellData.LandsOnOther = spellData.LandsOnOther.Substring(1);
                            helper.AddToList(NonPosessiveLandsOnOthers, spellData.LandsOnOther, spellData);
                        }

                        if (!string.IsNullOrEmpty(spellData.LandsOnYou)) // just do stuff in common
                        {
                            helper.AddToList(LandsOnYou, spellData.LandsOnYou, spellData);
                        }
                    }
                }
                catch (OverflowException ex)
                {
                    LOG.Error("Error reading spell data", ex);
                }
            });

            // sort by duration for the timeline to pick better options
            NonPosessiveLandsOnOthers.Values.ToList().ForEach(value => value.Sort((a, b) => DurationCompare(a, b)));
            PosessiveLandsOnOthers.Values.ToList().ForEach(value => value.Sort((a, b) => DurationCompare(a, b)));
            LandsOnYou.Values.ToList().ForEach(value => value.Sort((a, b) => DurationCompare(a, b)));

            var keepOut    = new Dictionary <string, byte>();
            var classEnums = Enum.GetValues(typeof(SpellClass)).Cast <SpellClass>().ToList();

            spellList.ForEach(spell =>
            {
                // exact match meaning class-only spell that are of certain target types
                var tgt = (SpellTarget)spell.Target;
                if ((tgt == SpellTarget.SELF || (spell.Level <= 250 && (tgt == SpellTarget.SINGLETARGET || tgt == SpellTarget.LOS))) && classEnums.Contains((SpellClass)spell.ClassMask))
                {
                    // these need to be unique and keep track if a conflict is found
                    if (SpellsToClass.ContainsKey(spell.Name))
                    {
                        SpellsToClass.Remove(spell.Name);
                        keepOut[spell.Name] = 1;
                    }
                    else if (!keepOut.ContainsKey(spell.Name))
                    {
                        SpellsToClass[spell.Name] = (SpellClass)spell.ClassMask;
                    }
                }
            });

            // load NPCs
            ConfigUtil.ReadList(@"data\npcs.txt").ForEach(line => AllNpcs[line.Trim()] = 1);

            // Load Adps
            AdpsKeys.ForEach(adpsKey => AdpsActive[adpsKey] = new Dictionary <string, uint>());
            AdpsKeys.ForEach(adpsKey => AdpsValues[adpsKey] = new Dictionary <string, uint>());

            string key = null;

            foreach (var line in ConfigUtil.ReadList(@"data\adpsMeter.txt"))
            {
                if (!string.IsNullOrEmpty(line) && line.Trim() is string trimmed && trimmed.Length > 0)
                {
                    if (trimmed[0] != '#' && !string.IsNullOrEmpty(key))
                    {
                        if (trimmed.Split('|') is string[] multiple && multiple.Length > 0)
                        {
                            foreach (var spellLine in multiple)
                            {
                                if (spellLine.Split('=') is string[] list && list.Length == 2 && uint.TryParse(list[1], out uint rate))
                                {
                                    if (SpellsAbbrvDB.TryGetValue(list[0], out SpellData spellData) || SpellsNameDB.TryGetValue(list[0], out spellData))
                                    {
                                        AdpsValues[key][spellData.NameAbbrv] = rate;

                                        if (!AdpsWearOff.TryGetValue(spellData.WearOff, out HashSet <SpellData> wearOffList))
                                        {
                                            AdpsWearOff[spellData.WearOff] = new HashSet <SpellData>();
                                        }

                                        AdpsWearOff[spellData.WearOff].Add(spellData);

                                        if (!AdpsLandsOn.TryGetValue(spellData.LandsOnYou, out HashSet <SpellData> landsOnList))
                                        {
                                            AdpsLandsOn[spellData.LandsOnYou] = new HashSet <SpellData>();
                                        }

                                        AdpsLandsOn[spellData.LandsOnYou].Add(spellData);
                                    }
                                }
                            }
                        }
                    }
                    else if (AdpsKeys.Contains(trimmed))
                    {
                        key = trimmed;
                    }
                }
            }

            PlayerManager.Instance.EventsNewTakenPetOrPlayerAction += (sender, name) => RemoveFight(name);
            PlayerManager.Instance.EventsNewVerifiedPlayer         += (sender, name) => RemoveFight(name);
            PlayerManager.Instance.EventsNewVerifiedPet            += (sender, name) => RemoveFight(name);

            int DurationCompare(SpellData a, SpellData b)
            {
                if (b.Duration.CompareTo(a.Duration) is int result && result == 0)
                {
                    if (int.TryParse(a.ID, out int aInt) && int.TryParse(b.ID, out int bInt) && aInt != bInt)
                    {
                        result = aInt > bInt ? -1 : 1;
                    }
                }

                return(result);
            }
        }