Exemple #1
0
        // For Cloning
        public Spell(Spell spell)
        {
            Name      = spell.Name;
            ClassType = spell.ClassType;
            ClassSpec = spell.ClassSpec;
            SpellIds.AddRange(spell.SpellIds);
            Levels.AddRange(spell.Levels);
            Talent = spell.Talent;
            Icon   = spell.Icon;

            Cooldowns.AddRange(spell.Cooldowns);
            Durations.AddRange(spell.Durations);

            IsPvp = spell.IsPvp;
            Range = spell.Range;

            Categories = spell.Categories.ToHashSet();
            Effects    = spell.Effects.ToList();

            Type      = spell.Type;
            Invert    = spell.Invert;
            BigStacks = spell.BigStacks;
            UseIcon   = spell.UseIcon;

            AssociatedAuras.AddRange(spell.AssociatedAuras);
        }
Exemple #2
0
    public static void ChangeStatsWeightSettings(ClassSpec classSpec)
    {
        Logger.Log($"Setting stat weight to {classSpec}");

        if (!AllPresets.ContainsKey(classSpec))
        {
            Logger.LogError($"{classSpec} couldn't be found in the presets dictionary.");
            return;
        }

        Dictionary <CharStat, int> preset = AllPresets[classSpec];

        if (preset == null)
        {
            Logger.LogError($"Preset dictionary for {classSpec} doesn't exist");
            return;
        }

        // Reset all values
        AutoEquipSettings.CurrentSettings.StatWeights.Clear();

        // Assign values
        foreach (KeyValuePair <CharStat, int> presetToAssign in preset)
        {
            AutoEquipSettings.CurrentSettings.SetStat(presetToAssign.Key, presetToAssign.Value);
        }

        AutoEquipSettings.CurrentSettings.Save();
        //AutoEquipSettings.Load();
    }
        private static string GenerateAuraId(ClassSpec classSpec, Spell spell)
        {
            var sb = new StringBuilder();

            var name = spell.Name
                       .Replace("-", "_")
                       .Replace("\'", "")
                       .Replace(":", "")
                       .Replace("!", "_")
                       .Replace(",", "")
                       .Replace(")", "")
                       .Replace("(", "")
                       .Replace(" ", "_");

            sb.Append(classSpec.ToAuraPrefix());
            sb.Append('_');
            sb.Append(name);
            // sb.Append('_');
            // sb.Append(spell.SpellIds.First());

            //if (spell.Type.HasFlag(SpellType.Cooldown)) sb.Append("_cd");
            //if (spell.Type.HasFlag(SpellType.DebuffOnTarget)) sb.Append("_debuff");
            //if (spell.Type.HasFlag(SpellType.BuffOnPlayer)) sb.Append("_buff");
            //if (spell.Type.HasFlag(SpellType.BuffOnTarget)) sb.Append("_tar");

            // if (spell.Type.HasFlag(SpellType.DoT)) sb.Append("_dot");
            // if (spell.Talent != 0) sb.Append("_t").Append(spell.Talent);

            return(sb.ToString().ToLowerInvariant());
        }
 public EnemyOrcRanger(int expReward   = 10, ClassSpec @class = ClassSpec.RANGER, string name = "OrcsmerRanger",
                       int healthPoint = 20, int armour       = 1, int attackPower = 3)
     : base(expReward, @class, name, healthPoint, armour, attackPower)
 {
     EquipedItems["Weapon"] = new Items.Weapons.SimpleBow();
     attackBehaviour        = new CharactersActions.AttackWithWeapon();
 }
Exemple #5
0
 public EnemyOrcMage(int expReward   = 10, ClassSpec @class = ClassSpec.MAGE, string name = "OrcsmerMage",
                     int healthPoint = 25, int armour       = 0, int attackPower = 2)
     : base(expReward, @class, name, healthPoint, armour, attackPower)
 {
     EquipedItems["Spell"] = new Items.Spells.Fireball();
     attackBehaviour       = new CharactersActions.AttackWithSpell();
 }
Exemple #6
0
 // note: Use booleans are ignored and it just checks to see if the object exists or not
 public static void LoadIf(this Aura aura, ClassSpec classSpec)
 {
     aura.Load.ClassAndSpec = new ClassAndSpec {
         Single = (int)classSpec
     };
     aura.Load.UseClassAndSpec = true;
 }
