public void ParseRareJewelInBodyArmourReturnsCorrectResult()
 {
     var mods = new[]
     {
         "+120 to Armour",
         "+27 to maximum Life",
         "+13% to Fire Resistance",
     };
     var item = new Item("Metadata/Items/Jewels/JewelAbyssRanged",
                         "Grim Arbiter Searching Eye Jewel", 0, 54, FrameType.Rare, false, mods, true);
     var local  = new ModifierSource.Local.Item(ItemSlot.BodyArmour, item.Name);
     var global = new ModifierSource.Global(local);
     var valueCalculationContext = Mock.Of <IValueCalculationContext>();
     var expectedModifiers       = new (string stat, Form form, double?value)[]
Exemplo n.º 2
0
 public void ParseRareAstralPlateReturnsCorrectResult()
 {
     var mods = new[]
     {
         "+1% to Fire Resistance", "+50 to maximum Life", "+32 to Strength", "10% increased Armour"
     };
     var item = new Item("Metadata/Items/Armours/BodyArmours/BodyStr15",
                         "Hypnotic Keep Astral Plate", 20, 62, FrameType.Rare, false, mods, true);
     var definition              = _baseItemDefinitions.GetBaseItemById(item.BaseMetadataId);
     var local                   = new ModifierSource.Local.Item(ItemSlot.BodyArmour, item.Name);
     var global                  = new ModifierSource.Global(local);
     var armourPropertyStat      = new Stat("BodyArmour.Armour");
     var valueCalculationContext = Mock.Of <IValueCalculationContext>(c =>
                                                                      c.GetValue(armourPropertyStat, NodeType.Total, PathDefinition.MainPath) == (NodeValue?)5);
     var expectedModifiers =
         new (string stat, Form form, double?value, ModifierSource source)[]
Exemplo n.º 3
0
        public void EvasionCalculation()
        {
            var sut = Calculator.CreateCalculator();

            var evasionStat   = new Stat();
            var lvlStat       = new Stat();
            var dexterityStat = new Stat();
            var globalSource  = new ModifierSource.Global();
            var bodySource    = new ModifierSource.Local.Item(ItemSlot.BodyArmour);
            var shieldSource  = new ModifierSource.Local.Item(ItemSlot.OffHand);

            sut.NewBatchUpdate()
            .AddModifier(evasionStat, Form.BaseSet, new Constant(53), globalSource)
            .AddModifier(evasionStat, Form.BaseAdd, new PerStatValue(lvlStat, 3), globalSource)
            .AddModifier(evasionStat, Form.BaseSet, new Constant(1000), bodySource)
            .AddModifier(evasionStat, Form.BaseSet, new Constant(500), shieldSource)
            .AddModifier(evasionStat, Form.Increase, new Constant(100), globalSource)
            .AddModifier(evasionStat, Form.Increase, new PerStatValue(dexterityStat, 1, 5), globalSource)
            .AddModifier(evasionStat, Form.Increase, new Constant(20), shieldSource)
            .AddModifier(evasionStat, Form.More, new Constant(100), bodySource)
            .AddModifier(lvlStat, Form.BaseSet, new Constant(90), globalSource)
            .AddModifier(dexterityStat, Form.BaseSet, new Constant(32), globalSource)
            .AddModifier(dexterityStat, Form.BaseAdd, new Constant(50), globalSource)
            .DoUpdate();
            var lvlTotal       = 90 * 3;
            var dexterityTotal = 50 + 32;
            var globalBase     = 53 + lvlTotal;
            var globalIncrease = 1 + Math.Ceiling(dexterityTotal / 5.0) / 100;
            var globalTotal    = globalBase * (1 + globalIncrease);
            var bodyBase       = 1000;
            var bodyTotal      = bodyBase * (1 + globalIncrease) * 2;
            var shieldBase     = 500;
            var shieldTotal    = shieldBase * (1 + globalIncrease + 0.2);
            var evasionTotal   = globalTotal + bodyTotal + shieldTotal;

            var actual = sut.NodeRepository.GetNode(evasionStat).Value;

            Assert.AreEqual(new NodeValue(evasionTotal), actual);
        }
Exemplo n.º 4
0
        public ParseResult Parse(ItemParserParameter parameter)
        {
            var(item, slot) = parameter;

            if (!item.IsEnabled)
            {
                return(ParseResult.Empty);
            }

            var localSource            = new ModifierSource.Local.Item(slot, item.Name);
            var globalSource           = new ModifierSource.Global(localSource);
            var baseItemDefinition     = _baseItemDefinitions.GetBaseItemById(item.BaseMetadataId);
            var partialParserParameter =
                new PartialItemParserParameter(item, slot, baseItemDefinition, localSource, globalSource);

            var parseResults = new List <ParseResult>(_partialParsers.Length);

            foreach (var partialParser in _partialParsers)
            {
                parseResults.Add(partialParser.Parse(partialParserParameter));
            }
            return(ParseResult.Aggregate(parseResults));
        }
Exemplo n.º 5
0
 public void BaseValueComesFromConvertsStatCorrectly()
 {
     var slot               = ItemSlot.Amulet;
     var expected           = new ModifierSource.Local.Item(slot);
     var expectedParameters = new BuildParameters(expected, default, default);