Пример #1
0
        public void ParseFrenzyReturnsCorrectResult()
        {
            var frenzy                      = new Skill("Frenzy", 20, 20, ItemSlot.Boots, 0, 0);
            var definition                  = _skillDefinitions.GetSkillById("Frenzy");
            var levelDefinition             = definition.Levels[20];
            var local                       = new ModifierSource.Local.Skill("Frenzy", "Frenzy");
            var global                      = new ModifierSource.Global(local);
            var gemSource                   = new ModifierSource.Local.Gem(ItemSlot.Boots, 0, "Frenzy", "Frenzy");
            var valueCalculationContextMock = new Mock <IValueCalculationContext>();
            var isMainSkillStat             = SetupIsActiveSkillInContext(valueCalculationContextMock, frenzy);
            var offHandTagsStat             = new Stat("OffHand.ItemTags");

            valueCalculationContextMock.Setup(c => c.GetValue(offHandTagsStat, NodeType.Total, PathDefinition.MainPath))
            .Returns(new NodeValue(Tags.Weapon.EncodeAsDouble()));
            var mainHandTagsStat = new Stat("MainHand.ItemTags");

            valueCalculationContextMock
            .Setup(c => c.GetValue(mainHandTagsStat, NodeType.Total, PathDefinition.MainPath))
            .Returns(new NodeValue(Tags.Ranged.EncodeAsDouble()));
            var frenzyAmountStat = new Stat("Frenzy.Amount");

            valueCalculationContextMock
            .Setup(c => c.GetValue(frenzyAmountStat, NodeType.Total, PathDefinition.MainPath))
            .Returns(new NodeValue(3));
            var baseCostStat = new Stat("Boots.0.Cost");

            valueCalculationContextMock
            .Setup(c => c.GetValue(baseCostStat, NodeType.Total, PathDefinition.MainPath))
            .Returns((NodeValue?)levelDefinition.ManaCost);
            var expectedModifiers =
                new (string stat, Form form, double?value, ModifierSource source, bool mainSkillOnly)[]
        private IValue Build(Skill skill, IValueBuilder valueBuilder, Entity modifierSourceEntity)
        {
            var gem = skill.Gem;

            if (gem is null)
            {
                return(new Constant(0));
            }

            var displayName       = GetSkillDefinition(gem.SkillId).DisplayName;
            var gemModifierSource = new ModifierSource.Local.Gem(gem, displayName);
            var buildParameters   = new BuildParameters(new ModifierSource.Global(gemModifierSource), modifierSourceEntity, default);

            return(valueBuilder.Build(buildParameters));
        }
Пример #3
0
 public SkillPreParseResult(
     SkillDefinition skillDefinition, SkillLevelDefinition levelDefinition, SkillDefinition mainSkillDefinition,
     ModifierSource.Local.Skill localSource, ModifierSource.Global globalSource,
     ModifierSource.Local.Gem gemSource,
     IConditionBuilder isMainSkill, IConditionBuilder isActiveSkill)
 {
     SkillDefinition     = skillDefinition;
     LevelDefinition     = levelDefinition;
     MainSkillDefinition = mainSkillDefinition;
     LocalSource         = localSource;
     GlobalSource        = globalSource;
     GemSource           = gemSource;
     IsMainSkill         = isMainSkill;
     IsActiveSkill       = isActiveSkill;
 }
Пример #4
0
        private ParseResult ParseRequirements(Gem gem, Entity modifierSourceEntity, SkillDefinition skillDefinition)
        {
            var levelDefinition  = skillDefinition.Levels[gem.Level];
            var modifierSource   = new ModifierSource.Local.Gem(gem, skillDefinition.DisplayName);
            var modifiers        = new ModifierCollection(_builderFactories, modifierSource, modifierSourceEntity);
            var requirementStats = _builderFactories.StatBuilders.Requirements;

            modifiers.AddLocal(requirementStats.Level, Form.BaseSet, levelDefinition.Requirements.Level);
            if (levelDefinition.Requirements.Dexterity > 0)
            {
                modifiers.AddLocal(requirementStats.Dexterity, Form.BaseSet, levelDefinition.Requirements.Dexterity);
            }
            if (levelDefinition.Requirements.Intelligence > 0)
            {
                modifiers.AddLocal(requirementStats.Intelligence, Form.BaseSet, levelDefinition.Requirements.Intelligence);
            }
            if (levelDefinition.Requirements.Strength > 0)
            {
                modifiers.AddLocal(requirementStats.Strength, Form.BaseSet, levelDefinition.Requirements.Strength);
            }

            return(ParseResult.Success(modifiers.Modifiers));
        }