private static string getLootRankWeightFilter(Character character) { StringBuilder wtf = new StringBuilder(); ComparisonCalculationBase[] statValues = CalculationsBase.GetRelativeStatValues(character); foreach (ComparisonCalculationBase ccb in statValues) { string stat = getLootrankStatID(ccb.Name); if (!stat.Equals(string.Empty)) { wtf.Append(stat + "=" + ccb.OverallPoints.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + "&"); } } if (character.CurrentModel == "Enhance") { wtf.Append("s1=2.4&s3=2.4&dps=6&odps=3&"); } if (wtf.Length == 0) { return(string.Empty); } else { return(wtf.ToString()); } }
internal Item[] GetRelevantItemsInternal(CalculationsBase model) { List <Item> itemList = new List <Item>(AllItems).FindAll(new Predicate <Item>( delegate(Item item) { return(model.IsItemRelevant(item) && ItemFilter.IsItemRelevant(model, item)); })); return(itemList.ToArray()); }
public static List <Enchant> FindEnchants(Item.ItemSlot slot, CalculationsBase model) { List <Item.ItemSlot> validSlots = new List <Item.ItemSlot>(); if (slot != Item.ItemSlot.MainHand) { validSlots.Add(slot); } if (slot == Item.ItemSlot.OffHand || slot == Item.ItemSlot.MainHand || slot == Item.ItemSlot.TwoHand) { validSlots.Add(Item.ItemSlot.OneHand); } if (slot == Item.ItemSlot.MainHand) { validSlots.Add(Item.ItemSlot.TwoHand); } return(AllEnchants.FindAll(new Predicate <Enchant>( delegate(Enchant enchant) { return model.HasRelevantStats(enchant.Stats) && (validSlots.Contains(enchant.Slot) || slot == Item.ItemSlot.None) || enchant.Slot == Item.ItemSlot.None; } ))); }
public void LoadRelativeStatValues() { comparisonGraph1.RoundValues = true; comparisonGraph1.CustomRendered = false; comparisonGraph1.ItemCalculations = CalculationsBase.GetRelativeStatValues(Character); comparisonGraph1.EquipSlot = CharacterSlot.None; _characterSlot = CharacterSlot.None; }
public Item[] GetUnfilteredRelevantItems(CalculationsBase model, CharacterRace race) { List <Item> itemList = new List <Item>(AllItems).FindAll(new Predicate <Item>( delegate(Item item) { return(model.IsItemRelevant(item) && item.FitsFaction(race)); })); return(itemList.ToArray()); }
/// <summary> /// Returns a list that can be used to set relevant item types list. Call ItemCache.OnItemsChanged() /// when you finish making changes to the list. /// </summary> public static List <ItemType> GetRelevantItemTypesList(CalculationsBase model) { ItemTypeList list; if (!data.RelevantItemTypes.TryGetValue(model.Name, out list)) { list = new ItemTypeList(model.RelevantItemTypes); data.RelevantItemTypes[model.Name] = list; } return(list); }
public static List <GemmingTemplate> GetModelTemplates(CalculationsBase model) { List <GemmingTemplate> list; if (!AllTemplates.TryGetValue(model.Name, out list)) { list = new List <GemmingTemplate>(model.DefaultGemmingTemplates); AllTemplates[model.Name] = list; } return(list); }
public Item[] GetRelevantItems(CalculationsBase model) { if (model == Calculations.Instance) { return(RelevantItems); } else { return(new List <Item>(AllItems).FindAll(new Predicate <Item>( delegate(Item item) { return model.IsItemRelevant(item); })).ToArray()); } }
public Optimizer.SuffixItem[] GetRelevantSuffixItems(CalculationsBase model, Character character, bool ignoreFilters = false)//CharacterRace race) { if (cachedRelevantSuffixItems == null || model != lastModel || character.Race != lastRace) { lock (syncLock) { // test again because of race conditions, but we still want to avoid the lock if we can because that'll be the majority case if (cachedRelevantSuffixItems == null || model != lastModel || character.Race != lastRace) { CacheRelevantItems(model, character, ignoreFilters); } } } return(cachedRelevantSuffixItems); }
internal Item[] GetRelevantItemsInternal(CalculationsBase model, Character character, bool ignoreFilters = false) { List <Item> itemList = new List <Item>(AllItems).FindAll(new Predicate <Item>( delegate(Item item) { return(model.IsItemRelevant(item) && // Model Relevance (ignoreFilters || ItemFilter.IsItemRelevant(model, item)) && // Filters Relevance (character == null || item.FitsFaction(character.Race)) && // Faction Relevance (character == null || character.ItemMatchesiLvlCheck(item)) && // iLvl check from UI Filter (non-tree) (character == null || character.ItemMatchesBindCheck(item)) && // Bind check from UI Filter (non-tree) (character == null || character.ItemMatchesProfCheck(item)) && // Prof check from UI Filter (non-tree) (character == null || character.ItemMatchesDropCheck(item))); // Drop check from UI Filter (non-tree) })); return(itemList.ToArray()); }
public static bool IsItemRelevant(CalculationsBase model, Item item) { if (GetRelevantItemTypesList(model).Contains(item.Type)) { bool added = false; bool anyMatch = false; bool enabledMatch = false; foreach (ItemFilterRegex regex in data.RegexList) { if (regex.AdditiveFilter && regex.AppliesTo(item) && regex.IsMatch(item)) { anyMatch = true; if (regex.IsEnabled(item)) { enabledMatch = true; break; } } } if (anyMatch) { added = enabledMatch; } else { added = OtherEnabled; } if (added) { foreach (ItemFilterRegex regex in data.RegexList) { if (!regex.AdditiveFilter && regex.Enabled.GetValueOrDefault(true) && regex.AppliesTo(item) && regex.IsMatch(item) && regex.IsEnabled(item)) { return(false); } } return(true); } } return(false); }
private void CacheRelevantItems(CalculationsBase model, Character character, bool ignoreFilters = false) { List <Item> itemList = new List <Item>(AllItems).FindAll(new Predicate <Item>( delegate(Item item) { return(model.IsItemRelevant(item) && // Model Relevance item.FitsFaction(character.Race) && // Faction Relevance (ignoreFilters || ItemFilter.IsItemRelevant(model, item)) && // Filters Relevance character.ItemMatchesiLvlCheck(item) && // iLvl check from UI Filter (non-tree) character.ItemMatchesBindCheck(item) && // Bind check from UI Filter (non-tree) character.ItemMatchesProfCheck(item) && // Prof check from UI Filter (non-tree) character.ItemMatchesDropCheck(item)); // Drop check from UI Filter (non-tree) })); cachedRelevantItems = itemList.ToArray(); List <Optimizer.SuffixItem> suffixItemList = new List <Optimizer.SuffixItem>(); foreach (var item in cachedRelevantItems) { if (item.AllowedRandomSuffixes == null || item.AllowedRandomSuffixes.Count == 0) { suffixItemList.Add(new Optimizer.SuffixItem() { Item = item, RandomSuffixId = 0 }); } else { foreach (var suffix in item.AllowedRandomSuffixes) { suffixItemList.Add(new Optimizer.SuffixItem() { Item = item, RandomSuffixId = suffix }); } } } cachedRelevantSuffixItems = suffixItemList.ToArray(); lastModel = model; lastRace = character.Race; }
private static string getPawnWeightFilter(Character character) { StringBuilder wtf = new StringBuilder(); ComparisonCalculationBase[] statValues = CalculationsBase.GetRelativeStatValues(character); foreach (ComparisonCalculationBase ccb in statValues) { string stat = getPawnStatID(ccb.Name); if (!stat.Equals(string.Empty)) { wtf.Append(stat + "=" + ccb.OverallPoints.ToString("F2", System.Globalization.CultureInfo.InvariantCulture) + ", "); } } if (wtf.Length == 0) { return(string.Empty); } else { return(wtf.ToString().Substring(0, wtf.Length - 2)); // remove trailing comma } }
public Item[] GetRelevantItems(CalculationsBase model, CharacterRace race) { if (cachedRelevantItems == null || model != lastModel || race != lastRace) { lock (syncLock) { // test again because of race conditions, but we still want to avoid the lock if we can because that'll be the majority case if (cachedRelevantItems == null || model != lastModel || race != lastRace) { List <Item> itemList = new List <Item>(AllItems).FindAll(new Predicate <Item>( delegate(Item item) { return(model.IsItemRelevant(item) && ItemFilter.IsItemRelevant(model, item) && item.FitsFaction(race)); })); cachedRelevantItems = itemList.ToArray(); lastModel = model; lastRace = race; } } } return(cachedRelevantItems); }
private void CacheRelevantItems(CalculationsBase model, Character character, bool ignoreFilters = false) { List<Item> itemList = new List<Item>(AllItems).FindAll(new Predicate<Item>( delegate(Item item) { return model.IsItemRelevant(item) // Model Relevance && item.FitsFaction(character.Race) // Faction Relevance && (ignoreFilters || ItemFilter.IsItemRelevant(model, item)) // Filters Relevance && character.ItemMatchesiLvlCheck(item) // iLvl check from UI Filter (non-tree) && character.ItemMatchesBindCheck(item) // Bind check from UI Filter (non-tree) && character.ItemMatchesProfCheck(item) // Prof check from UI Filter (non-tree) && character.ItemMatchesDropCheck(item); // Drop check from UI Filter (non-tree) })); cachedRelevantItems = itemList.ToArray(); List<Optimizer.SuffixItem> suffixItemList = new List<Optimizer.SuffixItem>(); foreach (var item in cachedRelevantItems) { if (item.AllowedRandomSuffixes == null || item.AllowedRandomSuffixes.Count == 0) { suffixItemList.Add(new Optimizer.SuffixItem() { Item = item, RandomSuffixId = 0 }); } else { foreach (var suffix in item.AllowedRandomSuffixes) { suffixItemList.Add(new Optimizer.SuffixItem() { Item = item, RandomSuffixId = suffix }); } } } cachedRelevantSuffixItems = suffixItemList.ToArray(); lastModel = model; lastRace = character.Race; }
public static Item[] GetRelevantItems(CalculationsBase model, Character character, bool ignoreFilters = false) { return(_instance.GetRelevantItems(model, character, ignoreFilters)); }
private void CreateBatchItemGenerator() { bool _overrideRegem = OverrideRegem; bool _overrideReenchant = OverrideReenchant; bool _overrideReforge = OverrideReforge; Character[] characterList = new Character[BatchCharacterList.Count]; CalculationsBase[] modelList = new CalculationsBase[BatchCharacterList.Count]; for (int i = 0; i < BatchCharacterList.Count; i++) { characterList[i] = BatchCharacterList[i].Character; modelList[i] = BatchCharacterList[i].Model; } itemGenerator = new AvailableItemGenerator(BatchCharacterList[0].Character.AvailableItems, optimizer.GreedyOptimizationMethod != GreedyOptimizationMethod.AllCombinations, TemplateGemsEnabled, _overrideRegem, _overrideReenchant, _overrideReforge, false, characterList, modelList); // link items to availability info for (int i = 0; i < BatchCharacterList.Count; i++) { for (int slot = 0; slot < Character.OptimizableSlotCount; slot++) { var item = BatchCharacterList[i].Character._item[slot]; if (item != null) { item.ItemAvailabilityInformation = null; } } } for (int i = 0; i < BatchCharacterList.Count; i++) { for (int slot = 0; slot < Character.OptimizableSlotCount; slot++) { if (slot != (int)CharacterSlot.OffHand || BatchCharacterList[i].Character.CurrentCalculations.IncludeOffHandInCalculations(BatchCharacterList[i].Character)) { var item = BatchCharacterList[i].Character._item[slot]; if (item != null && item.ItemAvailabilityInformation == null) { // find a matching item availability info and assign, prefer blue diamonds // make sure we don't reuse the same item twice on the same character if (item.Item.AvailabilityInformation != null) { foreach (var iai in item.Item.AvailabilityInformation) { if (iai.ItemAvailable.ContainsKey(item.GemmedId)) { bool valid = true; for (int slot2 = 0; slot2 < Character.OptimizableSlotCount; slot2++) { if (slot2 != (int)CharacterSlot.OffHand || BatchCharacterList[i].Character.CurrentCalculations.IncludeOffHandInCalculations(BatchCharacterList[i].Character)) { var item2 = BatchCharacterList[i].Character._item[slot2]; if (item2 != null && item2.ItemAvailabilityInformation == iai) { valid = false; break; } } } if (valid && item.ItemAvailabilityInformation == null || iai.ItemList.Count == 1) { item.ItemAvailabilityInformation = iai; } } } } // reuse the same iai for exact matches in subsequent characters, max one per character for (int j = i + 1; j < BatchCharacterList.Count; j++) { for (int slot2 = 0; slot2 < Character.OptimizableSlotCount; slot2++) { if (slot2 != (int)CharacterSlot.OffHand || BatchCharacterList[j].Character.CurrentCalculations.IncludeOffHandInCalculations(BatchCharacterList[j].Character)) { var item2 = BatchCharacterList[j].Character._item[slot2]; if (item2 != null && item2 == item) { item2.ItemAvailabilityInformation = item.ItemAvailabilityInformation; break; } } } } } } } } // create item restrictions for locked characters for (int i = 0; i < BatchCharacterList.Count; i++) { if (BatchCharacterList[i].Locked) { itemGenerator.AddItemRestrictions(BatchCharacterList[i].Character); } } }
public static Optimizer.SuffixItem[] GetRelevantSuffixItems(CalculationsBase model, Character character) { return(_instance.GetRelevantSuffixItems(model, character)); }
public static List<GemmingTemplate> GetModelTemplates(CalculationsBase model) { List<GemmingTemplate> list; if (!AllTemplates.TryGetValue(model.Name, out list)) { list = new List<GemmingTemplate>(model.DefaultGemmingTemplates); AllTemplates[model.Name] = list; } return list; }
public static List <Tinkering> FindTinkerings(ItemSlot slot, Character character, CalculationsBase model) { //List<ItemSlot> validSlots = new List<ItemSlot>(); //if (slot != ItemSlot.MainHand) // validSlots.Add(slot); //if (slot == ItemSlot.OffHand || slot == ItemSlot.MainHand || slot == ItemSlot.TwoHand) // validSlots.Add(ItemSlot.OneHand); //if (slot == ItemSlot.MainHand) // validSlots.Add(ItemSlot.TwoHand); return(AllTinkerings.FindAll(new Predicate <Tinkering>( delegate(Tinkering Tinkering) { return Tinkering.Slot == ItemSlot.None || model.IsTinkeringRelevant(Tinkering, character) && (slot == ItemSlot.None || Tinkering.FitsInSlot(slot, character)); } ))); }
public static Item[] GetRelevantItems(CalculationsBase model, Character character, bool ignoreFilters = false) { return _instance.GetRelevantItems(model, character, ignoreFilters); }
internal Item[] GetRelevantItemsInternal(CalculationsBase model, Character character, bool ignoreFilters = false) { List<Item> itemList = new List<Item>(AllItems).FindAll(new Predicate<Item>( delegate(Item item) { return model.IsItemRelevant(item) // Model Relevance && (ignoreFilters || ItemFilter.IsItemRelevant(model, item)) // Filters Relevance && (character == null || item.FitsFaction(character.Race)) // Faction Relevance && (character == null || character.ItemMatchesiLvlCheck(item)) // iLvl check from UI Filter (non-tree) && (character == null || character.ItemMatchesBindCheck(item)) // Bind check from UI Filter (non-tree) && (character == null || character.ItemMatchesProfCheck(item)) // Prof check from UI Filter (non-tree) && (character == null || character.ItemMatchesDropCheck(item)); // Drop check from UI Filter (non-tree) })); return itemList.ToArray(); }
public static List <Tinkering> FindTinkerings(ItemSlot slot, Character character, List <string> availableIds, CalculationsBase model) { return(AllTinkerings.FindAll(new Predicate <Tinkering>( delegate(Tinkering Tinkering) { return Tinkering.Id == 0 || ((Tinkering.Slot == ItemSlot.None || model.IsTinkeringRelevant(Tinkering, character) && (slot == ItemSlot.None || Tinkering.FitsInSlot(slot, character))) && availableIds.Contains((-1 * (Tinkering.Id + ((int)AvailableItemIDModifiers.Tinkerings * (int)Tinkering.Slot))).ToString())); } ))); }
public static Item[] GetRelevantItems(CalculationsBase model, CharacterRace race) { return(_instance.GetRelevantItems(model, race)); }
public Item[] GetUnfilteredRelevantItems(CalculationsBase model, CharacterRace race) { List<Item> itemList = new List<Item>(AllItems).FindAll(new Predicate<Item>( delegate(Item item) { return model.IsItemRelevant(item) && item.FitsFaction(race); })); return itemList.ToArray(); }
public static List <Enchant> FindEnchants(Item.ItemSlot slot, List <string> availableIds, CalculationsBase model) { List <Item.ItemSlot> validSlots = new List <Item.ItemSlot>(); if (slot != Item.ItemSlot.MainHand) { validSlots.Add(slot); } if (slot == Item.ItemSlot.OffHand || slot == Item.ItemSlot.MainHand) { validSlots.Add(Item.ItemSlot.OneHand); } if (slot == Item.ItemSlot.MainHand) { validSlots.Add(Item.ItemSlot.TwoHand); } return(AllEnchants.FindAll(new Predicate <Enchant>( delegate(Enchant enchant) { return ((model.HasRelevantStats(enchant.Stats) && (validSlots.Contains(enchant.Slot) || slot == Item.ItemSlot.None) || enchant.Slot == Item.ItemSlot.None) && availableIds.Contains((-1 * (enchant.Id + (10000 * (int)enchant.Slot))).ToString())) || enchant.Id == 0; } ))); }
public Optimizer.SuffixItem[] GetRelevantSuffixItems(CalculationsBase model, Character character, bool ignoreFilters = false)//CharacterRace race) { if (cachedRelevantSuffixItems == null || model != lastModel || character.Race != lastRace) { lock (syncLock) { // test again because of race conditions, but we still want to avoid the lock if we can because that'll be the majority case if (cachedRelevantSuffixItems == null || model != lastModel || character.Race != lastRace) { CacheRelevantItems(model, character, ignoreFilters); } } } return cachedRelevantSuffixItems; }
public void UpdateScalingGraph(Character character, Stats[] statsList, Stats baseStat, bool requiresReferenceCalculations, Color[] colors, int scale, string explanatoryText, string calculation) { CharacterCalculationsBase baseCalc = Calculations.GetCharacterCalculations(character); if (statsList.Length == 0 || statsList.Length > colors.Length) { return; // more than 12 elements for the array would run out of colours } Point[][] points = new Point[statsList.Length][]; // extract property data for relative stats calculations KeyValuePair <PropertyInfo, float>[] properties = new KeyValuePair <PropertyInfo, float> [statsList.Length]; for (int index = 0; index < statsList.Length; index++) { var p = statsList[index].Values(x => x > 0); foreach (var kvp in p) { properties[index] = kvp; } points[index] = new Point[2 * scale + 1]; } float unit = 1f; var bp = baseStat.Values(x => x > 0); foreach (var kvp in bp) { unit = kvp.Value; } Chart.Series.Clear(); for (int count = -scale; count <= scale; count++) { Stats newStats = new Stats(); newStats.Accumulate(baseStat, count); Item item = new Item() { Stats = newStats }; if (requiresReferenceCalculations) { Calculations.GetCharacterCalculations(character, item, true, false, false); } for (int index = 0; index < statsList.Length; index++) { ComparisonCalculationBase currentCalc = CalculationsBase.GetRelativeStatValue(character, properties[index].Key, item, properties[index].Value); float dpsChange = GetCalculationValue(currentCalc, calculation); points[index][count + scale] = new Point(count * unit, dpsChange); } } for (int index = 0; index < statsList.Length; index++) { Style dataPointStyle = new Style(typeof(LineDataPoint)); dataPointStyle.Setters.Add(new Setter(DataPoint.TemplateProperty, Resources["InvisibleDataPointTemplate"])); dataPointStyle.Setters.Add(new Setter(DataPoint.BackgroundProperty, new SolidColorBrush(colors[index]))); Chart.Series.Add(new LineSeries() { Title = statsList[index].ToString(), ItemsSource = points[index], IndependentValuePath = "X", DependentValuePath = "Y", DataPointStyle = dataPointStyle, }); } Chart.Axes.Clear(); Chart.Axes.Add(new LinearAxis() { Orientation = AxisOrientation.X, Title = "Stat Change", ShowGridLines = true, }); Chart.Axes.Add(new LinearAxis() { Orientation = AxisOrientation.Y, Title = calculation, ShowGridLines = true, }); // restore reference calculation if (requiresReferenceCalculations) { Stats newStats = new Stats(); Item item = new Item() { Stats = newStats }; Calculations.GetCharacterCalculations(character, item, true, false, false); } orgDataDirty = true; }
public static Item[] GetUnfilteredRelevantItems(CalculationsBase model, CharacterRace race) { return _instance.GetUnfilteredRelevantItems(model, race); }
public static void LoadModel(CalculationsBase model) { if (Instance != model) { OnModelChanging(); Instance = model; OnModelChanged(); } }
public static Optimizer.SuffixItem[] GetRelevantSuffixItems(CalculationsBase model, Character character) { return _instance.GetRelevantSuffixItems(model, character); }
public static void LoadModel(CalculationsBase model) { OnModelChanging(); Instance = model; OnModelChanged(); }