public void ParseReturnsCorrectResult()
        {
            var untranslatedStats = new[]
            {
                new UntranslatedStat("a", 1),
                new UntranslatedStat("b", 2),
                new UntranslatedStat("c", 3),
            };
            var modifierLines        = new[] { "a1", "b2" };
            var statTranslatorResult = new StatTranslatorResult(modifierLines, new UntranslatedStat[0]);
            var translator           = Mock.Of <IStatTranslator>(t => t.Translate(untranslatedStats) == statTranslatorResult);
            var localSource          = new ModifierSource.Local.Skill();
            var globalSource         = new ModifierSource.Global(localSource);
            var coreParserParameters = new[]
            {
                new CoreParserParameter(modifierLines[0], globalSource, Entity.Character),
                new CoreParserParameter(modifierLines[1], globalSource, Entity.Character),
            };
            var parseResults = new[]
            {
                ParseResult.Empty,
                ParseResult.Failure("b2", ""),
            };
            var coreParser = Mock.Of <ICoreParser>(p =>
                                                   p.Parse(coreParserParameters[0]) == parseResults[0] &&
                                                   p.Parse(coreParserParameters[1]) == parseResults[1]);

            var sut             = new UntranslatedStatParser(translator, coreParser);
            var parserParameter = new UntranslatedStatParserParameter(localSource, untranslatedStats);
            var expected        = ParseResult.Aggregate(parseResults);

            var actual = sut.Parse(parserParameter);

            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void ParseMultipleSupportedActiveSkillsCorrectly()
        {
            var expected = ParseResult.Aggregate(new[]
            {
                CreateParseResult("0", "b", "c"),
                CreateParseResult("1", "b"),
                CreateParseResult("2", "a", "b", "d"),
            });
            var actives = new[]
            {
                CreateSkill("0", 0),
                CreateSkill("1", 1),
                CreateSkill("2", 2),
            };
            var supports = new[]
            {
                CreateSkill("a", 2),
                CreateSkill("b", null),
                CreateSkill("c", 0),
                CreateSkill("d", 2),
            };
            var sut = CreateSut();

            var actual = sut.Parse(actives.Concat(supports).ToList());

            Assert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public ParseResult Parse(PartialItemParserParameter parameter)
        {
            var(item, _, entity, baseItemDefinition, localSource, globalSource) = parameter;
            var itemTags = baseItemDefinition.Tags;

            var results = new List <ParseResult>(1 + item.Modifiers.Count)
            {
                ParseBuffStats(entity, itemTags, localSource, baseItemDefinition.BuffStats)
            };

            foreach (var modifier in item.Modifiers)
            {
                if (ModifierLocalityTester.AffectsProperties(modifier, itemTags))
                {
                    results.Add(ParsePropertyModifier(localSource, entity, modifier));
                }
                else if (ModifierLocalityTester.IsLocal(modifier, itemTags))
                {
                    results.Add(ParseLocalModifier(itemTags, localSource, entity, modifier));
                }
                else
                {
                    results.Add(ParseGlobalModifier(itemTags, globalSource, entity, modifier));
                }
            }
            return(ParseResult.Aggregate(results));
        }
        public ParseResult Parse(IReadOnlyList <Skill> skills)
        {
            var activeSkills  = new List <Skill>();
            var supportSkills = new List <Skill>(skills.Count);

            foreach (var skill in skills)
            {
                if (_skillDefinitions.GetSkillById(skill.Id).IsSupport)
                {
                    supportSkills.Add(skill);
                }
                else
                {
                    activeSkills.Add(skill);
                }
            }

            var parseResults = new List <ParseResult>(activeSkills.Count * supportSkills.Count);

            foreach (var activeSkill in activeSkills)
            {
                parseResults.Add(_activeSkillParser.Parse(activeSkill));
                var supportingSkills = _supportabilityTester.SelectSupportingSkills(activeSkill, supportSkills);
                foreach (var supportingSkill in supportingSkills)
                {
                    parseResults.Add(_supportSkillParser.Parse(activeSkill, supportingSkill));
                }
            }

            return(ParseResult.Aggregate(parseResults));
        }
        public ParseResult Parse(GemsParserParameter parameter)
        {
            var(gems, entity) = parameter;
            var results = new List <ParseResult>(gems.Count);

            foreach (var gem in gems)
            {
                results.Add(_gemParser.Parse(gem, entity, out var newSkills));
                parameter.Skills.AddRange(newSkills);
            }
            results.AddRange(ParseAdditionalSkillStats(parameter.Skills, entity));
            return(ParseResult.Aggregate(results));
        }
        private ParseResult ParseTransformationModifier(string modifier, ModifierSource modifierSource,
                                                        IEnumerable <PassiveNodeDefinition> nodesInRadius)
        {
            var transformedNodeModifiers = _transformationParser.ApplyTransformation(modifier, nodesInRadius).ToList();
            var results = new List <ParseResult>(transformedNodeModifiers.Count);

            foreach (var transformedModifier in transformedNodeModifiers)
            {
                var parseResult = _coreParser.Parse(transformedModifier.Modifier, modifierSource, ModifierSourceEntity)
                                  .ApplyMultiplier(transformedModifier.ValueMultiplier.Build, ModifierSourceEntity);
                results.Add(parseResult);
            }
            return(ParseResult.Aggregate(results));
        }
        public ParseResult Parse(JewelInSkillTreeParserParameter parameter)
        {
            var(item, radius, nodeId) = parameter;
            if (!item.IsEnabled)
            {
                return(ParseResult.Empty);
            }

            var localSource   = new ModifierSource.Local.Jewel(radius, nodeId, item.Name);
            var globalSource  = new ModifierSource.Global(localSource);
            var nodesInRadius = _tree.GetNodesInRadius(nodeId, radius).ToList();

            var results = new List <ParseResult>(item.Modifiers.Count);

            foreach (var modifier in item.Modifiers)
            {
                results.Add(ParseModifier(modifier, globalSource, nodesInRadius));
            }

            return(ParseResult.Aggregate(results));
        }
Beispiel #8
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));
        }
 public ParseResult Parse(AdditionalSkillStatParserParameter parameter) =>
 ParseResult.Aggregate(_parsers.Select(p => p.Parse(parameter)));
Beispiel #10
0
 public ParseResult Parse(SkillsParserParameter parameter)
 {
     var(skills, entity) = parameter;
     var(supportSkills, activeSkills) = skills.Partition(s => _skillDefinitions.GetSkillById(s.Id).IsSupport);
     return(ParseResult.Aggregate(Parse(activeSkills.ToList(), supportSkills.ToList(), entity)));
 }