Exemple #1
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));
        }
Exemple #2
0
        private IEnumerable <ItemMod> CreateItemMods(IEnumerable <StatIdValuePair> statValuePairs)
        {
            if (statValuePairs == null)
            {
                yield break;
            }

            // this list is used to translate the stats in order of appearance,
            // using merged.Keys wouldn't guarantee that
            var statIds = new List <string>();
            var merged  = new Dictionary <string, int>();

            foreach (var pair in statValuePairs)
            {
                var stat = pair.StatId;
                statIds.Add(stat);
                var value = pair.Value;
                if (merged.ContainsKey(stat))
                {
                    value += merged[stat];
                }
                merged[stat] = value;
            }

            var lines = EquipmentData.StatTranslator.GetTranslations(statIds)
                        .Select(t => t.Translate(merged))
                        .Where(l => l != null);

            foreach (var line in lines)
            {
                var attr    = ItemMod.Numberfilter.Replace(line, "#");
                var isLocal = ModifierLocalityTester.IsLocal(attr, SelectedBase.Tags);
                yield return(new ItemMod(line, isLocal));
            }
        }
 public bool IsLocalReturnsCorrectResultForFlask(string modifier)
 => ModifierLocalityTester.IsLocal(modifier, Tags.Flask);
 public bool IsLocalReturnsCorrectResultForShield(string modifier)
 => ModifierLocalityTester.IsLocal(modifier, Tags.Shield);
 public bool IsLocalReturnsCorrectResultForArmour(string modifier)
 => ModifierLocalityTester.IsLocal(modifier, Tags.Armour);
 public bool IsLocalReturnsCorrectResultForWeapon(string modifier)
 => ModifierLocalityTester.IsLocal(modifier, Tags.Weapon);
 public bool IsLocalReturnsCorrectResultForGeneric(string modifier)
 => ModifierLocalityTester.IsLocal(modifier, Tags.Default);