private void RecomputeAllItemStats() { foreach (DataGridViewRow row in dataGridViewEquipment.Rows) { DataEquipmentInformation equipment = row.Tag as DataEquipmentInformation; if (equipment == null) { continue; } GridEquipStats stats = ComputeDisplayStats(equipment); SetStatsForRow(row, equipment, stats); } ResortByCurrentlySortedColumn(); }
void UpdateEquipmentGrid(DataEquipmentInformation[] EquipList) { int filterTypeLowerBound; int filterTypeUpperBound; if (comboBoxFilterType.SelectedIndex.Equals((int)ViewFilterTypeComboIndex.All)) { filterTypeLowerBound = 0; //If "All" filter selected, select all item types (specifically those within index range 0-99). filterTypeUpperBound = 99; } else //If any other filter selected, set upper and lower bound of item types to that specific type. { filterTypeLowerBound = comboBoxFilterType.SelectedIndex; filterTypeUpperBound = comboBoxFilterType.SelectedIndex; } mEquipments = EquipList; dataGridViewEquipment.Rows.Clear(); foreach (DataEquipmentInformation equip in EquipList) { //If "All" selected, chooses all item types from 0-99, if "Weapon" is selected, chooses item types in range 1-1 (i.e. =1). if (((int)equip.Type >= filterTypeLowerBound) && ((int)equip.Type <= filterTypeUpperBound) && (equip.Category != SchemaConstants.EquipmentCategory.ArmorUpgrade) && //Exclude Armour upgrade mats from "Armour" filter. (equip.Category != SchemaConstants.EquipmentCategory.WeaponUpgrade)) //Exclude Weapon upgrade mats from "Weapon" filter. { int row_index = dataGridViewEquipment.Rows.Add(); DataGridViewRow row = dataGridViewEquipment.Rows[row_index]; row.Tag = equip; row.Cells[dgcItemID.Name].Value = equip.EquipmentId; row.Cells[dgcItem.Name].Value = equip.Name; row.Cells[dgcCategory.Name].Value = equip.Category; row.Cells[dgcType.Name].Value = equip.Type; row.Cells[dgcRarity.Name].Value = new RarityColumnValue((int)equip.BaseRarity, (int)equip.EvolutionNumber); row.Cells[dgcSynergy.Name].Value = new SynergyColumnValue(RealmSynergy.FromSeries(equip.SeriesId)); row.Cells[dgcLevel.Name].Value = new LevelColumnValue(equip.Level, equip.LevelMax); row.Cells[dgcAugments.Name].Value = new AugmentColumnValue(equip.Augment, equip.AugmentMax); if (mAnalyzer != null) { row.Cells[dgcScore.Name].Value = new ScoreColumnValue(mAnalyzer.GetScore(equip.InstanceId)); } GridEquipStats stats = ComputeDisplayStats(equip); SetStatsForRow(row, equip, stats); } } }
void UpdateEquipmentGrid(DataEquipmentInformation[] EquipList) { mEquipments = EquipList; dataGridViewEquipment.Rows.Clear(); foreach (DataEquipmentInformation equip in EquipList) { int row_index = dataGridViewEquipment.Rows.Add(); DataGridViewRow row = dataGridViewEquipment.Rows[row_index]; row.Tag = equip; row.Cells[dgcItemID.Name].Value = equip.EquipmentId; row.Cells[dgcItem.Name].Value = equip.Name; row.Cells[dgcCategory.Name].Value = equip.Category; row.Cells[dgcType.Name].Value = equip.Type; row.Cells[dgcRarity.Name].Value = new RarityColumnValue((int)equip.BaseRarity, (int)equip.EvolutionNumber); row.Cells[dgcSynergy.Name].Value = new SynergyColumnValue(RealmSynergy.FromSeries(equip.SeriesId)); row.Cells[dgcLevel.Name].Value = new LevelColumnValue(equip.Level, equip.LevelMax); row.Cells[dgcScore.Name].Value = new ScoreColumnValue(mAnalyzer.GetScore(equip.InstanceId)); GridEquipStats stats = ComputeDisplayStats(equip); SetStatsForRow(row, equip, stats); } }
private GridEquipStats ComputeDisplayStats(DataEquipmentInformation equip) { ViewUpgradeModeComboIndex upgrade_type = (ViewUpgradeModeComboIndex)comboBoxUpgradeMode.SelectedIndex; RealmSynergy.SynergyValue synergy = RealmSynergy.Values.ElementAt(comboBoxSynergy.SelectedIndex); bool has_synergy = equip.SeriesId == synergy.GameSeries; DataCache.Items.Key cache_key = new DataCache.Items.Key { ItemId = equip.EquipmentId }; DataCache.Items.Data cache_value; bool in_cache = FFRKProxy.Instance.Cache.Items.TryGetValue(cache_key, out cache_value); GridEquipStats result = new GridEquipStats(); if (upgrade_type == ViewUpgradeModeComboIndex.CurrentUpgradeCurrentLevel) { result.Stats.Atk = (has_synergy) ? equip.SeriesAtk : equip.Atk; result.Stats.Mag = (has_synergy) ? equip.SeriesMag : equip.Mag; result.Stats.Acc = (has_synergy) ? equip.SeriesAcc : equip.Acc; result.Stats.Def = (has_synergy) ? equip.SeriesDef : equip.Def; result.Stats.Res = (has_synergy) ? equip.SeriesRes : equip.Res; result.Stats.Eva = (has_synergy) ? equip.SeriesEva : equip.Eva; result.Stats.Mnd = (has_synergy) ? equip.SeriesMnd : equip.Mnd; result.Level = equip.Level; result.MaxLevel = equip.LevelMax; if (equip.SeriesId == synergy.GameSeries) { result.Level = StatCalculator.EffectiveLevelWithSynergy(result.Level); } } else { if (upgrade_type == ViewUpgradeModeComboIndex.CurrentUpgradeMaxLevel) { result.MaxLevel = StatCalculator.MaxLevel(equip.Rarity); } else if (upgrade_type == ViewUpgradeModeComboIndex.MaxLevelThroughExistingCombine) { // Valid candidates for combining items into this are only those items with matching // equipment id and rarity LESS THAN OR EQUAL TO current item's rarity int candidates = mEquipments.Count(x => x.EquipmentId == equip.EquipmentId && x.InstanceId != equip.InstanceId && x.Rarity <= equip.Rarity); result.MaxLevel = StatCalculator.MaxLevel(StatCalculator.EvolveAsMuchAsPossible(equip.BaseRarity, equip.Rarity, candidates)); } else { result.MaxLevel = StatCalculator.MaxLevel(StatCalculator.Evolve(equip.BaseRarity, SchemaConstants.EvolutionLevel.PlusPlus)); } result.Level = result.MaxLevel; if (has_synergy) { result.Level = StatCalculator.EffectiveLevelWithSynergy(result.Level); } if (in_cache && cache_value.AreStatsValid) { // Try to get the equipment stats from the database result.Stats.Atk = StatCalculator.ComputeStatForLevel(equip.BaseRarity, cache_value.BaseStats.Atk, cache_value.MaxStats.Atk, result.Level); result.Stats.Mag = StatCalculator.ComputeStatForLevel(equip.BaseRarity, cache_value.BaseStats.Mag, cache_value.MaxStats.Mag, result.Level); result.Stats.Acc = StatCalculator.ComputeStatForLevel(equip.BaseRarity, cache_value.BaseStats.Acc, cache_value.MaxStats.Acc, result.Level); result.Stats.Def = StatCalculator.ComputeStatForLevel(equip.BaseRarity, cache_value.BaseStats.Def, cache_value.MaxStats.Def, result.Level); result.Stats.Res = StatCalculator.ComputeStatForLevel(equip.BaseRarity, cache_value.BaseStats.Res, cache_value.MaxStats.Res, result.Level); result.Stats.Eva = StatCalculator.ComputeStatForLevel(equip.BaseRarity, cache_value.BaseStats.Eva, cache_value.MaxStats.Eva, result.Level); result.Stats.Mnd = StatCalculator.ComputeStatForLevel(equip.BaseRarity, cache_value.BaseStats.Mnd, cache_value.MaxStats.Mnd, result.Level); } else { // If they aren't there, fall back to trying to compute effective stats from the ifnormation in the JSON. This will lead to some // rounding error due to the fact that the values for Atk and SeriesAtk etc are all rounded, so the division will be less precise // than doing it over the entire range of Max stats and base stats, but it's the best we can do in this case. byte series_effective_level = StatCalculator.EffectiveLevelWithSynergy(equip.Level); result.Stats.Atk = (result.MaxLevel == equip.Level) ? ((has_synergy) ? equip.SeriesAtk : equip.Atk) : StatCalculator.ComputeStatForLevel2(equip.Atk, equip.Level, equip.SeriesAtk, series_effective_level, result.Level); result.Stats.Mag = (result.MaxLevel == equip.Level) ? ((has_synergy) ? equip.SeriesMag : equip.Mag) : StatCalculator.ComputeStatForLevel2(equip.Mag, equip.Level, equip.SeriesMag, series_effective_level, result.Level); result.Stats.Acc = (result.MaxLevel == equip.Level) ? ((has_synergy) ? equip.SeriesAcc : equip.Acc) : StatCalculator.ComputeStatForLevel2(equip.Acc, equip.Level, equip.SeriesAcc, series_effective_level, result.Level); result.Stats.Def = (result.MaxLevel == equip.Level) ? ((has_synergy) ? equip.SeriesDef : equip.Def) : StatCalculator.ComputeStatForLevel2(equip.Def, equip.Level, equip.SeriesDef, series_effective_level, result.Level); result.Stats.Res = (result.MaxLevel == equip.Level) ? ((has_synergy) ? equip.SeriesRes : equip.Res) : StatCalculator.ComputeStatForLevel2(equip.Res, equip.Level, equip.SeriesRes, series_effective_level, result.Level); result.Stats.Eva = (result.MaxLevel == equip.Level) ? ((has_synergy) ? equip.SeriesEva : equip.Eva) : StatCalculator.ComputeStatForLevel2(equip.Eva, equip.Level, equip.SeriesEva, series_effective_level, result.Level); result.Stats.Mnd = (result.MaxLevel == equip.Level) ? ((has_synergy) ? equip.SeriesMnd : equip.Mnd) : StatCalculator.ComputeStatForLevel2(equip.Mnd, equip.Level, equip.SeriesMnd, series_effective_level, result.Level); } } if (equip.AugmentStat != null && equip.Augment > 0) { double bonus = (has_synergy) ? equip.Augment * 1.5 : (double)equip.Augment; System.Reflection.FieldInfo augmentField = typeof(EquipStats).GetField(equip.AugmentStat); short val = (short)augmentField.GetValue(result.Stats); augmentField.SetValue(result.Stats, (short)Math.Ceiling(val + bonus)); } return(result); }
private void SetStatsForRow(DataGridViewRow row, DataEquipmentInformation actual_stats, GridEquipStats display_stats) { SetStatForCell(row, dgcLevel, new LevelColumnValue(actual_stats.Level, actual_stats.LevelMax), new LevelColumnValue(display_stats.Level, display_stats.MaxLevel)); SetStatForCell(row, dgcATK, actual_stats.Atk, display_stats.Stats.Atk); SetStatForCell(row, dgcMAG, actual_stats.Mag, display_stats.Stats.Mag); SetStatForCell(row, dgcMND, actual_stats.Mnd, display_stats.Stats.Mnd); SetStatForCell(row, dgcDEF, actual_stats.Def, display_stats.Stats.Def); SetStatForCell(row, dgcRES, actual_stats.Res, display_stats.Stats.Res); }