Exemple #7
0
        // From Code-gen
        public Spell(string name, ClassType classType, ClassSpec classSpec,
                     int[] spellIds, int[] levels, int talent, int icon,
                     double[] cooldowns, double[] durations, bool isPvp, double range,
                     string[] categories, SpellEffectData[] data)
        {
            Name      = name;
            ClassType = classType;
            ClassSpec = classSpec;
            SpellIds.AddRange(spellIds);
            Levels.AddRange(levels);
            Talent = talent;
            Icon   = icon;

            Cooldowns.AddRange(cooldowns);
            Durations.AddRange(durations);

            IsPvp = isPvp;
            Range = range;

            Categories = categories.ToHashSet();
            Effects    = data.ToList();

            if (Effects.Any(e => e.AuraType == EffectAuraType.PeriodicDamage))
            {
                Type |= SpellType.DoT;
            }
        }
Exemple #8
0
        private Hero(ClassSpec @class, string name, int healthPoint, int armour, int attackPower)
            : base(@class, name, healthPoint, armour, attackPower)
        {
            //attackBehaviour = new CharactersActions.AttackWithWeapon();

            maxHP      = healthPoint;
            Expirience = 0;
            Level      = 0;
        }
Exemple #9
0
 // Minimal Variant -- for humans seeking a low effort typing experience
 public Spell(string name, ClassType classType, ClassSpec classSpec,
              int spellId, int talent, SpellType spellType = SpellType.Cooldown)
 {
     Name      = name;
     ClassType = classType;
     ClassSpec = classSpec;
     SpellIds.Add(spellId);
     Talent = talent;
     Type   = spellType;
 }
        public FriendlyTrader(ClassSpec @class = ClassSpec.WARRIOR, string name = "Trader", int healthPoint = 100, int armour = 0, int attackPower = 0)
            : base(@class, name, healthPoint, armour, attackPower)
        {
            attackBehaviour = new CharactersActions.NoAttack();
            quest           = new Quests.AssasinationQuest();

            for (int i = 0; i <= 10; i++)
            {
                resources.ItemList.Add(new Items.Armours.SteelArmour());
                resources.ItemList.Add(new Items.Weapons.SimpleBow());
                resources.ItemList.Add(new Items.Weapons.SteelSword());
            }
        }
        public void PropertyAndClassTest()
        {
            ClassSpec classSpec = NapackFileAnalyzer.Analyze("Test", "unused", SampleStrings.LargeSampleClass).Classes.First();

            Assert.AreEqual(1, classSpec.PublicProperties.Count);

            PropertySpec property = classSpec.PublicProperties.First();

            Assert.IsNotNull(property.Name);
            Assert.IsNotNull(property.Name.Name);
            Assert.IsNotNull(property.Name.Documentation);
            Assert.IsNotNull(property.Type);
            Assert.IsFalse(property.IsStatic);
        }
Exemple #12
0
        static Settings()
        {
            TimerInterval = Configuration.GetRequiredValue <int>("TimerInterval");

            AgencyId         = Configuration.GetRequiredValue <int>("AgencyId");
            WipeCarrierName  = Configuration.GetRequiredValue("WipeCarrierName");
            LastModifiedDate = Configuration.GetRequiredValue <DateTime>("LastModifiedDate");

            CsvOutputFolderPath            = Configuration.GetRequiredValue("CsvOutputFolderPath");
            PDFInputFolderPath             = Configuration.GetRequiredValue("PDFInputFolderPath");
            ImportArchiveFolderPath        = Configuration.GetRequiredValue("ImportArchiveFolderPath");
            TextConverterProjectFolderPath = Configuration.GetRequiredValue("TextConverterProjectFolderPath");

            ClassSpec = Configuration.GetRequiredValue("ClassSpec", ParseClassSpec);
        }
        public void FieldAndClassTest()
        {
            ClassSpec classSpec = NapackFileAnalyzer.Analyze("Test", "unused", SampleStrings.LargeSampleClass).Classes.First();

            Assert.AreEqual(1, classSpec.PublicFields.Count);

            FieldSpec field = classSpec.PublicFields.First();

            Assert.IsNotNull(field.Name);
            Assert.IsNotNull(field.Name.Name);
            Assert.IsNotNull(field.Name.Documentation);
            Assert.IsNotNull(field.Type);
            Assert.IsTrue(field.IsConst);
            Assert.IsFalse(field.IsStatic);
            Assert.IsFalse(field.IsReadonly);
        }
        public BaseCharacter(ClassSpec @class = ClassSpec.WARRIOR, string name = "NoName",
                             int healthPoint  = 100, int armour = 0, int attackPower = 0)
        {
            EquipedItems.Add("Weapon", new Items.Weapons.SteelSword());
            EquipedItems.Add("Armour", new Items.Armours.SteelArmour());
            EquipedItems.Add("Spell", new Items.Spells.Fireball());
            EquipedItems.Add("Potion", new Items.Potion.HealthPotion());

            Class       = @class;
            Name        = name;
            HealthPoint = healthPoint;
            Armour      = armour;
            AttackPower = attackPower;

            attackBehaviour = new CharactersActions.BasicAttack();
        }
        public void MethodAndClassTest()
        {
            ClassSpec classSpec = NapackFileAnalyzer.Analyze("Test", "unused", SampleStrings.LargeSampleClass).Classes.First();

            Assert.IsTrue(classSpec.PublicMethods.Count != 0);

            MethodSpec method = classSpec.PublicMethods.First();

            foreach (ParameterSpec parameter in method.Parameters)
            {
                Assert.IsNotNull(parameter.Name);
                Assert.IsNotNull(parameter.Modifier);
                Assert.IsNotNull(parameter.Type);
            }

            Assert.IsNotNull(method.ReturnType);
        }
