Ejemplo n.º 1
0
        public void TestBuild()
        {
            // Read build entry.
            string treeURL = TestContext.DataRow["TreeURL"].ToString();
            int level = Convert.ToInt32(TestContext.DataRow["Level"]);
            string buildFile = @"..\..\TestBuilds\" + TestContext.DataRow["BuildFile"].ToString();
            List<string> expectDefense = new List<string>();
            List<string> expectOffense = new List<string>();
            if (TestContext.DataRow.Table.Columns.Contains("ExpectDefence"))
            {
                using (StringReader reader = new StringReader(TestContext.DataRow["ExpectDefence"].ToString()))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.Length > 0 && !line.StartsWith("#"))
                            expectDefense.Add(line.Trim());
                    }
                }
            }
            if (TestContext.DataRow.Table.Columns.Contains("ExpectOffence"))
            {
                using (StringReader reader = new StringReader(TestContext.DataRow["ExpectOffence"].ToString()))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.Length > 0 && !line.StartsWith("#"))
                            expectOffense.Add(line.Trim());
                    }

                }
            }

            // Initialize structures.
            Tree.LoadFromURL(treeURL);
            Tree.Level = level;

            string itemData = File.ReadAllText(buildFile);
            ItemAttributes itemAttributes = new ItemAttributes(itemData);
            Compute.Initialize(Tree, itemAttributes);

            // Compare defense properties.
            Dictionary<string, List<string>> defense = new Dictionary<string, List<string>>();
            if (expectDefense.Count > 0)
            {
                foreach (ListGroup grp in Compute.Defense())
                {
                    List<string> props = new List<string>();
                    foreach (string item in grp.Properties.Select(InsertNumbersInAttributes))
                        props.Add(item);
                    defense.Add(grp.Name, props);
                }

                List<string> group = null;
                foreach (string entry in expectDefense)
                {
                    if (entry.Contains(':')) // Property: Value
                    {
                        Assert.IsNotNull(group, "Missing defence group [" + TestContext.DataRow["BuildFile"].ToString() + "]");
                        Assert.IsTrue(group.Contains(entry), "Wrong " + entry + " [" + TestContext.DataRow["BuildFile"].ToString() + "]");
                    }
                    else // Group
                    {
                        Assert.IsTrue(defense.ContainsKey(entry), "No such defence group: " + entry + " [" + TestContext.DataRow["BuildFile"].ToString() + "]");
                        group = defense[entry];
                    }
                }
            }

            // Compare offense properties.
            Dictionary<string, List<string>> offense = new Dictionary<string, List<string>>();
            if (expectOffense.Count > 0)
            {
                foreach (ListGroup grp in Compute.Offense())
                {
                    List<string> props = new List<string>();
                    foreach (string item in grp.Properties.Select(InsertNumbersInAttributes))
                        props.Add(item);
                    offense.Add(grp.Name, props);
                }

                List<string> group = null;
                foreach (string entry in expectOffense)
                {
                    if (entry.Contains(':')) // Property: Value
                    {
                        Assert.IsNotNull(group, "Missing offence group [" + TestContext.DataRow["BuildFile"].ToString() + "]");
                        Assert.IsTrue(group.Contains(entry), "Wrong " + entry + " [" + TestContext.DataRow["BuildFile"].ToString() + "]");
                    }
                    else // Group
                    {
                        Assert.IsTrue(offense.ContainsKey(entry), "No such offence group: " + entry + " [" + TestContext.DataRow["BuildFile"].ToString() + "]");
                        group = offense[entry];
                    }
                }
            }
        }
Ejemplo n.º 2
0
        // Initializes structures.
        public static void Initialize(SkillTree skillTree, ItemAttributes itemAttrs)
        {
            Items = itemAttrs.Equip;

            MainHand = new Weapon(WeaponHand.Main, Items.Find(i => i.Class == Item.ItemClass.MainHand));
            OffHand = new Weapon(WeaponHand.Off, Items.Find(i => i.Class == Item.ItemClass.OffHand));

            // If main hand weapon has Counts as Dual Wielding modifier, then clone weapon to off hand.
            // @see http://pathofexile.gamepedia.com/Wings_of_Entropy
            if (MainHand.Attributes.ContainsKey("Counts as Dual Wielding"))
                OffHand = MainHand.Clone(WeaponHand.Off);

            IsDualWielding = MainHand.IsWeapon() && OffHand.IsWeapon();
            if (IsDualWielding)
            {
                // Set dual wielded bit on weapons.
                MainHand.Hand |= WeaponHand.DualWielded;
                OffHand.Hand |= WeaponHand.DualWielded;
            }
            IsWieldingShield = MainHand.Is(WeaponType.Shield) || OffHand.Is(WeaponType.Shield);
            IsWieldingStaff = MainHand.Is(WeaponType.Staff);

            Level = skillTree.Level;
            if (Level < 1) Level = 1;
            else if (Level > 100) Level = 100;

            Global = new AttributeSet();

            Tree = new AttributeSet(skillTree.SelectedAttributesWithoutImplicit);
            Global.Add(Tree);

            // Keystones.
            Acrobatics = Tree.ContainsKey("#% Chance to Dodge Attacks. #% less Armour and Energy Shield, #% less Chance to Block Spells and Attacks");
            AvatarOfFire = Tree.ContainsKey("Deal no Non-Fire Damage");
            BloodMagic = Tree.ContainsKey("Removes all mana. Spend Life instead of Mana for Skills");
            ChaosInoculation = Tree.ContainsKey("Maximum Life becomes #, Immune to Chaos Damage");
            EldritchBattery = Tree.ContainsKey("Converts all Energy Shield to Mana");
            IronGrip = Tree.ContainsKey("The increase to Physical Damage from Strength applies to Projectile Attacks as well as Melee Attacks");
            IronReflexes = Tree.ContainsKey("Converts all Evasion Rating to Armour. Dexterity provides no bonus to Evasion Rating");
            NecromanticAegis = Tree.ContainsKey("All bonuses from an equipped Shield apply to your Minions instead of you");
            ResoluteTechnique = Tree.ContainsKey("Never deal Critical Strikes");
            VaalPact = Tree.ContainsKey("Life Leech applies instantly at #% effectiveness. Life Regeneration has no effect.");
            ZealotsOath = Tree.ContainsKey("Life Regeneration applies to Energy Shield instead of Life");

            Equipment = new AttributeSet();
            foreach (ItemAttributes.Attribute attr in itemAttrs.NonLocalMods)
                Equipment.Add(attr.TextAttribute, new List<float>(attr.Value));

            if (NecromanticAegis && OffHand.IsShield())
            {
                // Remove all bonuses of shield from equipment set.
                // @see http://pathofexile.gamepedia.com/Necromantic_Aegis
                foreach (var attr in OffHand.Attributes)
                    Equipment.Remove(attr);
                // Remove all bonuses from shield itself.
                OffHand.Attributes.Clear();
            }

            Global.Add(Equipment);

            CoreAttributes();

            Implicit = new AttributeSet(SkillTree.ImplicitAttributes(Global, Level));
            Global.Add(Implicit);

            // Innate dual wielding bonuses.
            // @see http://pathofexile.gamepedia.com/Dual_wielding
            if (IsDualWielding)
            {
                Global["#% more Attack Speed"] = new List<float>() { 10 };
                Global["#% more Physical Damage with Weapons"] = new List<float>() { 20 };
            }
        }