コード例 #1
0
        public void GetTranslations_VentorsGamble()
        {
            IReadOnlyDictionary <string, int> statDict = new Dictionary <string, int>
            {
                { "base_maximum_life", 30 },
                { "base_item_found_quantity_+%", 0 },
                { "base_item_found_rarity_+%", -15 },
                { "base_fire_damage_resistance_%", 33 },
                { "base_cold_damage_resistance_%", 0 },
                { "base_lightning_damage_resistance_%", -1 },
            };

            string[] expected =
            {
                "+30 to maximum Life",
                null,
                "15% reduced Rarity of Items found",
                "+33% to Fire Resistance",
                null,
                "-1% to Lightning Resistance",
            };
            var actual = _translator.GetTranslations(statDict);

            CollectionAssert.AreEqual(expected, actual.ToArray());
        }
コード例 #2
0
            public string Translate(IReadOnlyList <int> values)
            {
                if (_valueIndices.Count != values.Count)
                {
                    throw new ArgumentException("Number of values must match number of value indices");
                }

                var firstMatch = _valueIndices
                                 .EquiZip(values, (i, v) => _affix.QueryModsSingleValue(i, v))
                                 .Aggregate((a, ms) => a.Intersect(ms))
                                 .FirstOrDefault();

                if (firstMatch == null)
                {
                    return(null);
                }

                var idValueDict = _valueIndices
                                  .Select(i => firstMatch.Stats[i].Id)
                                  .EquiZip(values, Tuple.Create)
                                  .ToDictionary(t => t.Item1, t => t.Item2);

                return(_statTranslator.GetTranslations(idValueDict).First());
            }