Exemple #16
0
        /// <summary>
        /// Determines the requried upversioning when code transitions from the old Napack to the new Napack.
        /// </summary>
        /// <remarks>
        /// Major == breaking changes.
        /// Minor == publically-facing API was added (but not changed or removed) from the new Napack.
        /// Patch == The publically-facing API is identical between both Napacks, excluding documentation.
        /// </remarks>
        public static UpversionType DeterminedRequiredUpversioning(NapackSpec oldNapack, NapackSpec newNapack)
        {
            UpversionType maxUpversionType = UpversionType.Patch;

            foreach (ClassSpec oldClassSpec in oldNapack.Classes)
            {
                ClassSpec newClassSpec = newNapack.Classes
                                         .FirstOrDefault(cls => cls.Name.Name.Equals(oldClassSpec.Name.Name, StringComparison.InvariantCulture));
                UpversionType upversionType = NapackAnalyst.AnalyzeClass(oldClassSpec, newClassSpec);
                if (upversionType == UpversionType.Major)
                {
                    // Exit early, as we found a breaking change.
                    return(UpversionType.Major);
                }
                else if (upversionType == UpversionType.Minor)
                {
                    maxUpversionType = UpversionType.Minor;
                }
            }

            foreach (InterfaceSpec oldInterfaceSpec in oldNapack.Interfaces)
            {
                InterfaceSpec newInterfaceSpec = newNapack.Interfaces
                                                 .FirstOrDefault(cls => cls.Name.Name.Equals(oldInterfaceSpec.Name.Name, StringComparison.InvariantCulture));
                UpversionType upversionType = NapackAnalyst.AnalyzeInterface(oldInterfaceSpec, newInterfaceSpec);
                if (upversionType == UpversionType.Major)
                {
                    // Exit early, as we found a breaking change.
                    return(UpversionType.Major);
                }
                else if (upversionType == UpversionType.Minor)
                {
                    maxUpversionType = UpversionType.Minor;
                }
            }

            // No APIs added in the prior classes. Did the new package add classes?
            if (maxUpversionType == UpversionType.Patch && (newNapack.Classes.Count != oldNapack.Classes.Count || newNapack.Interfaces.Count != oldNapack.Interfaces.Count))
            {
                maxUpversionType = UpversionType.Minor;
            }

            return(maxUpversionType);
        }
        // todo: this is _really_ bad logic, only works since lists don't change order
        // LUA DRIVEN VARIANT
        public static void ArrangeSpells2(this WeakAura weak, AuraGrid grid, ClassSpec spec, IEnumerable <Spell> spells)
        {
            foreach (var spell in spells)
            {
                var spellAuras = weak.AddSpell(spell, spec, 0, 0);

                for (var i = 0; i < spellAuras.Count; i++)
                {
                    var advance       = i == spellAuras.Count - 1;
                    var aura          = spellAuras[i];
                    var auraGrid      = grid.LuaId;
                    var auraTalent    = spell.Talent;
                    var auraClassSpec = (int)spec;

                    if (auraClassSpec != _auraClassSpec)
                    {
                        _sb.AddRecords(aura.Id, advance, auraGrid, auraTalent, auraClassSpec);
                    }
                    else if (auraTalent != _auraTalent)
                    {
                        _sb.AddRecords(aura.Id, advance, auraGrid, auraTalent);
                    }
                    else if (auraGrid != _auraGrid)
                    {
                        _sb.AddRecords(aura.Id, advance, auraGrid);
                    }
                    else if (advance)
                    {
                        _sb.AddRecords(aura.Id, advance);
                    }
                    else
                    {
                        _sb.AddRecords(aura.Id);
                    }

                    _auraGrid      = auraGrid;
                    _auraTalent    = auraTalent;
                    _auraClassSpec = auraClassSpec;
                }
            }
        }
