public DKDPS() { // TODO: Add constructor logic here weap = new Stats(); weap.Strength = 10; weap.CritRating = 500; weapon = new Item("test", ItemQuality.Common, ItemType.OneHandSword, 10101, "icon.bmp", ItemSlot.OneHand, "", false, weap, weap, ItemSlot.None, ItemSlot.None, ItemSlot.None, 100, 200, ItemDamageType.Physical, 3.8f, "Death Knight"); m_char = new Character(); string szXML = System.IO.File.ReadAllText("..\\..\\..\\..\\Rawr\\Rawr.UnitTests\\testdata\\~Test_Rawr4_Unholy2h.xml"); // string szXML = System.IO.File.ReadAllText("..\\..\\..\\..\\Rawr\\Rawr.UnitTests\\testdata\\~Test_Rawr4_Frost2h.xml"); m_char = Character.LoadFromXml(szXML); if (m_char.Class == CharacterClass.Druid) { // This means it didn't load properly. m_char.Class = CharacterClass.DeathKnight; // So a weapon, so we have values in weapon specific abilities. m_char.MainHand = new ItemInstance(weapon, 0, null, null, null, new Enchant(), new Reforging(), new Tinkering()); // Unholy DK m_char.DeathKnightTalents = new DeathKnightTalents("203200000000000000002000000000000000000003310321231031021231.010000001010100000010010000111"); } m_char.CurrentModel = "DPSDK"; }
public DKTANK() { // TODO: Add constructor logic here weap = new Stats(); weap.Strength = 10; weapon = new Item("test", ItemQuality.Common, ItemType.OneHandSword, 10101, "icon.bmp", ItemSlot.OneHand, "", false, weap, weap, ItemSlot.None, ItemSlot.None, ItemSlot.None, 100, 200, ItemDamageType.Physical, 3.8f, "Death Knight"); m_char = new Character(); string szXML = System.IO.File.ReadAllText("..\\..\\..\\..\\Rawr\\Rawr.UnitTests\\testdata\\~Test_Rawr4_Blood2h.xml"); m_char = Character.LoadFromXml(szXML); if (m_char.Class == CharacterClass.Druid) { // This means it didn't load properly. m_char.Class = CharacterClass.DeathKnight; // So a weapon, so we have values in weapon specific abilities. m_char.MainHand = new ItemInstance(weapon, 0, null, null, null, new Enchant(), new Reforging(), new Tinkering()); // Some talents. // Blood Talents. m_char.DeathKnightTalents = new DeathKnightTalents("03322203130022011321000000000000000000000000000000000000000.00000000000000000000000000000"); } m_char.CurrentModel = "TankDK"; if (m_char.BossOptions == null || m_char.BossOptions.Attacks.Count <= 0) { BossList list = new BossList(); BossHandler testboss = new BossHandler(); testboss = list.GetBossFromName("Pit Lord Argaloth"); m_char.BossOptions = new BossOptions(); m_char.BossOptions.CloneThis(testboss); } }
public BasicCharacterTest() { m_char = new Character(); Calculations.RegisterModel(typeof(Rawr.Bear.CalculationsBear)); Calculations.RegisterModel(typeof(Rawr.Cat.CalculationsCat)); Calculations.RegisterModel(typeof(Rawr.DPSDK.CalculationsDPSDK)); Calculations.RegisterModel(typeof(Rawr.DPSWarr.CalculationsDPSWarr)); Calculations.RegisterModel(typeof(Rawr.Elemental.CalculationsElemental)); Calculations.RegisterModel(typeof(Rawr.Enhance.CalculationsEnhance)); Calculations.RegisterModel(typeof(Rawr.Healadin.CalculationsHealadin)); Calculations.RegisterModel(typeof(Rawr.HealPriest.CalculationsHealPriest)); Calculations.RegisterModel(typeof(Rawr.Hunter.CalculationsHunter)); Calculations.RegisterModel(typeof(Rawr.Mage.CalculationsMage)); Calculations.RegisterModel(typeof(Rawr.Moonkin.CalculationsMoonkin)); Calculations.RegisterModel(typeof(Rawr.ProtPaladin.CalculationsProtPaladin)); Calculations.RegisterModel(typeof(Rawr.ProtWarr.CalculationsProtWarr)); Calculations.RegisterModel(typeof(Rawr.RestoSham.CalculationsRestoSham)); Calculations.RegisterModel(typeof(Rawr.Retribution.CalculationsRetribution)); Calculations.RegisterModel(typeof(Rawr.Rogue.CalculationsRogue)); Calculations.RegisterModel(typeof(Rawr.ShadowPriest.CalculationsShadowPriest)); Calculations.RegisterModel(typeof(Rawr.TankDK.CalculationsTankDK)); Calculations.RegisterModel(typeof(Rawr.Tree.CalculationsTree)); Calculations.RegisterModel(typeof(Rawr.Warlock.CalculationsWarlock)); }
// public static void MyClassInitialize(TestContext testContext) { } // [SetUp] public void Setup() { _character = new Character { Class = CharacterClass.Priest, }; SetupCharacter(_character); }
public static string GetLootRankURL(Character character) { StringBuilder lootrank = new System.Text.StringBuilder(); lootrank.Append("http://www.lootrank.com/wow/wr.asp?"); // add URL header lootrank.Append(getLootRankClassAndArmour(character.Class)); lootrank.Append("Max=10&n1=1&i4=0&Gem=3&"); // Gem=3 rare Gem=4 epic change when new epic gems available lootrank.Append("maxlv=" + character.Level + "&"); lootrank.Append(getLootRankWeightFilter(character)); return lootrank.ToString(); }
public static void CopyPawnString(Character character) { StringBuilder pawn = new System.Text.StringBuilder(); pawn.Append("( Pawn: v1: \"Rawr\": "); // adds pawn header pawn.Append(getPawnWeightFilter(character)); pawn.AppendLine(" )"); // adds pawn footer try { Clipboard.SetText(pawn.ToString()); } catch { } }
/// <summary> /// Generate a graph to compare stat progressions. /// </summary> /// <param name="character"></param> /// <param name="statsList">Array of Stats objects that contain what stats to evalutate.</param> /// <param name="colors">Color for each stat object. Should be same or > # of elements as statsList</param> /// <param name="scale">How many increments of the stats values should be performed? Larger values mean much larger calculation times.</param> /// <param name="explanatoryText"></param> /// <param name="calculation">[In] Generally pass in null or "Overall Points" otherwise pass in the specific subpoint string you are concerned about.</param> public void UpdateStatsGraph(Character character, Stats[] statsList, Color[] colors, int scale, string explanatoryText, string calculation) { CharacterCalculationsBase baseCalc = Calculations.GetCharacterCalculations(character); float baseFigure = GetCalculationValue(baseCalc, calculation); 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][]; Chart.Series.Clear(); for (int index = 0; index < statsList.Length; index++) { Stats newStats = new Stats(); points[index] = new Point[2 * scale + 1]; newStats.Accumulate(statsList[index], -scale - 1); for (int count = -scale; count <= scale; count++) { newStats.Accumulate(statsList[index]); CharacterCalculationsBase currentCalc = Calculations.GetCharacterCalculations(character, new Item() { Stats = newStats }, false, false, false); float currentFigure = GetCalculationValue(currentCalc, calculation); float dpsChange = currentFigure - baseFigure; points[index][count + scale] = new Point(count, dpsChange); } 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, }); orgDataDirty = true; }
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(); }
public void SetupStatsGraph(Character character, Stats[] statsList, int scale, string explanatoryText, string calculation) { Chart.Title = "Graph of " + calculation; Color[] colors = new Color[] { Color.FromArgb(255,202,180,096), Color.FromArgb(255,101,225,240), Color.FromArgb(255,000,004,003), Color.FromArgb(255,238,238,030), Color.FromArgb(255,045,112,063), Color.FromArgb(255,121,072,210), Color.FromArgb(255,217,100,054), Color.FromArgb(255,210,072,195), Color.FromArgb(255,206,189,191), Color.FromArgb(255,255,000,000), Color.FromArgb(255,000,255,000), Color.FromArgb(255,000,000,255), Color.FromArgb(255,000,000,175), }; UpdateStatsGraph(character, statsList, colors, scale, explanatoryText, calculation); }
public void Render(Character character, System.Drawing.Graphics g, int width, int height) { //MinimumX = -1000; MaximumX = 1000; GranularityX = 2; Width = width - 16; Height = height - 24; MinimumY = MaximumY = 0f; string[] rotations; float[] graphData = BuildGraphData(character, out MinimumY, out MaximumY, out rotations); MinimumY = 0f;//(float)Math.Floor(MinimumY / 10f) * 10f; MaximumY = 5f;//(float)Math.Ceiling(MaximumY / 10f) * 10f; //RangeX = MaximumX - MinimumX; //RangeY = MaximumY - MinimumY; ConversionX = (width - 16f) / (MaximumX - MinimumX); ConversionY = (height - 24f) / (MaximumY - MinimumY); PointF[] points = new PointF[graphData.Length + 2]; points[0] = GetScreenPoint(MinimumX, 0); points[points.Length - 1] = GetScreenPoint(MaximumX, 0); byte[] types = new byte[points.Length]; types[0] = (byte)PathPointType.Start; types[types.Length - 1] = (byte)PathPointType.Line; float x = 0, integralY = 0f; for (int i = 1; i <= graphData.Length; i++) { x = MinimumX + (float)(i - 1) / (float)GranularityX; integralY = 0f; if (i < graphData.Length - 1) integralY = (graphData[i] - graphData[i - 1]); points[i] = GetScreenPoint(x, integralY); types[i] = (byte)PathPointType.Line; } GraphicsPath pathData = new GraphicsPath(points, types, FillMode.Winding); g.FillPath(BrushStat, pathData); g.DrawPath(PenStat, pathData); }
public static Optimizer.SuffixItem[] GetRelevantSuffixItems(CalculationsBase model, Character character) { return _instance.GetRelevantSuffixItems(model, character); }
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 Item[] GetRelevantItems(CalculationsBase model, Character character, bool ignoreFilters = false) { return _instance.GetRelevantItems(model, character, ignoreFilters); }
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 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 OptimizerResults(Character before, Character after, bool talents) { _before = before.Clone(); _after = after.Clone(); _talents = talents; }
public static Character LoadFromXml(string xml) { Character character; if (!string.IsNullOrEmpty(xml)) { try { xml = xml.Replace("<Region>en", "<Region>US").Replace("<Weapon>", "<MainHand>").Replace("</Weapon>", "</MainHand>") .Replace("<Idol>", "<Ranged>").Replace("</Idol>", "</Ranged>").Replace("<WeaponEnchant>", "<MainHandEnchant>").Replace("</WeaponEnchant>", "</MainHandEnchant>") .Replace("HolyPriest", "HealPriest") .Replace("T7_0", "T11_10").Replace("T8_0", "T11_10").Replace("T9_0", "T11_10").Replace("T10_0", "T11_10") .Replace("T7_5", "T11_10").Replace("T8_5", "T11_10").Replace("T9_5", "T11_10").Replace("T10_5", "T11_10") .Replace("T7_9", "T11_10").Replace("T8_9", "T11_10").Replace("T9_9", "T11_10").Replace("T10_9", "T11_10") .Replace("T11_0", "T11_10").Replace("T11_5", "T11_10").Replace("T11_9", "T11_10") .Replace("<Attack xsi:type=\"DoT\">", "<Attack>"); if (xml.IndexOf("<CalculationOptions>") != xml.LastIndexOf("<CalculationOptions>")) { xml = xml.Substring(0, xml.IndexOf("<CalculationOptions>")) + xml.Substring(xml.LastIndexOf("</CalculationOptions>") + "</CalculationOptions>".Length); } System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Character)); System.IO.StringReader reader = new System.IO.StringReader(xml); character = (Character)serializer.Deserialize(reader); character.IsLoading = false; // decode non-english characters for name and realm if (!String.IsNullOrEmpty(character.Name)) { character.Name = Uri.UnescapeDataString(character.Name); } // Realm is now not correctly encoded by rawr4 character-loading proxy, but it will work fine in future, I think. if (!String.IsNullOrEmpty(character.Realm)) { //character.Realm = Encoding. UnicodeEncoding.Convert(Encoding.UTF8, Encoding.Unicode, character.Realm.ToCharArray()); character.Realm = Uri.UnescapeDataString(character.Realm); } character._activeBuffs = new List<Buff>(character._activeBuffsXml.ConvertAll(buff => Buff.GetBuffByName(buff))); character._activeBuffs.RemoveAll(buff => buff == null); // remove all set bonuses, they should no longer be in active buffs character._activeBuffs.RemoveAll(buff => !string.IsNullOrEmpty(buff.SetName)); character.itemSetList = new ItemSetList(character._itemSetListXML.ConvertAll(itemset => ItemSet.GenerateItemSetFromSavedString(itemset))); character.itemSetList.RemoveAll(ItemSet => ItemSet == null); character.ArmoryPets = new List<ArmoryPet>(character.ArmoryPetsXml.ConvertAll(armoryPet => ArmoryPet.GetPetByString(armoryPet))); character.RecalculateSetBonuses(); // now you can call it foreach (ItemInstance item in character.CustomItemInstances) { item.ForceDisplay = true; } for (int i = 0; i < character.AvailableItems.Count; i++) { // breaking compatibility with 2.0 characters with version 4.0.20 // assume all available items at this point are single id green diamonds // or full 7 id gemmed id without random suffix // convert gemmed ids to include random suffix bool dirty = false; string item = character.AvailableItems[i]; string[] ids = item.Split('.'); if (ids.Length == 7) { string[] nids = new string[] { ids[0], "0", ids[1], ids[2], ids[3], ids[4], ids[5], ids[6] }; item = string.Join(".", nids); dirty = true; } if (dirty) { character.AvailableItems[i] = item; } } reader.Close(); } catch (Exception ex) { #if !RAWR3 && !RAWR4 Log.Show("There was an error attempting to open this character. Most likely, it was saved with a previous version of Rawr, and isn't upgradable to the new format. Sorry. Please load your character from the armory to begin."); #endif new Base.ErrorBox() { Title = "Error Generating Character from XML", Function = "Character.LoadFromXML(...)", TheException = ex, }.Show(); character = new Character() { IsLoading = false }; } } else character = new Character() { IsLoading = false }; return character; }
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 void SetItems(Character character, bool allSlots, bool invalidate) { int max = allSlots ? SlotCount : OptimizableSlotCount; for (int slot = 0; slot < max; slot++) { _item[slot] = character._item[slot] == null ? null : character._item[slot].Clone(); } // when called from optimizer we never want to invalidate since that causes creation of new item instances // and causes us to lose stats cache if (invalidate) { OnCalculationsInvalidated(); } }
public static bool ValidateArmorSpecialization(Character source, ItemType i) { // Null Check if (source == null) { return false; } // Item Type Fails if (source.Head == null || source.Head.Type != i) { return false; } if (source.Shoulders == null || source.Shoulders.Type != i) { return false; } if (source.Chest == null || source.Chest.Type != i) { return false; } if (source.Wrist == null || source.Wrist.Type != i) { return false; } if (source.Hands == null || source.Hands.Type != i) { return false; } if (source.Waist == null || source.Waist.Type != i) { return false; } if (source.Legs == null || source.Legs.Type != i) { return false; } if (source.Feet == null || source.Feet.Type != i) { return false; } // If it hasn't failed by now, it must be good return true; }
private float[] BuildGraphData(Character character, out float minY, out float maxY, out string[] rotations) { minY = float.MaxValue; maxY = 0f; float[] overallData = new float[(MaximumX - MinimumX) * GranularityX + 1]; rotations = new string[overallData.Length]; Item itemStats = new Item() { Stats = new Stats() }; PropertyInfo propertyX = typeof(Stats).GetProperty(StatX); float y, x; for (int i = 0; i < overallData.Length; i++) { try { x = MinimumX + (float)i / (float)GranularityX; propertyX.SetValue(itemStats.Stats, x, null); CharacterCalculationsBase calcs = Calculations.GetCharacterCalculations(character, itemStats, false, true, false); y = calcs.OverallPoints; //rotations[i] = calcs.GetCharacterDisplayCalculationValues()["Optimal Rotation"]; overallData[i] = y; minY = Math.Min(minY, y); maxY = Math.Max(maxY, y); } catch (Exception ex) { ex.ToString(); } } return overallData; }
/// <summary> /// Implement this method to setup the character in whatever way needs to be tested /// </summary> /// <param name="character">The character.</param> protected abstract void SetupCharacter(Character character);
public void AssignAllTalentsFromCharacter(Character character, bool clone) { if (clone) { WarriorTalents = (WarriorTalents)character.WarriorTalents.Clone(); PaladinTalents = (PaladinTalents)character.PaladinTalents.Clone(); HunterTalents = (HunterTalents)character.HunterTalents.Clone(); RogueTalents = (RogueTalents)character.RogueTalents.Clone(); PriestTalents = (PriestTalents)character.PriestTalents.Clone(); ShamanTalents = (ShamanTalents)character.ShamanTalents.Clone(); MageTalents = (MageTalents)character.MageTalents.Clone(); WarlockTalents = (WarlockTalents)character.WarlockTalents.Clone(); DruidTalents = (DruidTalents)character.DruidTalents.Clone(); DeathKnightTalents = (DeathKnightTalents)character.DeathKnightTalents.Clone(); } else { _warriorTalents = character._warriorTalents; _paladinTalents = character._paladinTalents; _hunterTalents = character._hunterTalents; _rogueTalents = character._rogueTalents; _priestTalents = character._priestTalents; _shamanTalents = character._shamanTalents; _mageTalents = character._mageTalents; _warlockTalents = character._warlockTalents; _druidTalents = character._druidTalents; _deathKnightTalents = character._deathKnightTalents; } }
/// <summary>This overload is used from optimizer and is optimized for performance, do not modify</summary> public Character(Character baseCharacter, object[] items, int count) { IsLoading = true; _name = baseCharacter._name; _realm = baseCharacter._realm; _region = baseCharacter._region; _race = baseCharacter._race; _currentModel = baseCharacter._currentModel; _calculationOptions = baseCharacter._calculationOptions; _primaryProfession = baseCharacter._primaryProfession; _secondaryProfession = baseCharacter._secondaryProfession; _class = baseCharacter._class; AssignAllTalentsFromCharacter(baseCharacter, false); CalculationToOptimize = baseCharacter.CalculationToOptimize; OptimizationRequirements = baseCharacter.OptimizationRequirements; _bossOptions = baseCharacter._bossOptions; _faction = baseCharacter._faction; _item = new ItemInstance[SlotCount]; Array.Copy(items, _item, count); IsLoading = false; ActiveBuffs = new List<Buff>(baseCharacter.ActiveBuffs); RecalculateSetBonuses(); }
public void LoadAvailablePrerequisiteItemCost(string token, Character character) { foreach (Item item in AllItems) { item.Cost = 0.0f; foreach (var li in item.LocationInfo) { if (li.Source == ItemSource.Vendor) { VendorItem vendor = li as VendorItem; int count; if (vendor.TokenMap.TryGetValue(token, out count)) { // determine if the other prerequisites are available bool valid = true; foreach (var t in vendor.TokenMap) { if (t.Key != token) { // we have the name of the lower level item // find this item var pitem = AllItems.Find(i => i.Name == t.Key && i.ItemLevel < item.ItemLevel); if (pitem != null) { // is it available if (character.GetItemAvailability(new ItemInstance(pitem, 0, null, null, null, null, null, null)) == ItemAvailability.NotAvailable) { valid = false; break; } } } } if (valid) { item.Cost = count; } } } } } // don't need to invalidate relevant caches, but still trigger event to refresh graphs etc. if (ItemsChanged != null) ItemsChanged(null, null); }
public void SetItems(Character character) { SetItems(character, false, true); }
public static void LoadAvailablePrerequisiteItemCost(string token, Character character) { _instance.LoadAvailablePrerequisiteItemCost(token, character); }
void _optimizer_EvaluateUpgradeCompleted(object sender, EvaluateUpgradeCompletedEventArgs e) { switch (currentOperation) { case AsyncOperation.BuildUpgradeList: upgradeListEnumerator.Current.Value += e.UpgradeValue * CurrentBatchCharacter.Weight; upgradeListEnumerator.Current.ValueList.Add(e.UpgradeValue); if (upgradeListEnumerator.MoveNext()) { EvaluateUpgradeCurrentBatchCharacter(false); } else { do { batchIndex++; } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null); if (batchIndex < BatchCharacterList.Count) { upgradeListEnumerator = GetUpgradeListEnumerator(); upgradeListEnumerator.MoveNext(); EvaluateUpgradeCurrentBatchCharacter(true); } else { currentOperation = AsyncOperation.None; UpdateStatusLabel(); if (OperationCompleted != null) { OperationCompleted(this, EventArgs.Empty); } float totalValue = 0f; foreach (BatchCharacter batchCharacter in BatchCharacterList) { if (batchCharacter.Character != null) { totalValue += batchCharacter.Weight; } } Dictionary<CharacterSlot, List<ComparisonCalculationUpgrades>> upgrades = new Dictionary<CharacterSlot, List<ComparisonCalculationUpgrades>>(); foreach (var kvp in upgradeList) { Dictionary<string, UpgradeEntry> filtered = new Dictionary<string, UpgradeEntry>(); foreach (UpgradeEntry entry in kvp.Value.Values) { UpgradeEntry existingEntry; filtered.TryGetValue(entry.Item.SuffixId, out existingEntry); if (entry.Value > 0 && (existingEntry == null || entry.Value > existingEntry.Value)) { filtered[entry.Item.SuffixId] = entry; } } upgrades[kvp.Key] = new List<ComparisonCalculationUpgrades>(); foreach (UpgradeEntry entry in filtered.Values) { ComparisonCalculationUpgrades itemCalc = new ComparisonCalculationUpgrades(); itemCalc.ItemInstance = entry.Item; itemCalc.CharacterItems = null; itemCalc.Name = entry.Item.Name; itemCalc.Equipped = false; itemCalc.OverallPoints = entry.Value / totalValue; itemCalc.SubPoints = entry.ValueList.ToArray(); upgrades[kvp.Key].Add(itemCalc); } } List<string> customSubpoints = new List<string>(); foreach (BatchCharacter batchCharacter in BatchCharacterList) { customSubpoints.Add(batchCharacter.Name); } Upgrades = upgrades; CustomSubpoints = customSubpoints.ToArray(); if (UpgradeListCompleted != null) { UpgradeListCompleted(this, EventArgs.Empty); } } } break; case AsyncOperation.BuildProgressiveUpgradeList: if (e.Cancelled || e.Error != null) { currentOperation = AsyncOperation.None; UpdateStatusLabel(); if (OperationCompleted != null) { OperationCompleted(this, EventArgs.Empty); } break; } CharacterSlot slot = Character.GetCharacterSlotByItemSlot(optimizedItemInstance.Slot); Dictionary<string, UpgradeEntry> map; if (!upgradeList.TryGetValue(slot, out map)) { map = new Dictionary<string, UpgradeEntry>(); upgradeList[slot] = map; } string key = optimizedItemInstance.SuffixId; UpgradeEntry upgradeEntry; if (!map.TryGetValue(key, out upgradeEntry)) { upgradeEntry = new UpgradeEntry(); upgradeEntry.Item = optimizedItemInstance; map[key] = upgradeEntry; } if (e.UpgradeValue > 0) { // make item restrictions based on best character itemGenerator.AddItemRestrictions(e.Upgrade.CharacterItems, workingCharacter.CurrentCalculations.IncludeOffHandInCalculations(workingCharacter)); upgradeEntry.Value += e.UpgradeValue * CurrentBatchCharacter.Weight; upgradeEntry.ValueList.Add(e.UpgradeValue); } else { // make item restrictions based on best character without using the item itemGenerator.AddItemRestrictions(workingCharacter); upgradeEntry.ValueList.Add(0.0f); } // move to next character do { batchIndex++; } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null); if (batchIndex < BatchCharacterList.Count) { // we made item restrictions, first we have to optimize character without the item int _thoroughness = Thoroughness; workingCharacter = CurrentBatchCharacter.Character.Clone(); // regularize character with current item restrictions itemGenerator.RegularizeCharacter(workingCharacter); optimizer.InitializeItemCache(workingCharacter, CurrentBatchCharacter.Model, itemGenerator); optimizer.OptimizeCharacterAsync(workingCharacter, _thoroughness, true); } else { // we finished all characters for this item // move to next item itemIndex++; if (itemIndex < itemList.Length) { batchIndex = 0; upgradeListPhase = 0; int _thoroughness = Thoroughness; // we have to reinitialize item generator because of the restrictions we made //CreateBatchItemGenerator(); itemGenerator.RestoreAvailabilityInformation(); optimizer.InitializeItemCache(CurrentBatchCharacter.Character, CurrentBatchCharacter.Model, itemGenerator); workingCharacter = CurrentBatchCharacter.Character; optimizer.ComputeUpgradesAsync(CurrentBatchCharacter.Character, _thoroughness, itemList[itemIndex]); } else { // we're done WrapUpProgressiveUpgradeList(); } } break; } }
protected override void SetupCharacter(Character character) { TestItemSets.LoadItemSet2(character); TestTalentSets.LoadSuggested(character.PriestTalents); }
public Character Clone() { ItemInstance[] clonedItemInstances = new ItemInstance[SlotCount]; for (int i = 0; i < clonedItemInstances.Length; i++) { ItemInstance itemInstance = _item[i]; if (itemInstance != null) clonedItemInstances[i] = itemInstance.Clone(); } Character clone = new Character(this.Name, this.Realm, this.Region, this.Race, this.BossOptions.Clone(), clonedItemInstances, ActiveBuffs, CurrentModel); clone.CalculationOptions = this.CalculationOptions; clone.itemSetList = this.itemSetList; clone.Class = this.Class; clone.AssignAllTalentsFromCharacter(this, true); clone.PrimaryProfession = this.PrimaryProfession; clone.SecondaryProfession = this.SecondaryProfession; clone.WaistBlacksmithingSocketEnabled = this.WaistBlacksmithingSocketEnabled; clone.WristBlacksmithingSocketEnabled = this.WristBlacksmithingSocketEnabled; clone.HandsBlacksmithingSocketEnabled = this.HandsBlacksmithingSocketEnabled; clone.OptimizationRequirements = this.OptimizationRequirements; clone.CalculationToOptimize = this.CalculationToOptimize; clone.BossOptions = this.BossOptions.Clone(); return clone; }