示例#1
0
        public RollValue(ItemMod mod, FsController fs, int iLvl, bool implicitMod = false)
        {
            string name = mod.RawName;

            TheMod    = fs.Mods.records[name];
            AffixType = TheMod.AffixType;
            AffixText = String.IsNullOrEmpty(TheMod.UserFriendlyName) ? TheMod.Key : TheMod.UserFriendlyName;
            IsCrafted = TheMod.Domain == 10;
            StatValue = new int[] { mod.Value1, mod.Value2, mod.Value3, mod.Value4 };

            int subOptimalTierDistance = 0;

            List <ModsDat.ModRecord> allTiers;

            if (fs.Mods.recordsByTier.TryGetValue(Tuple.Create(TheMod.Group, TheMod.AffixType), out allTiers))
            {
                bool tierFound = false;
                TotalTiers = 0;
                //AllTiersRange = new[]{new IntRange(), new IntRange(), new IntRange()};
                foreach (var tn in allTiers)
                {
                    // still not filtering out some mods. (like a.spd from gloves projected onto rings)
                    if (tn.StatNames[0] != TheMod.StatNames[0] || tn.StatNames[1] != TheMod.StatNames[1] ||
                        tn.StatNames[2] != TheMod.StatNames[2] || tn.StatNames[3] != TheMod.StatNames[3])
                    {
                        continue;
                    }

                    TotalTiers++;
                    if (tn.Equals(TheMod))
                    {
                        Tier      = TotalTiers;
                        tierFound = true;
                    }
                    if (!tierFound && tn.MinLevel <= iLvl)
                    {
                        subOptimalTierDistance++;
                    }
                }
            }
            double hue;

            if (TotalTiers == 1)
            {
                hue = 180;
            }
            else
            {
                hue = 120 - Math.Min(subOptimalTierDistance, 3) * 40;
            }

            if (implicitMod)
            {
                TextColor = HudSkin.MagicColor;
            }
            else
            {
                TextColor = ColorUtils.ColorFromHsv(hue, TotalTiers == 1 ? 0 : 1, 1);
            }
        }
示例#2
0
        public ModValue(ItemMod mod, FsController fs, int iLvl)
        {
            string name = mod.RawName;

            Record    = fs.Mods.records[name];
            AffixType = Record.AffixType;
            AffixText = String.IsNullOrEmpty(Record.UserFriendlyName) ? Record.Key : Record.UserFriendlyName;
            IsCrafted = Record.Domain == 10;
            StatValue = new[] { mod.Value1, mod.Value2, mod.Value3, mod.Value4 };
            Tier      = -1;

            int subOptimalTierDistance = 0;

            List <ModsDat.ModRecord> allTiers;

            if (fs.Mods.recordsByTier.TryGetValue(Tuple.Create(Record.Group, Record.AffixType), out allTiers))
            {
                IEnumerable <string> validTags = Record.Tags.Select(t => t.Key)
                                                 .Where((t, tIdx) => Record.TagChances
                                                        .Where((c, cIdx) => tIdx == cIdx && c > 0).Any());
                bool tierFound = false;
                totalTiers = 0;
                foreach (ModsDat.ModRecord record in allTiers)
                {
                    // skip tiers that cannot be attained normally
                    if (!record.Tags.Where((t, tIdx) => record.TagChances
                                           .Where((c, cIdx) => tIdx == cIdx && c > 0 && (t.Key == "default" || validTags.Contains(t.Key)))
                                           .Any()).Any())
                    {
                        continue;
                    }
                    if (record.StatNames[0] == Record.StatNames[0] && record.StatNames[1] == Record.StatNames[1] &&
                        record.StatNames[2] == Record.StatNames[2] && record.StatNames[3] == Record.StatNames[3])
                    {
                        totalTiers++;
                        if (record.Equals(Record))
                        {
                            Tier      = totalTiers;
                            tierFound = true;
                        }
                        if (!tierFound && record.MinLevel <= iLvl)
                        {
                            subOptimalTierDistance++;
                        }
                    }
                }
            }

            double hue = totalTiers == 1 ? 180 : 120 - Math.Min(subOptimalTierDistance, 3) * 40;

            Color = ColorUtils.ColorFromHsv(hue, totalTiers == 1 ? 0 : 1, 1);
        }
示例#3
0
        public ModValue(ItemMod mod, FsController fs, int iLvl, Models.BaseItemType baseItem)
        {
            string baseClassName = baseItem.ClassName.ToLower().Replace(' ', '_');

            Record    = fs.Mods.records[mod.RawName];
            AffixType = Record.AffixType;
            AffixText = String.IsNullOrEmpty(Record.UserFriendlyName) ? Record.Key : Record.UserFriendlyName;
            IsCrafted = Record.Domain == ModsDat.ModDomain.Master;
            StatValue = new[] { mod.Value1, mod.Value2, mod.Value3, mod.Value4 };
            Tier      = -1;

            int subOptimalTierDistance = 0;

            List <ModsDat.ModRecord> allTiers;

            if (fs.Mods.recordsByTier.TryGetValue(Tuple.Create(Record.Group, Record.AffixType), out allTiers))
            {
                bool tierFound = false;
                totalTiers = 0;
                var keyRcd = Record.Key.Where(c => char.IsLetter(c)).ToArray <char>();
                foreach (var tmp in allTiers)
                {
                    var keyrcd = tmp.Key.Where(k => char.IsLetter(k)).ToArray <char>();
                    if (!keyrcd.SequenceEqual(keyRcd))
                    {
                        continue;
                    }

                    int baseChance;
                    if (!tmp.TagChances.TryGetValue(baseClassName, out baseChance))
                    {
                        baseChance = -1;
                    }

                    int defaultChance;
                    if (!tmp.TagChances.TryGetValue("default", out defaultChance))
                    {
                        defaultChance = 0;
                    }

                    int tagChance = -1;
                    foreach (var tg in baseItem.Tags)
                    {
                        if (tmp.TagChances.ContainsKey(tg))
                        {
                            tagChance = tmp.TagChances[tg];
                        }
                    }

                    int moreTagChance = -1;
                    foreach (var tg in baseItem.MoreTagsFromPath)
                    {
                        if (tmp.TagChances.ContainsKey(tg))
                        {
                            moreTagChance = tmp.TagChances[tg];
                        }
                    }

                    #region GetOnlyValidMods
                    switch (baseChance)
                    {
                    case 0:
                        break;

                    case -1:         //baseClass name not found in mod tags.
                        switch (tagChance)
                        {
                        case 0:
                            break;

                        case -1:             //item tags not found in mod tags.
                            switch (moreTagChance)
                            {
                            case 0:
                                break;

                            case -1:                //more item tags not found in mod tags.
                                if (defaultChance > 0)
                                {
                                    totalTiers++;
                                    if (tmp.Equals(Record))
                                    {
                                        Tier      = totalTiers;
                                        tierFound = true;
                                    }
                                    if (!tierFound && tmp.MinLevel <= iLvl)
                                    {
                                        subOptimalTierDistance++;
                                    }
                                }
                                break;

                            default:
                                totalTiers++;
                                if (tmp.Equals(Record))
                                {
                                    Tier      = totalTiers;
                                    tierFound = true;
                                }
                                if (!tierFound && tmp.MinLevel <= iLvl)
                                {
                                    subOptimalTierDistance++;
                                }
                                break;
                            }
                            break;

                        default:
                            totalTiers++;
                            if (tmp.Equals(Record))
                            {
                                Tier      = totalTiers;
                                tierFound = true;
                            }
                            if (!tierFound && tmp.MinLevel <= iLvl)
                            {
                                subOptimalTierDistance++;
                            }
                            break;
                        }
                        break;

                    default:
                        totalTiers++;
                        if (tmp.Equals(Record))
                        {
                            Tier      = totalTiers;
                            tierFound = true;
                        }
                        if (!tierFound && tmp.MinLevel <= iLvl)
                        {
                            subOptimalTierDistance++;
                        }
                        break;
                    }
                    #endregion
                }
            }
            double hue = totalTiers == 1 ? 180 : 120 - Math.Min(subOptimalTierDistance, 3) * 40;
            Color = ColorUtils.ColorFromHsv(hue, totalTiers == 1 ? 0 : 1, 1);
        }