Exemple #18
0
        public static Hero GetInstance(ClassSpec classSpec)
        {
            if (instance == null)
            {
                switch (classSpec)
                {
                case ClassSpec.WARRIOR:
                    instance = new Hero(ClassSpec.WARRIOR, "HeroWarrior", 120, 0, 10);
                    break;

                case ClassSpec.RANGER:
                    instance = new Hero(ClassSpec.RANGER, "HeroRanger", 100, 2, 5);
                    break;

                case ClassSpec.MAGE:
                    instance = new Hero(ClassSpec.RANGER, "HeroMage", 80, 1, 2);
                    break;
                }
            }
            return(instance);
        }
Exemple #19
0
 public static string ToAuraPrefix(this ClassSpec classSpec)
 {
     return(classSpec switch
     {
         ClassSpec.FrostMage => "mage_frost",
         ClassSpec.HolyPaladin => "paladin_holy",
         ClassSpec.ProtectionPaladin => "paladin_protection",
         ClassSpec.Retribution => "paladin_retribution",
         ClassSpec.Arms => "warrior_arms",
         ClassSpec.Fury => "warrior_fury",
         ClassSpec.ProtectionWarrior => "warrior_protection",
         ClassSpec.Balance => "druid_balance",
         ClassSpec.Feral => "druid_feral",
         ClassSpec.Guardian => "druid_guardian",
         ClassSpec.RestorationDruid => "druid_restoration",
         ClassSpec.Blood => "deathknight_blood",
         ClassSpec.Frost => "deathknight_frost",
         ClassSpec.Unholy => "deathknight_unholy",
         ClassSpec.BeastMastery => "hunter_beastmastery",
         ClassSpec.Marksmanship => "hunter_marksmanship",
         ClassSpec.Survival => "hunter_survival",
         ClassSpec.Discipline => "priest_discipline",
         ClassSpec.HolyPriest => "priest_holy",
         ClassSpec.Shadow => "priest_shadow",
         ClassSpec.Assassination => "rogue_assassination",
         ClassSpec.Outlaw => "rogue_outlaw",
         ClassSpec.Subtlety => "rogue_subtlety",
         ClassSpec.Elemental => "shaman_elemental",
         ClassSpec.Enhancement => "shaman_enhancement",
         ClassSpec.RestorationShaman => "shaman_restoration",
         ClassSpec.Affliction => "warlock_affliction",
         ClassSpec.Demonology => "warlock_demonology",
         ClassSpec.Destruction => "warlock_destruction",
         ClassSpec.Brewmaster => "monk_brewmaster",
         ClassSpec.Windwalker => "monk_windwalker",
         ClassSpec.Mistweaver => "monk_mistweaver",
         ClassSpec.Havoc => "demonhunter_havoc",
         ClassSpec.Vengeance => "demonhunter_vengeance",
         _ => throw new ArgumentOutOfRangeException(nameof(classSpec), classSpec, null)
     });
        public void DocumentationIsParsed()
        {
            ClassSpec classSpec = NapackFileAnalyzer.Analyze("Test", "unused", SampleStrings.LargeSampleClass).Classes.First();

            Assert.IsNotNull(classSpec.Name);
            Assert.IsNotNull(classSpec.Name.Name);
            Assert.IsNotNull(classSpec.Name.Documentation);

            Assert.IsTrue(classSpec.PublicMethods.Count != 0);
            MethodSpec method = classSpec.PublicMethods.First();

            Assert.IsNotNull(method.Name);
            Assert.IsNotNull(method.Name.Name);
            Assert.IsNotNull(method.Name.Documentation);

            Assert.IsTrue(classSpec.PublicConstructors.Count != 0);
            ConstructorSpec constructor = classSpec.PublicConstructors.First();

            Assert.IsNotNull(constructor.Name);
            Assert.IsNotNull(constructor.Name.Name);
            Assert.IsNotNull(constructor.Name.Documentation);
        }
        // OLD VARIANT
        public static void ArrangeSpells(this WeakAura weak, AuraGrid grid, ClassSpec spec, IEnumerable <Spell> spells)
        {
            var talents  = new List <int>();
            var position = 0;

            grid = grid.Clone();
            grid.Reset();

            foreach (var spell in spells)
            {
                weak.AddSpell(spell, spec, 0, 0);

                var o = grid.Location?.Clone();

                grid.Next();

                var x = grid.Location.X;
                var y = grid.Location.Y;

                // Console.WriteLine($"{position}:: {x}, {y} -- {spell.Name} -- {y} - {grid.Origin.Y} < -{grid.Height} * {grid.Size}");

                var spellAuras = weak.AddSpell(spell, spec, x, y);
                if (talents.Any())
                {
                    spellAuras.DisplaceByTalents(grid, position, talents.ToArray());
                }

                if (spell.Talent != 0)
                {
                    talents.Add(spell.Talent);
                    grid.Location = o;
                }
                else
                {
                    position++;
                }
            }
        }
        public void ConstructorAndClassTest()
        {
            ClassSpec classSpec = NapackFileAnalyzer.Analyze("Test", "unused", SampleStrings.LargeSampleClass).Classes.First();

            Assert.IsTrue(classSpec.PublicConstructors.Count != 0);

            ConstructorSpec constructor = classSpec.PublicConstructors.First();

            bool oneHasDefault = false;

            foreach (ParameterSpec parameter in constructor.Parameters)
            {
                Assert.IsNotNull(parameter.Name);
                Assert.IsNotNull(parameter.Modifier);
                Assert.IsNotNull(parameter.Type);
                if (!string.IsNullOrWhiteSpace(parameter.Default))
                {
                    oneHasDefault = true;
                }
            }

            Assert.IsTrue(oneHasDefault);
        }
Exemple #23
0
 public Enemy(int expReward, ClassSpec @class = ClassSpec.WARRIOR, string name = "NoName", int healthPoint = 100, int armour = 0, int attackPower = 0) : base(@class, name, healthPoint, armour, attackPower)
 {
     ExpReward = expReward;
     maxHP     = healthPoint;
 }
        public static List <Aura> AddSpell(this WeakAura weak, Spell spell, ClassSpec classSpec, int x, int y)
        {
            // todo: Use_Icon
            var addedAuras = new List <Aura>();
            var auraId     = GenerateAuraId(classSpec, spell);

            if (spell.Type.HasFlag(SpellType.Cooldown))
            {
                var aura = AuraIcon.Generate(auraId);
                aura.WatchAbilityCooldown(spell.Name, spell.SpellIds);
                addedAuras.Add(aura);
            }

            if (spell.Type.HasFlag(SpellType.DoT))
            {
                var onTarget = AuraIcon.Generate($"{auraId}_is_on_target");
                onTarget.WatchForDebuffOnTarget(spell.Name);

                var notOnTarget = AuraIcon.Generate($"{auraId}_not_on_target");
                notOnTarget.WatchForDebuffNotOnTarget(spell.Name, spell.SpellIds);
                notOnTarget.AddGlow(new Color(1, 0.04, 0.3));

                var refreshable = spell.Durations.Count == 0 ? 0 : (int)Math.Floor(spell.Durations.Max() * 0.3);
                if (refreshable < 1)
                {
                    Console.WriteLine($"WARN: {spell.Name} refreshable very low: {refreshable};");
                }

                var canRefresh = AuraIcon.Generate($"{auraId}_refreshable");
                canRefresh.AddGlow();
                canRefresh.WatchForDebuffOnTargetLow(spell.Name, refreshable);

                addedAuras.Add(onTarget, notOnTarget, canRefresh);
            }
            // DoT types already include a debuff on target tracker
            else if (spell.Type.HasFlag(SpellType.DebuffOnTarget))
            {
                var onTarget = AuraIcon.Generate($"{auraId}_is_on_target");
                onTarget.AddGlow();

                if (spell.AssociatedAuras.Count != 0)
                {
                    spell.AssociatedAuras.ForEach(s => onTarget.WatchForDebuffOnTarget(s.Name));
                }
                else
                {
                    onTarget.WatchForDebuffOnTarget(spell.Name);
                }

                addedAuras.Add(onTarget);
            }

            if (spell.Type.HasFlag(SpellType.BuffOnPlayer))
            {
                var onPlayer = AuraIcon.Generate($"{auraId}_buff_on_me");
                onPlayer.AddGlow();

                if (spell.AssociatedAuras.Count != 0)
                {
                    spell.AssociatedAuras.ForEach(s =>
                    {
                        if (s.Invert)
                        {
                            onPlayer.WatchForBuffNotOnPlayer(s.Name);
                        }
                        else
                        {
                            onPlayer.WatchForBuffOnPlayer(s.Name);
                        }
                    });
                }
                else
                {
                    if (spell.Invert)
                    {
                        onPlayer.WatchForBuffNotOnPlayer(spell.Name);
                    }
                    else
                    {
                        onPlayer.WatchForBuffOnPlayer(spell.Name);
                    }
                }

                addedAuras.Add(onPlayer);
            }

            foreach (var aura in addedAuras)
            {
                weak.Table.Children.Add(aura);

                aura.LoadIf(classSpec);
                aura.LoadIfTalent(spell.Talent);
                aura.AddVisibilityToggle();
                aura.XOffset = x;
                aura.YOffset = y;

                if (spell.BigStacks)
                {
                    // First SubRegion is always a TextRegion
                    aura.SubRegions.First().TextFontSize = 30;
                }
            }

            return(addedAuras);
        }
Exemple #25
0
 public Friend(ClassSpec @class = ClassSpec.WARRIOR, string name = "NoName", int healthPoint = 100, int armour = 0,
               int attackPower  = 0) : base(@class, name, healthPoint, armour, attackPower)
 {
 }
Exemple #26
0
        internal static ClassSpec AnalyzeClassSyntaxTree(string napackName, string filename, ClassDeclarationSyntax classNode)
        {
            ClassSpec classSpec = new ClassSpec();

            classSpec.Name       = DocumentedElement.LoadFromSyntaxNode(classNode);
            classSpec.IsAbstract = classNode.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.AbstractKeyword));
            classSpec.IsStatic   = classNode.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.StaticKeyword));
            classSpec.IsSealed   = classSpec.IsStatic || classNode.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.SealedKeyword));

            // Parse classes recursively
            foreach (ClassDeclarationSyntax node in classNode.ChildNodes().Where(node => node.IsKind(SyntaxKind.ClassDeclaration)))
            {
                if (node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.PublicKeyword)) ||
                    (classSpec.ProtectedItemsConsideredPublic && node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.ProtectedKeyword))))
                {
                    // This recursion will exit because we aren't *compiling* the code, but merely parsing it.
                    classSpec.PublicClasses.Add(AnalyzeClassSyntaxTree(napackName, filename, node));
                }
            }

            // Parse methods
            foreach (MethodDeclarationSyntax node in classNode.ChildNodes().Where(node => node.IsKind(SyntaxKind.MethodDeclaration)))
            {
                if (node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.PublicKeyword)) ||
                    (classSpec.ProtectedItemsConsideredPublic && node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.ProtectedKeyword))))
                {
                    classSpec.PublicMethods.Add(MethodSpec.LoadFromSyntaxNode(node));
                }
            }

            // Parse constructors
            foreach (ConstructorDeclarationSyntax node in classNode.ChildNodes().Where(node => node.IsKind(SyntaxKind.ConstructorDeclaration)))
            {
                if (node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.PublicKeyword)) ||
                    (classSpec.ProtectedItemsConsideredPublic && node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.ProtectedKeyword))))
                {
                    classSpec.PublicConstructors.Add(ConstructorSpec.LoadFromSyntaxNode(node));
                }
            }

            // Parse fields
            foreach (FieldDeclarationSyntax node in classNode.ChildNodes().Where(node => node.IsKind(SyntaxKind.FieldDeclaration)))
            {
                if (node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.PublicKeyword)) ||
                    (classSpec.ProtectedItemsConsideredPublic && node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.ProtectedKeyword))))
                {
                    classSpec.PublicFields.Add(FieldSpec.LoadFromSyntaxNode(node));
                }
            }

            // Parse properties
            foreach (PropertyDeclarationSyntax node in classNode.ChildNodes().Where(node => node.IsKind(SyntaxKind.PropertyDeclaration)))
            {
                if (node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.PublicKeyword)) ||
                    (classSpec.ProtectedItemsConsideredPublic && node.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.ProtectedKeyword))))
                {
                    classSpec.PublicProperties.Add(PropertySpec.LoadFromSyntaxNode(node));
                }
            }

            return(classSpec);
        }
