예제 #1
0
        public static void LoadSettings()
        {
            m_config = new XmlConfig(ConfigPath);
            m_config.AddAssembly(typeof(Settings).Assembly);

            if (!File.Exists(ConfigPath))
            {
                m_config.Create();
            }
            else
            {
                m_config.Load();
            }
        }
예제 #2
0
        public virtual void LoadConfig()
        {
            if (!UseConfig)
            {
                return;
            }

            var configPath = GetConfigPath();

            Config = new XmlConfig(configPath);
            Config.AddAssembly(GetType().Assembly);

            if (File.Exists(configPath))
            {
                Config.Load();
            }
            else
            {
                Config.Create();
            }
        }
예제 #3
0
        public static void Main()
        {
            Console.WriteLine("Load {0}...", ConfigFile);
            m_config = new XmlConfig(ConfigFile);
            m_config.AddAssembly(Assembly.GetExecutingAssembly());

            if (!File.Exists(ConfigFile))
            {
                m_config.Create();
            }
            else
            {
                m_config.Load();
            }

            Console.WriteLine("Initializing Database...");
            m_databaseAccessor = new DatabaseAccessor(DatabaseConfiguration);
            m_databaseAccessor.RegisterMappingAssembly(Assembly.GetExecutingAssembly());
            m_databaseAccessor.Initialize();

            Console.WriteLine("Opening Database...");
            m_databaseAccessor.OpenConnection();
            DataManager.DefaultDatabase = m_databaseAccessor.Database;

            Console.WriteLine("Loading texts...");
            TextManager.Instance.Initialize();
            TextManager.Instance.SetDefaultLanguage(SecondaryLanguage);

            Console.WriteLine("Loading effects...");
            EffectManager.Instance.Initialize();

            Console.WriteLine("Loading spells...");
            SpellManager.Instance.Initialize();


            while (true)
            {
                Console.Write(">");
                var pattern = Console.ReadLine();
                try
                {
                    if (pattern.StartsWith("target:"))
                    {
                        var target = pattern.Remove(0, "target:".Length);

                        if (!target.Any())
                        {
                            var targets = SpellManager.Instance.GetSpellTemplates()
                                          .SelectMany(x => SpellManager.Instance.GetSpellLevel((int)x.SpellLevelsIds[0]).Effects.SelectMany(y => y.TargetMask.Split(','))).Select(z => z[0]).Distinct();

                            foreach (var mask in targets)
                            {
                                Console.WriteLine(mask);
                            }
                        }

                        foreach (
                            var spell in
                            SpellManager.Instance.GetSpellTemplates()
                            .Where(
                                x =>
                                SpellManager.Instance.GetSpellLevel((int)x.SpellLevelsIds[0])
                                .Effects.Any(y => y.TargetMask.Contains(target))))
                        {
                            Console.WriteLine("Spell:{0} ({1})", spell.Name, spell.Id);
                        }
                    }

                    if (pattern.StartsWith("trigger:"))
                    {
                        var trigger = pattern.Remove(0, "trigger:".Length);

                        foreach (
                            var spell in
                            SpellManager.Instance.GetSpellTemplates()
                            .Where(
                                x =>
                                SpellManager.Instance.GetSpellLevel((int)x.SpellLevelsIds[0])
                                .Effects.Any(y => y.Triggers.Split('|').Any(z => z == trigger))))
                        {
                            Console.WriteLine("Spell:{0} ({1})", spell.Name, spell.Id);
                        }
                    }

                    if (pattern.StartsWith("zone:"))
                    {
                        var zone = pattern.Remove(0, "zone:".Length);

                        foreach (
                            var spell in
                            SpellManager.Instance.GetSpellTemplates()
                            .Where(
                                x =>
                                SpellManager.Instance.GetSpellLevel((int)x.SpellLevelsIds[0])
                                .Effects.Any(y => y.ZoneShape.ToString() == zone)))
                        {
                            Console.WriteLine("Spell:{0} ({1})", spell.Name, spell.Id);
                        }
                    }

                    if (pattern.StartsWith("delay"))
                    {
                        foreach (
                            var spell in
                            SpellManager.Instance.GetSpellTemplates()
                            .Where(
                                x =>
                                SpellManager.Instance.GetSpellLevel((int)x.SpellLevelsIds[0])
                                .Effects.Any(y => y.Delay != 0)))
                        {
                            Console.WriteLine("Spell:{0} ({1})", spell.Name, spell.Id);
                        }
                    }

                    if (pattern.StartsWith("priority"))
                    {
                        foreach (
                            var spell in
                            SpellManager.Instance.GetSpellTemplates()
                            .Where(
                                x =>
                                SpellManager.Instance.GetSpellLevel((int)x.SpellLevelsIds[0])
                                .Effects.Any(y => y.Priority != 0)))
                        {
                            Console.WriteLine("Spell:{0} ({1})", spell.Name, spell.Id);
                        }
                    }
                    if (pattern.StartsWith("group"))
                    {
                        foreach (
                            var spell in
                            SpellManager.Instance.GetSpellTemplates()
                            .Where(
                                x =>
                                SpellManager.Instance.GetSpellLevel((int)x.SpellLevelsIds[0])
                                .Effects.Any(y => y.Group != 0)))
                        {
                            Console.WriteLine("Spell:{0} ({1})", spell.Name, spell.Id);
                        }
                    }
                    if (pattern.StartsWith("@"))
                    {
                        pattern = pattern.Remove(0, 1);

                        var spells = SpellManager.Instance.GetSpellLevels()
                                     .Where(x => x.Effects.Any(y => y.Id == int.Parse(pattern)));

                        foreach (var spell in spells.Distinct())
                        {
                            Console.WriteLine("Spell:{0} ({1})", spell.Spell.Name, spell.SpellId);
                        }
                    }
                    if (pattern.StartsWith("casted:"))
                    {
                        var spellId = int.Parse(pattern.Remove(0, "casted:".Length));

                        var spells = SpellManager.Instance.GetSpellLevels()
                                     .Where(x => x.Effects.Any(y => (y.EffectId == EffectsEnum.Effect_TriggerBuff || y.EffectId == EffectsEnum.Effect_TriggerBuff_793 ||
                                                                     y.EffectId == EffectsEnum.Effect_CastSpell_1160 || y.EffectId == EffectsEnum.Effect_CastSpell_1017) && y.DiceNum == spellId));

                        foreach (var spell in spells.Distinct())
                        {
                            Console.WriteLine("Spell:{0} ({1})", spell.Spell.Name, spell.SpellId);
                        }
                    }
                    if (pattern.StartsWith("state:"))
                    {
                        var stateId = int.Parse(pattern.Remove(0, "state:".Length));

                        var spells = SpellManager.Instance.GetSpellLevels()
                                     .Where(x => x.Effects.Any(y => y.EffectId == EffectsEnum.Effect_AddState && y.Value == stateId));

                        foreach (var spell in spells.Distinct())
                        {
                            Console.WriteLine("Spell:{0} ({1})", spell.Spell.Name, spell.SpellId);
                        }
                    }

                    var critical = pattern.EndsWith("!");
                    if (critical)
                    {
                        pattern = pattern.Remove(pattern.Length - 1, 1);
                    }

                    foreach (SpellTemplate spell in FindSpells(pattern))
                    {
                        if (spell == null)
                        {
                            Console.WriteLine("Spell not found");
                        }
                        else
                        {
                            ExploreSpell(spell, FindPatternSpellLevel(pattern), critical);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }