예제 #1
0
 public AnalyzerSettings.PartyMemberSettings this[string Name]
 {
     get
     {
         AnalyzerSettings.PartyMemberSettings partyMemberSettings = (AnalyzerSettings.PartyMemberSettings)null;
         if (this.mConfiguration.TryGetValue(Name, out partyMemberSettings))
         {
             return(partyMemberSettings);
         }
         return(this == AnalyzerSettings.mDefaultSettings ? AnalyzerSettings.mDefaultMemberSettings.Clone() : AnalyzerSettings.mDefaultSettings[Name]);
     }
 }
예제 #2
0
        public void Run()
        {
            // First run through and compute the effective stats of each item based
            // on the value of the item level consideration setting.
            DebugParallelForEach(mItems.Where(x => !x.Ignore),
                                 item =>
            {
                byte effective_level = item.Item.Level;
                switch (mSettings.LevelConsideration)
                {
                case AnalyzerSettings.ItemLevelConsideration.Current:
                    effective_level = item.Item.Level;
                    break;

                case AnalyzerSettings.ItemLevelConsideration.CurrentRankMaxLevel:
                    effective_level = item.Item.LevelMax;
                    break;

                case AnalyzerSettings.ItemLevelConsideration.FullyMaxed:
                    effective_level = StatCalculator.MaxLevel(
                        StatCalculator.Evolve(item.Item.BaseRarity, SchemaConstants.EvolutionLevel.PlusPlus));
                    break;
                }

                item.NonSynergizedStats = StatCalculator.ComputeStatsForLevel(item.Item.BaseRarity, item.BaseStats, item.MaxStats, effective_level);
                effective_level         = StatCalculator.EffectiveLevelWithSynergy(effective_level);
                item.SynergizedStats    = StatCalculator.ComputeStatsForLevel(item.Item.BaseRarity, item.BaseStats, item.MaxStats, effective_level);
            });

            RealmSynergy.SynergyValue[]      synergy_values  = RealmSynergy.Values.ToArray();
            AnalyzerSettings.DefensiveStat[] defensive_stats = Enum.GetValues(typeof(AnalyzerSettings.DefensiveStat)).Cast <AnalyzerSettings.DefensiveStat>().ToArray();
            AnalyzerSettings.OffensiveStat[] offensive_stats = Enum.GetValues(typeof(AnalyzerSettings.OffensiveStat)).Cast <AnalyzerSettings.OffensiveStat>().ToArray();

            List <AnalysisItem>[,] best_defensive_items = new List <AnalysisItem> [synergy_values.Length, defensive_stats.Length];
            List <AnalysisItem>[,] best_offensive_items = new List <AnalysisItem> [synergy_values.Length, offensive_stats.Length];

            // Sort the item list MxN different ways, once for each combination of (realm,stat)
            DebugParallelForEach(CartesianProduct(synergy_values, defensive_stats),
                                 x =>
            {
                RealmSynergy.SynergyValue synergy   = x.Key;
                AnalyzerSettings.DefensiveStat stat = x.Value;
                List <AnalysisItem> sorted_items    = new List <AnalysisItem>(mItems.Where(y => !y.Ignore));
                sorted_items.Sort((a, b) =>
                {
                    EquipStats a_stats = a.GetEffectiveStats(synergy);
                    EquipStats b_stats = b.GetEffectiveStats(synergy);
                    short a_value      = ChooseDefensiveStat(a_stats, stat);
                    short b_value      = ChooseDefensiveStat(b_stats, stat);
                    return(-a_value.CompareTo(b_value));
                });
                best_defensive_items[(int)synergy.Realm + 1, (int)stat] = sorted_items;
            });

            DebugParallelForEach(CartesianProduct(synergy_values, offensive_stats),
                                 x =>
            {
                RealmSynergy.SynergyValue synergy   = x.Key;
                AnalyzerSettings.OffensiveStat stat = x.Value;
                List <AnalysisItem> sorted_items    = new List <AnalysisItem>(mItems.Where(y => !y.Ignore));
                sorted_items.Sort((a, b) =>
                {
                    EquipStats a_stats = a.GetEffectiveStats(synergy);
                    EquipStats b_stats = b.GetEffectiveStats(synergy);
                    short a_value      = ChooseOffensiveStat(a_stats, stat);
                    short b_value      = ChooseOffensiveStat(b_stats, stat);
                    return(-a_value.CompareTo(b_value));
                });
                best_offensive_items[(int)synergy.Realm + 1, (int)stat] = sorted_items;
            });

            // Compute the top N items for each character.
            DebugParallelForEach(mBuddies.Where(x => x.Settings.Score),
                                 buddy =>
            {
                buddy.TopNDefense = new List <AnalysisItem> [synergy_values.Length, defensive_stats.Length];
                buddy.TopNOffense = new List <AnalysisItem> [synergy_values.Length, offensive_stats.Length];
                for (int x = 0; x < best_defensive_items.GetLength(0); ++x)
                {
                    for (int y = 0; y < best_defensive_items.GetLength(1); ++y)
                    {
                        List <AnalysisItem> best_items = best_defensive_items[x, y];
                        buddy.TopNDefense[x, y]        = best_items.Where(item => item.EnabledUsers.Contains(buddy)).Take(mTopN).ToList();
                    }
                }
                for (int x = 0; x < best_offensive_items.GetLength(0); ++x)
                {
                    for (int y = 0; y < best_offensive_items.GetLength(1); ++y)
                    {
                        List <AnalysisItem> best_items = best_offensive_items[x, y];
                        buddy.TopNOffense[x, y]        = best_items.Where(item => item.EnabledUsers.Contains(buddy)).Take(mTopN).ToList();
                    }
                }
            });

            // Finally, go through each item and assign it a score based on how many times it appears in someone's Top N list.
            DebugParallelForEach(mItems.Where(x => !x.Ignore),
                                 item =>
            {
                bool is_weapon = false;
                switch (item.Item.Type)
                {
                case SchemaConstants.ItemType.Weapon:
                    is_weapon = true;
                    break;

                case SchemaConstants.ItemType.Armor:
                    is_weapon = false;
                    break;

                default:
                    return;
                }

                // In the worst case the item appears 0 times in the top N for any character and any realm.  In the best
                // case it appears somewhere in the top N for every character who can use it, and in every single realm.
                // Furthermore, we weight appearances by their rank, so the max *score* is that value times the best
                // possible rank.
                int usable_by = item.EnabledUsers.Count;
                int max_denormalized_score = mTopN * usable_by * synergy_values.Length;
                int denormalized_score     = 0;
                foreach (AnalysisBuddy buddy in mBuddies.Where(b => b.Settings.Score))
                {
                    AnalyzerSettings.PartyMemberSettings buddy_settings = mSettings[buddy.Buddy.Name];
                    List <AnalysisItem>[,] rank_array = is_weapon ? buddy.TopNOffense : buddy.TopNDefense;
                    int stat_index = is_weapon ? (int)buddy_settings.OffensiveStat : (int)buddy_settings.DefensiveStat;

                    for (int realm = 0; realm < rank_array.GetLength(0); ++realm)
                    {
                        List <AnalysisItem> top_n_for_stat = rank_array[realm, stat_index];
                        int index = top_n_for_stat.IndexOf(item);
                        if (index == -1)
                        {
                            continue;
                        }
                        denormalized_score += top_n_for_stat.Count - index;
                    }
                }
                System.Diagnostics.Debug.Assert(denormalized_score <= max_denormalized_score);
                item.Result.IsValid = true;
                item.Result.Score   = (double)denormalized_score / (double)max_denormalized_score;
                item.Result.Score  *= 100.0;
            });
        }