Exemple #27
0
    public static void AutoDetectMyClassSpec()
    {
        ClassSpec currentSpec = WAECharacterSheet.ClassSpec;

        switch (ObjectManager.Me.WowClass)
        {
        case (WoWClass.Warlock):
            if (WTTalent.GetSpec() == 2)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.WarlockDemonology;
            }
            else if (WTTalent.GetSpec() == 3)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.WarlockDestruction;
            }
            else
            {
                WAECharacterSheet.ClassSpec = ClassSpec.WarlockAffliction;
            }
            break;

        case (WoWClass.DeathKnight):
            if (WTTalent.GetSpec() == 1)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.DeathKnightBloodDPS;
            }
            else if (WTTalent.GetSpec() == 2)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.DeathKnightFrostDPS;
            }
            else
            {
                WAECharacterSheet.ClassSpec = ClassSpec.DeathKnightUnholy;
            }
            break;

        case (WoWClass.Druid):
            if (WTTalent.GetSpec() == 1)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.DruidBalance;
            }
            else if (WTTalent.GetSpec() == 3)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.DruidRestoration;
            }
            else
            {
                // TBC FERAL
                if (ToolBox.GetWoWVersion() == ToolBox.WoWVersion.TBC)
                {
                    if (WTTalent.GetTalentRank(2, 7) > 0)     // Feral Charge
                    {
                        WAECharacterSheet.ClassSpec = ClassSpec.DruidFeralTank;
                    }
                    else
                    {
                        WAECharacterSheet.ClassSpec = ClassSpec.DruidFeralDPS;
                    }
                }
                // WOTLK FERAL
                if (ToolBox.GetWoWVersion() == ToolBox.WoWVersion.WOTLK)
                {
                    if (WTTalent.GetTalentRank(2, 5) > 2 ||  // Thick Hide
                        WTTalent.GetTalentRank(2, 16) > 0 ||     // Natural Reaction
                        WTTalent.GetTalentRank(2, 22) > 0)        // Protector of the Pack
                    {
                        WAECharacterSheet.ClassSpec = ClassSpec.DruidFeralTank;
                    }
                    else
                    {
                        WAECharacterSheet.ClassSpec = ClassSpec.DruidFeralDPS;
                    }
                }
            }
            break;

        case (WoWClass.Hunter):
            if (WTTalent.GetSpec() == 1)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.HunterBeastMastery;
            }
            else if (WTTalent.GetSpec() == 3)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.HunterSurvival;
            }
            else
            {
                WAECharacterSheet.ClassSpec = ClassSpec.HunterMarksman;
            }
            break;

        case (WoWClass.Mage):
            if (WTTalent.GetSpec() == 1)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.MageArcane;
            }
            else if (WTTalent.GetSpec() == 2)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.MageFire;
            }
            else
            {
                WAECharacterSheet.ClassSpec = ClassSpec.MageFrost;
            }
            break;

        case (WoWClass.Paladin):
            if (WTTalent.GetSpec() == 1)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.PaladinHoly;
            }
            else if (WTTalent.GetSpec() == 2)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.PaladinProtection;
            }
            else
            {
                WAECharacterSheet.ClassSpec = ClassSpec.PaladinRetribution;
            }
            break;

        case (WoWClass.Priest):
            if (WTTalent.GetSpec() == 1)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.PriestDiscipline;
            }
            else if (WTTalent.GetSpec() == 2)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.PriestHoly;
            }
            else
            {
                WAECharacterSheet.ClassSpec = ClassSpec.PriestShadow;
            }
            break;

        case (WoWClass.Rogue):
            if (WTTalent.GetSpec() == 1)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.RogueAssassination;
            }
            else if (WTTalent.GetSpec() == 3)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.RogueSubtelty;
            }
            else
            {
                WAECharacterSheet.ClassSpec = ClassSpec.RogueCombat;
            }
            break;

        case (WoWClass.Shaman):
            if (WTTalent.GetSpec() == 1)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.ShamanElemental;
            }
            else if (WTTalent.GetSpec() == 3)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.ShamanRestoration;
            }
            else
            {
                WAECharacterSheet.ClassSpec = ClassSpec.ShamanEnhancement;
            }
            break;

        case (WoWClass.Warrior):
            if (WTTalent.GetSpec() == 1)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.WarriorArms;
            }
            else if (WTTalent.GetSpec() == 3)
            {
                WAECharacterSheet.ClassSpec = ClassSpec.WarriorTank;
            }
            else
            {
                WAECharacterSheet.ClassSpec = ClassSpec.WarriorFury;
            }
            break;

        default:
            WAECharacterSheet.ClassSpec = ClassSpec.None;
            break;
        }

        // Update stat weights in case of auto detect
        if (AutoEquipSettings.CurrentSettings.AutoDetectStatWeights && currentSpec != WAECharacterSheet.ClassSpec)
        {
            WAEItemDB.ItemDb.Clear(); // to Rescan all items
            SettingsPresets.ChangeStatsWeightSettings(WAECharacterSheet.ClassSpec);
        }

        // Set other default plugin settings according to detected class for first launch
        if (AutoEquipSettings.CurrentSettings.FirstLaunch && currentSpec != WAECharacterSheet.ClassSpec)
        {
            Logger.Log("First Launch");
            SettingsPresets.ChangeAutoEquipSetting(WAECharacterSheet.ClassSpec);
            AutoEquipSettings.CurrentSettings.FirstLaunch = false;
            AutoEquipSettings.CurrentSettings.Save();
        }

        AutoEquipSettings.CurrentSettings.SpecSelectedByUser = WAECharacterSheet.ClassSpec;
    }
        private void EmitProxy(ClassSpec classSpec)
        {
            var methods = new StringBuilder();

            foreach (var methodSpec in classSpec.Methods)
            {
                var signature     = new StringBuilder($"public {methodSpec.FullyQualifiedReturnTypeName} {methodSpec.Name}(");
                var callArgs      = new StringBuilder("");
                var signatureArgs = new StringBuilder("");
                var first         = true;
                foreach (var argumentSpec in methodSpec.Arguments)
                {
                    if (!first)
                    {
                        signatureArgs.Append(", ");
                    }

                    first = false;
                    signatureArgs.Append($"{argumentSpec.FullyQualifiedTypeName} {argumentSpec.Name}");
                    callArgs.Append($", {argumentSpec.Name}");
                }
                signature.Append(signatureArgs);
                signature.Append(')');

                // Prepare method body
                var body = "";
                if (methodSpec.Support != SupportClassification.Supported)
                {
                    body = methodSpec.SupportHint is null
                        ? "throw new System.NotSupportedException();"
                        : $"throw new System.NotSupportedException(\"{methodSpec.SupportHint}\");";
                }
                else
                {
                    // Get specific hub connection extension method call
                    var specificCall = GetSpecificCall(methodSpec);

                    // Handle ValueTask
                    var prefix = "";
                    var suffix = "";
                    if (methodSpec.IsReturnTypeValueTask)
                    {
                        if (methodSpec.InnerReturnTypeName is not null)
                        {
                            prefix = $"new System.Threading.Tasks.ValueTask<{methodSpec.InnerReturnTypeName}>(";
                        }
                        else
                        {
                            prefix = "new System.Threading.Tasks.ValueTask(";
                        }
                        suffix = $")";
                    }

                    // Bake it all together
                    body = $"return {prefix}this.connection.{specificCall}(\"{methodSpec.Name}\"{callArgs}){suffix};";
                }

                var method = $@"
        {signature}
        {{
            {body}
        }}
";
                methods.Append(method);
            }

            var proxy = $@"// <auto-generated>
// Generated by Microsoft.AspNetCore.Client.SourceGenerator
// </auto-generated>

#nullable enable

using Microsoft.AspNetCore.SignalR.Client;

namespace {_spec.GetterNamespace}
{{
    {_spec.GetterClassAccessibility} static partial class {_spec.GetterClassName}
    {{
        private sealed class {classSpec.ClassTypeName} : {classSpec.FullyQualifiedInterfaceTypeName}
        {{
            private readonly HubConnection connection;
            internal {classSpec.ClassTypeName}(HubConnection connection)
            {{
                this.connection = connection;
            }}
    {methods.ToString()}
        }}
    }}
}}";

            _context.AddSource($"HubServerProxy.{classSpec.ClassTypeName}.g.cs", SourceText.From(proxy.ToString(), Encoding.UTF8));
        }
Exemple #29
0
 public SpellTalentSpec(Talent talent)
 {
     Talent = talent.TalentPosition();
     Spec   = (ClassSpec)talent.SpecId;
 }
Exemple #30
0
 public EnemyOrcWarrior(int expReward   = 99, ClassSpec @class = ClassSpec.WARRIOR, string name = "OrcsmerWarrior",
                        int healthPoint = 30, int armour       = 2, int attackPower = 5)
     : base(expReward, @class, name, healthPoint, armour, attackPower)
 {
 }