Exemplo n.º 1
0
        private void NameGrid_MouseEnter(object sender, MouseEventArgs e)
        {
            ComparisonCalculationBase calc = ((Grid)sender).Tag as ComparisonCalculationBase;

            if ((calc.Description != null || calc.ItemInstance != null || calc.Item != null) && (!ContextMenuService.GetContextMenu(((Grid)sender)).IsOpen))
            {
                if (calc.ItemInstance != null)
                {
                    MainPage.Tooltip.ItemInstance = calc.ItemInstance;
                }
                else if (calc.Item != null)
                {
                    MainPage.Tooltip.Item = calc.Item;
                }
                else if (calc.ItemSet != null)
                {
                    MainPage.Tooltip.ItemSet = calc.ItemSet; MainPage.Tooltip.CurrentString = calc.Name + "|" + calc.Description;
                }
                else
                {
                    MainPage.Tooltip.CurrentString = calc.Name + "|" + calc.Description;
                }
                if (calc is ComparisonCalculationUpgrades)
                {
                    ComparisonCalculationUpgrades upgrades = calc as ComparisonCalculationUpgrades;
                    MainPage.Tooltip.CharacterItems = upgrades.CharacterItems;
                }
                MainPage.Tooltip.Show((Grid)sender, 162 + Rawr.Properties.GeneralSettings.Default.ItemNameWidthSetting * 20 + 1, 2);
            }
        }
Exemplo n.º 2
0
 public int CompareItemCalculations(ComparisonCalculationBase a, ComparisonCalculationBase b)
 {
     if (Sort == ComparisonSort.Overall)
     {
         if (b.OverallPoints != a.OverallPoints)
         {
             return(b.OverallPoints.CompareTo(a.OverallPoints));
         }
         if (b.Equipped != a.Equipped)
         {
             return(b.Equipped.CompareTo(a.Equipped));
         }
         if (b.PartEquipped != a.PartEquipped)
         {
             return(b.PartEquipped.CompareTo(a.PartEquipped));
         }
         return(a.Name.CompareTo(b.Name));
     }
     else if (Sort == ComparisonSort.Alphabetical)
     {
         if (a.Name != b.Name)
         {
             return(a.Name.CompareTo(b.Name));
         }
         if (b.OverallPoints != a.OverallPoints)
         {
             return(b.OverallPoints.CompareTo(a.OverallPoints));
         }
         if (b.PartEquipped != a.PartEquipped)
         {
             return(b.PartEquipped.CompareTo(a.PartEquipped));
         }
         return(b.Equipped.CompareTo(a.Equipped));
     }
     else
     {
         int subPointCompare = b.SubPoints[(int)Sort].CompareTo(a.SubPoints[(int)Sort]);
         if (subPointCompare != 0)
         {
             return(subPointCompare);
         }
         if (b.OverallPoints != a.OverallPoints)
         {
             return(b.OverallPoints.CompareTo(a.OverallPoints));
         }
         if (b.Equipped != a.Equipped)
         {
             return(b.Equipped.CompareTo(a.Equipped));
         }
         if (b.PartEquipped != a.PartEquipped)
         {
             return(b.PartEquipped.CompareTo(a.PartEquipped));
         }
         return(a.Name.CompareTo(b.Name));
     }
 }
Exemplo n.º 3
0
        private void WriteItem(int indent, ItemInstance item, Character character, CharacterSlot slot)
        {
            int slotId = Item.GetSlotIdbyCharacterSlot(slot);

            if (slotId == 0 || item == null)
            {
                WriteLine(indent, "{ slot = " + slotId + ", item = \"" + nullItem + "\", loc = \"unknown\", },");
            }
            else
            {
                ComparisonCalculationBase itemCalc = Calculations.GetItemCalculations(item, character, slot);
                WriteItem(indent, item, itemCalc, slotId);
            }
        }
        public RawrAddonSaveDialog(Character character, ComparisonCalculationBase[] duCalcs, string[] customSubpoints = null)
        {
            InitializeComponent();

#if !SILVERLIGHT
            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            this.WindowState = System.Windows.WindowState.Normal;
            this.ResizeMode = System.Windows.ResizeMode.NoResize;
#endif

            if (character != null)
            {
                output = new StringBuilder();
                DUCalcs = duCalcs;
                this.customSubpoints = customSubpoints;
                TB_XMLDump.Text = BuildExportLua(character);
                TB_XMLDump.SelectAll();
            }
        }
Exemplo n.º 5
0
 private static float GetCalculationValue(ComparisonCalculationBase calcs, string calculation)
 {
     if (calculation == null || calculation == "Overall Rating")
     {
         return(calcs.OverallPoints);
     }
     else
     {
         int index = 0;
         foreach (string subPoint in Calculations.SubPointNameColors.Keys)
         {
             if (calculation.StartsWith(subPoint, StringComparison.Ordinal))
             {
                 return(calcs.SubPoints[index]);
             }
             index++;
         }
         return(0f);
     }
 }
Exemplo n.º 6
0
 private void WriteItem(int indent, ItemInstance item, ComparisonCalculationBase itemCalc, int slotId)
 {
     WriteLine(indent, "{ slot = " + slotId + ", item = \"" + item.ToItemString() + "\", loc = \"" + item.Item.GetFullLocationDesc.Replace('"', '\'') + "\", ");
     WriteLine(indent + 4, "overall = " + itemCalc.OverallPoints + ", ");
     WriteLine(indent + 4, "subpoint = { ");
     // for custom points the calculations will not be comparable to upgrades
     // just emit 0 values for all
     if (customSubpoints != null && (itemCalc.SubPoints == null || customSubpoints.Length != itemCalc.SubPoints.Length))
     {
         for (int i = 0; i < customSubpoints.Length; i++)
         {
             WriteLine(indent + 8, 0 + ", ");
         }
     }
     else
     {
         for (int i = 0; i < itemCalc.SubPoints.Length; i++)
         {
             WriteLine(indent + 8, itemCalc.SubPoints[i].ToString("0.####") + ", ");
         }
     }
     WriteLine(indent + 4, "},");
     WriteLine(indent, "},");
 }
Exemplo n.º 7
0
        private void BuildListItems()
        {
            try
            {
                _buildingListItems = true;
                if (Character == null)
                {
                    return;
                }
                bool seenEquippedItem = (Character[Slot] == null);

                List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>();
                if (IsEnchantList)
                {
                    CharacterCalculationsBase current = Calculations.GetCharacterCalculations(Character);
                    if (Character != null && current != null)
                    {
                        itemCalculations = Calculations.GetEnchantCalculations(Item.GetItemSlotByCharacterSlot(Slot), Character, current, false);
                    }
                }
                else if (IsTinkeringList)
                {
                    CharacterCalculationsBase current = Calculations.GetCharacterCalculations(Character);
                    if (Character != null && current != null)
                    {
                        itemCalculations = Calculations.GetTinkeringCalculations(Item.GetItemSlotByCharacterSlot(Slot), Character, current, false);
                    }
                }
                else if (IsReforgeList)
                {
                    CharacterCalculationsBase current = Calculations.GetCharacterCalculations(Character);
                    if (Character != null && current != null)
                    {
                        itemCalculations = Calculations.GetReforgeCalculations(Slot, Character, current, false);
                    }
                }
                else if (IsCogwheelList)
                {
                    Calculations.ClearCache();
                    List <Item> relevantItems = Character.GetRelevantItems(GemSlot);
                    foreach (Item item in relevantItems)
                    {
                        ComparisonCalculationBase itemCalc = Calculations.GetItemGemCalculations(item, Character, Slot, GemIndex);
                        if (SelectedItem != null && SelectedItem.Id == item.Id)
                        {
                            itemCalc.Equipped = true;
                            seenEquippedItem  = true;
                        }
                        itemCalculations.Add(itemCalc);
                    }
                    if (!seenEquippedItem)
                    {
                        itemCalculations.Add(Calculations.GetItemGemCalculations(SelectedItem, Character, Slot, GemIndex));
                    }
                }
                else if (IsHydraulicList)
                {
                    Calculations.ClearCache();
                    List <Item> relevantItems = Character.GetRelevantItems(GemSlot);
                    foreach (Item item in relevantItems)
                    {
                        ComparisonCalculationBase itemCalc = Calculations.GetItemGemCalculations(item, Character, Slot, GemIndex);
                        if (SelectedItem != null && SelectedItem.Id == item.Id)
                        {
                            itemCalc.Equipped = true;
                            seenEquippedItem  = true;
                        }
                        itemCalculations.Add(itemCalc);
                    }
                    if (!seenEquippedItem)
                    {
                        itemCalculations.Add(Calculations.GetItemGemCalculations(SelectedItem, Character, Slot, GemIndex));
                    }
                }
                else if (IsGemList)
                {
                    Calculations.ClearCache();
                    List <Item> relevantItems = Character.GetRelevantItems(GemSlot);
                    foreach (Item item in relevantItems)
                    {
                        ComparisonCalculationBase itemCalc = Calculations.GetItemGemCalculations(item, Character, Slot, GemIndex);
                        if (SelectedItem != null && SelectedItem.Id == item.Id)
                        {
                            itemCalc.Equipped = true;
                            seenEquippedItem  = true;
                        }
                        itemCalculations.Add(itemCalc);
                    }
                    if (!seenEquippedItem)
                    {
                        itemCalculations.Add(Calculations.GetItemGemCalculations(SelectedItem, Character, Slot, GemIndex));
                    }
                }
                else
                {
                    Calculations.ClearCache();
                    List <ItemInstance> relevantItemInstances = Character.GetRelevantItemInstances(Slot);
                    if (relevantItemInstances.Count > 0)
                    {
                        foreach (ItemInstance item in relevantItemInstances)
                        {
                            if (!seenEquippedItem && Character[Slot].Equals(item))
                            {
                                seenEquippedItem = true;
                            }
                            itemCalculations.Add(Calculations.GetItemCalculations((ItemInstance)item, Character, Slot));
                        }
                    }
                    if (!seenEquippedItem)
                    {
                        itemCalculations.Add(Calculations.GetItemCalculations(Character[Slot], Character, Slot));
                    }
                }

                float maxValue = itemCalculations.Count == 0 ? 100f : itemCalculations.Max(c => c.OverallPoints);

                Items.Clear();
                List <ItemListItem> itemListItems = new List <ItemListItem>();
                ItemListItem        selectedListItem = null;
                int selectedEnchantId = 0, selectedReforgingId = 0, selectedTinkeringId = 0;
                if (IsEnchantList)
                {
                    Enchant selectedEnchant = Character.GetEnchantBySlot(Slot);
                    if (selectedEnchant != null)
                    {
                        selectedEnchantId = selectedEnchant.Id;
                    }
                }
                else if (IsTinkeringList)
                {
                    Tinkering selectedTinkering = Character.GetTinkeringBySlot(Slot);
                    if (selectedTinkering != null)
                    {
                        selectedTinkeringId = selectedTinkering.Id;
                    }
                }
                else if (IsReforgeList)
                {
                    Reforging selectedReforging = Character.GetReforgingBySlot(Slot);
                    if (selectedReforging != null)
                    {
                        selectedReforgingId = selectedReforging.Id;
                    }
                }
                else if (IsGemList)
                {
                    ComparisonCalculationBase emptyCalcs = Calculations.CreateNewComparisonCalculation();
                    emptyCalcs.Name      = "Empty";
                    emptyCalcs.Item      = new Item();
                    emptyCalcs.Item.Name = "Empty";
                    emptyCalcs.Item.Id   = -1;
                    emptyCalcs.Equipped  = SelectedItem == null;
                    itemCalculations.Add(emptyCalcs);
                }
                else
                {
                    ComparisonCalculationBase emptyCalcs = Calculations.CreateNewComparisonCalculation();
                    emptyCalcs.Name            = "Empty";
                    emptyCalcs.Item            = new Item();
                    emptyCalcs.Item.Name       = "Empty";
                    emptyCalcs.ItemInstance    = new ItemInstance();
                    emptyCalcs.ItemInstance.Id = -1;
                    emptyCalcs.Equipped        = Character[Slot] == null;
                    itemCalculations.Add(emptyCalcs);
                }
                foreach (ComparisonCalculationBase calc in itemCalculations)
                {
                    ItemListItem itemListItem = new ItemListItem(calc, maxValue, 344d);
                    itemListItems.Add(itemListItem);
                    if (IsEnchantList)
                    {
                        if (itemListItem.EnchantId == selectedEnchantId)
                        {
                            selectedListItem = itemListItem;
                        }
                    }
                    else if (IsTinkeringList)
                    {
                        if (itemListItem.TinkeringId == selectedTinkeringId)
                        {
                            selectedListItem = itemListItem;
                        }
                    }
                    else if (IsReforgeList)
                    {
                        if (itemListItem.ReforgeId == selectedReforgingId)
                        {
                            selectedListItem = itemListItem;
                        }
                    }
                    else if (IsGemList || IsHydraulicList || IsCogwheelList)
                    {
                        if (calc.Item == null)
                        {
                            if (SelectedItem == null)
                            {
                                selectedListItem = itemListItem;
                            }
                        }
                        else
                        {
                            if ((SelectedItem != null && calc.Item.Id == SelectedItem.Id) || (calc.Item.Id == -1 && SelectedItem == null))
                            {
                                selectedListItem = itemListItem;
                            }
                        }
                    }
                    else
                    {
                        if (calc.ItemInstance == Character[Slot] || (calc.ItemInstance.Id == -1 && Character[Slot] == null))
                        {
                            selectedListItem = itemListItem;
                        }
                    }
                }
                Items.AddRange(itemListItems);
                listBoxItems.SelectedItem = selectedListItem;
                listBoxItems.Focus();
                IsPopulated = true;
            }
            finally
            {
                _buildingListItems = false;
            }
        }
Exemplo n.º 8
0
        public int CompareItemCalculations(ComparisonCalculationBase a, ComparisonCalculationBase b)
        {
            if (Sort == ComparisonSort.Overall)
            {
                if (b.OverallPoints != a.OverallPoints)
                {
                    return(b.OverallPoints.CompareTo(a.OverallPoints));
                }
                if (b.Equipped != a.Equipped)
                {
                    return(b.Equipped.CompareTo(a.Equipped));
                }
                if (b.PartEquipped != a.PartEquipped)
                {
                    return(b.PartEquipped.CompareTo(a.PartEquipped));
                }
                return(a.Name.CompareTo(b.Name));
            }
            else if (Sort == ComparisonSort.Alphabetical)
            {
                if (a.Name != b.Name)
                {
                    return(a.Name.CompareTo(b.Name));
                }
                if (b.OverallPoints != a.OverallPoints)
                {
                    return(b.OverallPoints.CompareTo(a.OverallPoints));
                }
                if (b.PartEquipped != a.PartEquipped)
                {
                    return(b.PartEquipped.CompareTo(a.PartEquipped));
                }
                return(b.Equipped.CompareTo(a.Equipped));
            }
            else if ((int)Sort >= b.SubPoints.Length) // This is a special 'grouped' sort
            {
                int subPointCompare = 0;


                // It's a combination one
                if (b.SubPoints.Length == 3)
                {
                    switch ((int)Sort)
                    {
                    case 3: { subPointCompare = (b.SubPoints[0] + b.SubPoints[1]).CompareTo(a.SubPoints[0] + a.SubPoints[1]); break; }

                    case 4: { subPointCompare = (b.SubPoints[0] + b.SubPoints[2]).CompareTo(a.SubPoints[0] + a.SubPoints[2]); break; }

                    default: { subPointCompare = (b.SubPoints[1] + b.SubPoints[2]).CompareTo(a.SubPoints[1] + a.SubPoints[2]); break; }
                    }
                }
                else if (b.SubPoints.Length == 4)
                {
                    switch ((int)Sort)
                    {
                    case 4: { subPointCompare = (b.SubPoints[0] + b.SubPoints[1]).CompareTo(a.SubPoints[0] + a.SubPoints[1]); break; }

                    case 5: { subPointCompare = (b.SubPoints[0] + b.SubPoints[2]).CompareTo(a.SubPoints[0] + a.SubPoints[2]); break; }

                    case 6: { subPointCompare = (b.SubPoints[0] + b.SubPoints[3]).CompareTo(a.SubPoints[0] + a.SubPoints[3]); break; }

                    case 7: { subPointCompare = (b.SubPoints[1] + b.SubPoints[2]).CompareTo(a.SubPoints[1] + a.SubPoints[2]); break; }

                    case 8: { subPointCompare = (b.SubPoints[1] + b.SubPoints[2]).CompareTo(a.SubPoints[1] + a.SubPoints[2]); break; }

                    default: { subPointCompare = (b.SubPoints[2] + b.SubPoints[3]).CompareTo(a.SubPoints[2] + a.SubPoints[3]); break; }
                    }
                }
                // Note a Subpoints Length of greater than 5 would mean we would enter here by default if this was just an else (...)
                // and that would throw off the case values.
                else if (b.SubPoints.Length == 5)
                {
                    switch ((int)Sort)
                    {
                    case 5: { subPointCompare = (b.SubPoints[0] + b.SubPoints[1]).CompareTo(a.SubPoints[0] + a.SubPoints[1]); break; }

                    case 6: { subPointCompare = (b.SubPoints[0] + b.SubPoints[2]).CompareTo(a.SubPoints[0] + a.SubPoints[2]); break; }

                    case 7: { subPointCompare = (b.SubPoints[0] + b.SubPoints[3]).CompareTo(a.SubPoints[0] + a.SubPoints[3]); break; }

                    case 8: { subPointCompare = (b.SubPoints[0] + b.SubPoints[4]).CompareTo(a.SubPoints[0] + a.SubPoints[4]); break; }

                    case 9: { subPointCompare = (b.SubPoints[1] + b.SubPoints[2]).CompareTo(a.SubPoints[1] + a.SubPoints[2]); break; }

                    case 10: { subPointCompare = (b.SubPoints[1] + b.SubPoints[3]).CompareTo(a.SubPoints[1] + a.SubPoints[3]); break; }

                    case 11: { subPointCompare = (b.SubPoints[1] + b.SubPoints[4]).CompareTo(a.SubPoints[1] + a.SubPoints[4]); break; }

                    case 12: { subPointCompare = (b.SubPoints[2] + b.SubPoints[3]).CompareTo(a.SubPoints[2] + a.SubPoints[3]); break; }

                    case 13: { subPointCompare = (b.SubPoints[2] + b.SubPoints[4]).CompareTo(a.SubPoints[2] + a.SubPoints[4]); break; }

                    default: { subPointCompare = (b.SubPoints[3] + b.SubPoints[4]).CompareTo(a.SubPoints[3] + a.SubPoints[4]); break; }
                    }
                }
                if (subPointCompare != 0)
                {
                    return(subPointCompare);
                }

                if (b.OverallPoints != a.OverallPoints)
                {
                    return(b.OverallPoints.CompareTo(a.OverallPoints));
                }
                if (b.Equipped != a.Equipped)
                {
                    return(b.Equipped.CompareTo(a.Equipped));
                }
                if (b.PartEquipped != a.PartEquipped)
                {
                    return(b.PartEquipped.CompareTo(a.PartEquipped));
                }

                return(a.Name.CompareTo(b.Name));
            }
            else
            {
                int subPointCompare = b.SubPoints[(int)Sort].CompareTo(a.SubPoints[(int)Sort]);
                if (subPointCompare != 0)
                {
                    return(subPointCompare);
                }
                if (b.OverallPoints != a.OverallPoints)
                {
                    return(b.OverallPoints.CompareTo(a.OverallPoints));
                }
                if (b.Equipped != a.Equipped)
                {
                    return(b.Equipped.CompareTo(a.Equipped));
                }
                if (b.PartEquipped != a.PartEquipped)
                {
                    return(b.PartEquipped.CompareTo(a.PartEquipped));
                }
                return(a.Name.CompareTo(b.Name));
            }
        }
Exemplo n.º 9
0
 public ItemListItem(ComparisonCalculationBase calc, double maxValue, double maxWidth)
 {
     _calc     = calc;
     _maxValue = maxValue;
     _maxWidth = maxWidth;
 }
Exemplo n.º 10
0
        public int CompareItemCalculations(ComparisonCalculationBase a, ComparisonCalculationBase b)
        {
            if (Sort == ComparisonSort.Overall)
            {
                if (b.OverallPoints != a.OverallPoints)
                    return b.OverallPoints.CompareTo(a.OverallPoints);
                if (b.Equipped != a.Equipped)
                    return b.Equipped.CompareTo(a.Equipped);
                if (b.PartEquipped != a.PartEquipped)
                    return b.PartEquipped.CompareTo(a.PartEquipped);
                return a.Name.CompareTo(b.Name);
            }
            else if (Sort == ComparisonSort.Alphabetical)
            {
                if (a.Name != b.Name)
                    return a.Name.CompareTo(b.Name);
                if (b.OverallPoints != a.OverallPoints)
                    return b.OverallPoints.CompareTo(a.OverallPoints);
                if (b.PartEquipped != a.PartEquipped)
                    return b.PartEquipped.CompareTo(a.PartEquipped);
                return b.Equipped.CompareTo(a.Equipped);
            }
            else if ((int)Sort >= b.SubPoints.Length) // This is a special 'grouped' sort
            {
                int subPointCompare = 0;


                // It's a combination one
                if (b.SubPoints.Length == 3)
                {
                    switch ((int)Sort)
                    {
                        case 3: { subPointCompare = (b.SubPoints[0] + b.SubPoints[1]).CompareTo(a.SubPoints[0] + a.SubPoints[1]); break; }
                        case 4: { subPointCompare = (b.SubPoints[0] + b.SubPoints[2]).CompareTo(a.SubPoints[0] + a.SubPoints[2]); break; }
                        default: { subPointCompare = (b.SubPoints[1] + b.SubPoints[2]).CompareTo(a.SubPoints[1] + a.SubPoints[2]); break; }
                    }
                }
                else if (b.SubPoints.Length == 4)
                {
                    switch ((int)Sort)
                    {
                        case 4: { subPointCompare = (b.SubPoints[0] + b.SubPoints[1]).CompareTo(a.SubPoints[0] + a.SubPoints[1]); break; }
                        case 5: { subPointCompare = (b.SubPoints[0] + b.SubPoints[2]).CompareTo(a.SubPoints[0] + a.SubPoints[2]); break; }
                        case 6: { subPointCompare = (b.SubPoints[0] + b.SubPoints[3]).CompareTo(a.SubPoints[0] + a.SubPoints[3]); break; }
                        case 7: { subPointCompare = (b.SubPoints[1] + b.SubPoints[2]).CompareTo(a.SubPoints[1] + a.SubPoints[2]); break; }
                        case 8: { subPointCompare = (b.SubPoints[1] + b.SubPoints[2]).CompareTo(a.SubPoints[1] + a.SubPoints[2]); break; }
                        default: { subPointCompare = (b.SubPoints[2] + b.SubPoints[3]).CompareTo(a.SubPoints[2] + a.SubPoints[3]); break; }
                    }
                }
                // Note a Subpoints Length of greater than 5 would mean we would enter here by default if this was just an else (...)
                // and that would throw off the case values.
                else if (b.SubPoints.Length == 5) 
                {
                    switch ((int)Sort)
                    {
                        case 5: { subPointCompare = (b.SubPoints[0] + b.SubPoints[1]).CompareTo(a.SubPoints[0] + a.SubPoints[1]); break; }
                        case 6: { subPointCompare = (b.SubPoints[0] + b.SubPoints[2]).CompareTo(a.SubPoints[0] + a.SubPoints[2]); break; }
                        case 7: { subPointCompare = (b.SubPoints[0] + b.SubPoints[3]).CompareTo(a.SubPoints[0] + a.SubPoints[3]); break; }
                        case 8: { subPointCompare = (b.SubPoints[0] + b.SubPoints[4]).CompareTo(a.SubPoints[0] + a.SubPoints[4]); break; }
                        case 9: { subPointCompare = (b.SubPoints[1] + b.SubPoints[2]).CompareTo(a.SubPoints[1] + a.SubPoints[2]); break; }
                        case 10: { subPointCompare = (b.SubPoints[1] + b.SubPoints[3]).CompareTo(a.SubPoints[1] + a.SubPoints[3]); break; }
                        case 11: { subPointCompare = (b.SubPoints[1] + b.SubPoints[4]).CompareTo(a.SubPoints[1] + a.SubPoints[4]); break; }
                        case 12: { subPointCompare = (b.SubPoints[2] + b.SubPoints[3]).CompareTo(a.SubPoints[2] + a.SubPoints[3]); break; }
                        case 13: { subPointCompare = (b.SubPoints[2] + b.SubPoints[4]).CompareTo(a.SubPoints[2] + a.SubPoints[4]); break; }
                        default: { subPointCompare = (b.SubPoints[3] + b.SubPoints[4]).CompareTo(a.SubPoints[3] + a.SubPoints[4]); break; }
                    }
                }
                if (subPointCompare != 0) { return subPointCompare; }

                if (b.OverallPoints != a.OverallPoints) { return b.OverallPoints.CompareTo(a.OverallPoints); }
                if (b.Equipped != a.Equipped) { return b.Equipped.CompareTo(a.Equipped); }
                if (b.PartEquipped != a.PartEquipped) { return b.PartEquipped.CompareTo(a.PartEquipped); }

                return a.Name.CompareTo(b.Name);
            }
            else
            {
                int subPointCompare = b.SubPoints[(int)Sort].CompareTo(a.SubPoints[(int)Sort]);
                if (subPointCompare != 0)
                    return subPointCompare;
                if (b.OverallPoints != a.OverallPoints)
                    return b.OverallPoints.CompareTo(a.OverallPoints);
                if (b.Equipped != a.Equipped)
                    return b.Equipped.CompareTo(a.Equipped);
                if (b.PartEquipped != a.PartEquipped)
                    return b.PartEquipped.CompareTo(a.PartEquipped);
                return a.Name.CompareTo(b.Name);
            }
        }
Exemplo n.º 11
0
        public void DisplayCalcs(ComparisonCalculationBase[] calcs)
        {
            if (calcs == null) return;
            currentCalcs = calcs;
            if (comparisonItems == null) comparisonItems = new List<ComparisonGraphItem>();
            int i = 0;
#if DEBUG
            DateTime dtA = DateTime.Now;
#endif

            minScale = 0; maxScale = 0;
            foreach (ComparisonCalculationBase c in calcs)
            {
                if (c == null) continue;
                float min = 0f, max = 0f;
                if (Mode == DisplayMode.Overall)
                {
                    if (c.OverallPoints < 0) min += c.OverallPoints;
                    else max += c.OverallPoints;
                }
                else
                {
                    foreach (float f in c.SubPoints)
                    {
                        if (f < 0) min += f;
                        else max += f;
                    }
                }
                if (min < minScale) minScale = min;
                if (max > maxScale) maxScale = max;
            }
            if (minScale > -.01f) minScale = 0f;
            if (maxScale < .01f) maxScale = 0f;
            if (maxScale == 0f && minScale == 0f) maxScale = 2f;

            // Section 1: Initial Scales and Step value
            float largestScale = Math.Max(-minScale, maxScale);
            float roundTo = 2f;
            if (largestScale >= 10) roundTo = (int)Math.Pow(10, Math.Floor(Math.Log10(largestScale) - .6f));
            minScale = roundTo * (float)Math.Floor(minScale / roundTo);
            maxScale = roundTo * (float)Math.Ceiling(maxScale / roundTo);
            float totalScale = maxScale - minScale;
            float step = totalScale / 8f;
            // Section 2: Determine what the points are and check if there's a 0 in the points
            bool hasZero = false;
            List<float> pointsList = new List<float>();
            int countBelow = 0;
            for (int p = 0; p < 9; p++) {
                pointsList.Add(minScale + p * step);
                if (pointsList[p] < 0) { countBelow++; }
            }
            hasZero = pointsList.Contains(0);
            int countLargest = Math.Max(countBelow, 9 - countBelow);
            // Section 3: If there is not a zero, we need to round it out so that there is one
            if (!hasZero) {
                step = roundTo * (float)Math.Ceiling(largestScale / (countLargest - 1));
                while (step > totalScale)//maxScale)
                {
                    // In some cases, the roundTo goes out of control
                    // This brings it back in line
                    step /= 10;
                }
                //
                pointsList.Clear();
                for (int p = -countBelow; p < (9 - countBelow); p++) {
                    pointsList.Add(p * step);
                }
            }
            // Section 4: Set the min/max scales based on the points we determined (which could be adjusted)
            minScale = pointsList[0];
            maxScale = pointsList[8];

#if DEBUG
            System.Diagnostics.Debug.WriteLine(string.Format("DisplayCalcs Phase A: {0}ms", DateTime.Now.Subtract(dtA).TotalMilliseconds));
            DateTime dtB = DateTime.Now;
#endif

            ChangedSize(this, null);
            IOrderedEnumerable<ComparisonCalculationBase> orderedCalcs;
            if (Sort == ComparisonSort.Alphabetical) 
                orderedCalcs = calcs.OrderBy(calc => calc == null ? "" : calc.Name);
            else if (Sort == ComparisonSort.Overall)
                orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.OverallPoints);
            else if ((int)Sort >= calcs[0].SubPoints.Length)
                // It's a combination one
                if        (calcs[0].SubPoints.Length == 3) {
                    switch ((int)Sort) {
                        case 3: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[0] + calc.SubPoints[1]); break; }
                        case 4: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[0] + calc.SubPoints[2]); break; }
                        default:{ orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[1] + calc.SubPoints[2]); break; }
                    }
                } else if (calcs[0].SubPoints.Length == 4) {
                    switch ((int)Sort) {
                        case 4: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[0] + calc.SubPoints[1]); break; }
                        case 5: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[0] + calc.SubPoints[2]); break; }
                        case 6: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[0] + calc.SubPoints[3]); break; }
                        case 7: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[1] + calc.SubPoints[2]); break; }
                        case 8: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[1] + calc.SubPoints[2]); break; }
                        default:{ orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[2] + calc.SubPoints[3]); break; }
                    }
                }
                else /*if (calcs[0].SubPoints.Length == 5)*/ {
                    switch ((int)Sort) {
                        case 5: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[0] + calc.SubPoints[1]); break; }
                        case 6: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[0] + calc.SubPoints[2]); break; }
                        case 7: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[0] + calc.SubPoints[3]); break; }
                        case 8: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[0] + calc.SubPoints[4]); break; }
                        case 9: { orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[1] + calc.SubPoints[2]); break; }
                        case 10:{ orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[1] + calc.SubPoints[3]); break; }
                        case 11:{ orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[1] + calc.SubPoints[4]); break; }
                        case 12:{ orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[2] + calc.SubPoints[3]); break; }
                        case 13:{ orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[2] + calc.SubPoints[4]); break; }
                        default:{ orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[3] + calc.SubPoints[4]); break; }
                    }
                }
            else
                orderedCalcs = calcs.OrderByDescending(calc => calc == null ? 0 : calc.SubPoints[(int)Sort]);
#if DEBUG
            System.Diagnostics.Debug.WriteLine(string.Format("DisplayCalcs Phase B: {0}ms", DateTime.Now.Subtract(dtB).TotalMilliseconds));
            DateTime dtC = DateTime.Now;
#endif
            foreach (ComparisonCalculationBase c in orderedCalcs)
            {
                if (c == null) continue;
                ComparisonGraphItem item;
                if (i >= comparisonItems.Count)
                {
                    item = new ComparisonGraphItem(LegendItems.Values);
                    item.Character = Character;
                    item.Slot = Slot;
                    comparisonItems.Add(item);
                    ItemStack.Children.Add(item);
                    item.NameGrid.MouseEnter += new MouseEventHandler(NameGrid_MouseEnter);
                    item.NameGrid.MouseLeave += new MouseEventHandler(NameGrid_MouseLeave);

//#if SILVERLIGHT
//                    item.NameGrid.MouseLeftButtonDown += new MouseButtonEventHandler(NameGrid_MouseLeftButtonDown);
//#else
//                    item.NameGrid.ContextMenu = ItemContextMenu;
//                    item.NameGrid.ContextMenuOpening += new ContextMenuEventHandler(NameGrid_ContextMenuOpening);
//#endif
                }
                else item = comparisonItems[i];
                bool isGem = c.Item != null && c.Item.IsGem;
                string s = c.Name;
                if (c.Item != null && c.Item.ItemLevel != 0 && !isGem) { s += string.Format(" [{0}]", c.Item.ItemLevel); }
                item.Title = s;
                item.Equipped = c.Equipped;
                item.PartEquipped = c.PartEquipped;
                item.OtherItem = c.Item;
                item.ItemInstance = c.ItemInstance;
                item.MinScale = minScale;
                item.MaxScale = maxScale;
                item.Slot = Slot;
                // Items will generate their own icon image, but if you supply one manually (like in custom charts), this will set it that way instead
                if (c.Item == null && c.ImageSource != null) { item.NonItemImageSource = c.ImageSource; }
                // Gems however, will not and we have to manually set them
                if (isGem && c.ImageSource != null) { item.NonItemImageSource = c.ImageSource; }

                item.NameGrid.Tag = c;

                // set visibility first, otherwise ActualWidth is 0 and it will fail to reset colors
                item.Visibility = Visibility.Visible;
                if (Mode == DisplayMode.Overall) { item[0] = c.OverallPoints; }
                else { for (int j = 0; j < c.SubPoints.Length; j++) item[j] = c.SubPoints[j]; }
                
                i++;
            }
#if DEBUG
            System.Diagnostics.Debug.WriteLine(string.Format("DisplayCalcs Phase C: {0}ms", DateTime.Now.Subtract(dtC).TotalMilliseconds));
            DateTime dtD = DateTime.Now;
#endif
            for (; i < comparisonItems.Count; i++) comparisonItems[i].Visibility = Visibility.Collapsed;
#if DEBUG
            System.Diagnostics.Debug.WriteLine(string.Format("DisplayCalcs Phase D: {0}ms", DateTime.Now.Subtract(dtD).TotalMilliseconds));
            System.Diagnostics.Debug.WriteLine(string.Format("Finished DisplayCalcs: Total {0}ms", DateTime.Now.Subtract(dtA).TotalMilliseconds));
#endif
        }
 private void WriteItem(int indent, ItemInstance item, ComparisonCalculationBase itemCalc, int slotId)
 {
     WriteLine(indent, "{ slot = " + slotId + ", item = \"" + item.ToItemString() + "\", loc = \"" + item.Item.GetFullLocationDesc.Replace('"', '\'') + "\", ");
     WriteLine(indent + 4, "overall = " + itemCalc.OverallPoints + ", ");
     WriteLine(indent + 4, "subpoint = { ");
     // for custom points the calculations will not be comparable to upgrades
     // just emit 0 values for all
     if (customSubpoints != null && (itemCalc.SubPoints == null || customSubpoints.Length != itemCalc.SubPoints.Length))
     {
         for (int i = 0; i < customSubpoints.Length; i++)
         {
             WriteLine(indent + 8, 0 + ", ");
         }
     }
     else
     {
         for (int i = 0; i < itemCalc.SubPoints.Length; i++)
         {
             WriteLine(indent + 8, itemCalc.SubPoints[i].ToString("0.####") + ", ");
         }
     }
     WriteLine(indent + 4, "},");
     WriteLine(indent, "},");
 }
Exemplo n.º 13
0
        public override ComparisonCalculationBase[] GetCustomChartData(Character character, string chartName)
        {
            CharacterCalculationsProtWarr calculations = GetCharacterCalculations(character) as CharacterCalculationsProtWarr;

            switch (chartName)
            {
                /*
                #region Rotation Damage and Threat
                case "Rotation Damage":
                case "Rotation Threat":
                    {
                        CalculationOptionsProtWarr options = character.CalculationOptions as CalculationOptionsProtWarr;
                        string[] rotations = Enum.GetNames(typeof(AttackModelMode));
                        // Optimal rotation will need to be ignored as it is outside the scope of this
                        ComparisonCalculationBase[] comparisons = new ComparisonCalculationBase[rotations.Length - 1];

                        int j = 0;
                        for (int i = 0; i < rotations.Length; i++)
                        {
                            if (rotations[i] != "Optimal")
                            {
                                AttackModel am = new AttackModel(character, calculations.BasicStats, options, (AttackModelMode)Enum.Parse(typeof(AttackModelMode), rotations[i]));
                                ComparisonCalculationProtWarr comparison = new ComparisonCalculationProtWarr();
                                comparison.Name = am.Name;

                                if (chartName == "Rotation Damage")
                                    comparison.ThreatPoints = am.DamagePerSecond;
                                else
                                    comparison.ThreatPoints = am.ThreatPerSecond;

                                comparisons[j] = comparison;
                                j++;
                            }
                        }
                        return comparisons;
                    }
                #endregion
                */
                #region Ability Damage and Threat
                case "Ability Damage":
                case "Ability Threat":
                    {
                        // Vigilance will need to be ignores as it is outside the scope of this
                        ComparisonCalculationBase[] comparisons = new ComparisonCalculationBase[calculations.Abilities.Count];
                        // Index Deep Wounds for including in everything that can crit
                        AbilityModel DeepWounds = calculations.Abilities[Ability.DeepWounds];

                        int j = 0;
                        foreach (AbilityModel ability in calculations.Abilities)
                        {
                            ComparisonCalculationProtWarr comparison = new ComparisonCalculationProtWarr();
                            comparison.Name = ability.Name;

                            // Deep Wounds gets colored red to make the integrated parts easier to understand
                            if (ability.Ability == Ability.DeepWounds)
                            {
                                if (chartName == "Ability Damage")
                                    comparison.MitigationPoints = ability.Damage;
                                else
                                    comparison.MitigationPoints = ability.Threat;
                            }
                            else
                            {
                                if (chartName == "Ability Damage")
                                {
                                    comparison.ThreatPoints = ability.Damage;
                                    comparison.MitigationPoints = ability.CritPercentage * DeepWounds.Damage;
                                }
                                else
                                {
                                    comparison.ThreatPoints = ability.Threat;
                                    comparison.MitigationPoints = ability.CritPercentage * DeepWounds.Threat;
                                }
                            }

                            comparison.OverallPoints = comparison.SurvivalPoints + comparison.ThreatPoints + comparison.MitigationPoints;
                            comparisons[j] = comparison;
                            j++;
                        }
                        return comparisons;
                    }
                #endregion
                #region Combat Table
                case "Combat Table":
                    {
                        ComparisonCalculationProtWarr calcMiss = new ComparisonCalculationProtWarr();
                        ComparisonCalculationProtWarr calcDodge = new ComparisonCalculationProtWarr();
                        ComparisonCalculationProtWarr calcParry = new ComparisonCalculationProtWarr();
                        ComparisonCalculationProtWarr calcBlock = new ComparisonCalculationProtWarr();
                        ComparisonCalculationProtWarr calcCritBlock = new ComparisonCalculationProtWarr();
                        ComparisonCalculationProtWarr calcCrit = new ComparisonCalculationProtWarr();
                        ComparisonCalculationProtWarr calcCrush = new ComparisonCalculationProtWarr();
                        ComparisonCalculationProtWarr calcHit = new ComparisonCalculationProtWarr();
                        if (calculations != null)
                        {
                            calcMiss.Name = "Miss";
                            calcDodge.Name = "Dodge";
                            calcParry.Name = "Parry";
                            calcBlock.Name = "Block";
                            calcCritBlock.Name = "Critical Block";
                            calcCrit.Name = "Crit";
                            calcCrush.Name = "Crush";
                            calcHit.Name = "Hit";

                            calcMiss.OverallPoints = calcMiss.MitigationPoints = calculations.Miss * 100.0f;
                            calcDodge.OverallPoints = calcDodge.MitigationPoints = calculations.Dodge * 100.0f;
                            calcParry.OverallPoints = calcParry.MitigationPoints = calculations.Parry * 100.0f;
                            calcCritBlock.OverallPoints = calcCritBlock.MitigationPoints = calculations.CriticalBlock * 100.0f;
                            calcBlock.OverallPoints = calcBlock.MitigationPoints = (calculations.Block - calculations.CriticalBlock) * 100.0f;
                            calcCrit.OverallPoints = calcCrit.SurvivalPoints = calculations.CritVulnerability * 100.0f;
                            calcHit.OverallPoints = calcHit.SurvivalPoints = (1.0f - calculations.AnyAvoid - calculations.CritVulnerability) * 100.0f;
                        }
                        return new ComparisonCalculationBase[] { calcMiss, calcDodge, calcParry, calcBlock, calcCritBlock, calcCrit, calcCrush, calcHit };
                    }
                #endregion
                #region Item Budget
                case "Item Budget":
                    CharacterCalculationsProtWarr calcBaseValue = GetCharacterCalculations(character) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcStrengthValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Strength = 100.0f } }) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcAgilityValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Agility = 100.0f } }) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcStaminaValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Stamina = 150.0f } }) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcHealthValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Health = 1500.0f } }) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcArmorValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { BonusArmor = 400.0f } }) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcDodgeValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { DodgeRating = 100.0f } }) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcParryValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { ParryRating = 100.0f } }) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcMasteryValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { MasteryRating = 100.0f } }) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcHasteValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { HasteRating = 100.0f } }) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcExpertiseValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { ExpertiseRating = 100.0f } }) as CharacterCalculationsProtWarr;
                    CharacterCalculationsProtWarr calcHitValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { HitRating = 100.0f } }) as CharacterCalculationsProtWarr;

                    return new ComparisonCalculationBase[] { 
                        new ComparisonCalculationProtWarr() { Name = "100 Strength",
                            OverallPoints = (calcStrengthValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcStrengthValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcStrengthValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcStrengthValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtWarr() { Name = "100 Agility",
                            OverallPoints = (calcAgilityValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcAgilityValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcAgilityValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcAgilityValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtWarr() { Name = "150 Stamina",
                            OverallPoints = (calcStaminaValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcStaminaValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcStaminaValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcStaminaValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtWarr() { Name = "1500 Health",
                            OverallPoints = (calcHealthValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcHealthValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcHealthValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcHealthValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtWarr() { Name = "400 Armor",
                            OverallPoints = (calcArmorValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcArmorValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcArmorValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcArmorValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtWarr() { Name = "100 Dodge Rating",
                            OverallPoints = (calcDodgeValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcDodgeValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcDodgeValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcDodgeValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtWarr() { Name = "100 Parry Rating",
                            OverallPoints = (calcParryValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcParryValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcParryValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcParryValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtWarr() { Name = "100 Mastery Rating",
                            OverallPoints = (calcMasteryValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcMasteryValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcMasteryValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcMasteryValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtWarr() { Name = "100 Haste Rating",
                            OverallPoints = (calcHasteValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcHasteValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcHasteValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcHasteValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtWarr() { Name = "100 Expertise Rating",
                            OverallPoints = (calcExpertiseValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcExpertiseValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcExpertiseValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcExpertiseValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtWarr() { Name = "100 Hit Rating",
                            OverallPoints = (calcHitValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcHitValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcHitValue.SurvivalPoints - calcBaseValue.SurvivalPoints),
                            ThreatPoints = (calcHitValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                    };
                #endregion
                default:
                    return new ComparisonCalculationBase[0];
            }
        }
Exemplo n.º 14
0
        public override ComparisonCalculationBase[] GetCustomChartData(Character character, string chartName)
        {
            CharacterCalculationsProtPaladin calculations = GetCharacterCalculations(character) as CharacterCalculationsProtPaladin;

            switch (chartName)
            {
                #region Ability Damage/Threat
                case "Ability Damage":
                case "Ability Threat":
                    {
                        ComparisonCalculationBase[] comparisons = new ComparisonCalculationBase[calculations.Abilities.Count];
                        int j = 0;
                        foreach (var abilities in calculations.Abilities)
                        {
                            AbilityModel ability = (AbilityModel)abilities.Value;
                            ComparisonCalculationProtPaladin comparison = new ComparisonCalculationProtPaladin();

                            comparison.Name = ability.Name;
                            if (chartName == "Ability Damage")
                                comparison.MitigationPoints = ability.Damage;
                            if (chartName == "Ability Threat")
                                comparison.ThreatPoints = ability.Threat;

                            comparison.OverallPoints = comparison.SurvivalPoints + comparison.ThreatPoints + comparison.MitigationPoints;
                            comparisons[j] = comparison;
                            j++;
                        }
                        return comparisons;
                    }
                #endregion
                #region Combat Table: Defensive Stats
                case "Combat Table: Defensive Stats":
                    {
                        ComparisonCalculationProtPaladin calcMiss = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcDodge = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcParry = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcBlock = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcCrit = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcCrush = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcHit = new ComparisonCalculationProtPaladin();
                        if (calculations != null)
                        {
                            calcMiss.Name  = "1 Miss";
                            calcDodge.Name = "2 Dodge";
                            calcParry.Name = "3 Parry";
                            calcBlock.Name = "4 Block";
                            calcCrit.Name  = "5 Crit";
                            calcCrush.Name = "6 Crush";
                            calcHit.Name   = "7 Hit";

                            calcMiss.OverallPoints = calcMiss.MitigationPoints = calculations.Miss * 100.0f;
                            calcDodge.OverallPoints = calcDodge.MitigationPoints = calculations.Dodge * 100.0f;
                            calcParry.OverallPoints = calcParry.MitigationPoints = calculations.Parry * 100.0f;
                            calcBlock.OverallPoints = calcBlock.MitigationPoints = calculations.Block * 100.0f;
                            calcCrit.OverallPoints = calcCrit.SurvivalPoints = calculations.CritVulnerability * 100.0f;
                            calcHit.OverallPoints = calcHit.SurvivalPoints = (1.0f - (calculations.DodgePlusMissPlusParryPlusBlock + calculations.CritVulnerability)) * 100.0f;
                        }
                        return new ComparisonCalculationBase[] { calcMiss, calcDodge, calcParry, calcBlock, calcCrit, calcCrush, calcHit };
                    }
                #endregion
                #region Combat Table: Offensive Stats
                case "Combat Table: Offensive Stats":
                    {
                        ComparisonCalculationProtPaladin calcMiss = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcDodge = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcParry = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcGlance = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcBlock = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcCrit = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcHit = new ComparisonCalculationProtPaladin();
                        if (calculations != null)
                        {
                            calcMiss.Name   = "1 Miss";
                            calcDodge.Name  = "2 Dodge";
                            calcParry.Name  = "3 Parry";
                            calcGlance.Name = "4 Glancing";
                            calcBlock.Name  = "5 Block";
                            calcCrit.Name   = "6 Crit";
                            calcHit.Name    = "7 Hit";

                            calcMiss.OverallPoints = calcMiss.MitigationPoints = calculations.MissedAttacks * 100.0f;
                            calcDodge.OverallPoints = calcDodge.MitigationPoints = calculations.DodgedAttacks * 100.0f;
                            calcParry.OverallPoints = calcParry.MitigationPoints = calculations.ParriedAttacks * 100.0f;
                            calcGlance.OverallPoints = calcGlance.MitigationPoints = calculations.GlancingAttacks * 100.0f;
                            calcBlock.OverallPoints = calcBlock.MitigationPoints = calculations.BlockedAttacks * 100.0f;
                            calcCrit.OverallPoints = calcCrit.SurvivalPoints = calculations.Crit * 100.0f;
                            calcHit.OverallPoints = calcHit.SurvivalPoints = (1.0f - (calculations.AvoidedAttacks + calculations.GlancingAttacks + calculations.BlockedAttacks + calculations.Crit)) * 100.0f;
                        }
                        return new ComparisonCalculationBase[] { calcMiss, calcDodge, calcParry, calcGlance, calcBlock, calcCrit, calcHit };
                    }
                #endregion
                #region Item Budget
                case "Item Budget":
                    CharacterCalculationsProtPaladin calcBaseValue = GetCharacterCalculations(character) as CharacterCalculationsProtPaladin;
                    CharacterCalculationsProtPaladin calcDodgeValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { DodgeRating = 10f } }) as CharacterCalculationsProtPaladin;
                    CharacterCalculationsProtPaladin calcParryValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { ParryRating = 10f } }) as CharacterCalculationsProtPaladin;
                    CharacterCalculationsProtPaladin calcBlockValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { BlockRating = 10f } }) as CharacterCalculationsProtPaladin;
                    CharacterCalculationsProtPaladin calcHasteValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { HasteRating = 10f } }) as CharacterCalculationsProtPaladin;
                    CharacterCalculationsProtPaladin calcExpertiseValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { ExpertiseRating = 10f } }) as CharacterCalculationsProtPaladin;
                    CharacterCalculationsProtPaladin calcHitValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { HitRating = 10f } }) as CharacterCalculationsProtPaladin;
                    CharacterCalculationsProtPaladin calcHealthValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Health = (10f * 10f) / 0.667f } }) as CharacterCalculationsProtPaladin;
                    CharacterCalculationsProtPaladin calcResilValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Resilience = 10f } }) as CharacterCalculationsProtPaladin;
                    CharacterCalculationsProtPaladin calcMasteryValue = GetCharacterCalculations(character, new Item() { Stats = new Stats() { MasteryRating = 10f } }) as CharacterCalculationsProtPaladin;

                    //Differential Calculations for Agi
                    CharacterCalculationsProtPaladin calcAtAdd = calcBaseValue;
                    float agiToAdd = 0f;
                    while (calcBaseValue.OverallPoints == calcAtAdd.OverallPoints && agiToAdd < 2)
                    {
                        agiToAdd += 0.01f;
                        calcAtAdd = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Agility = agiToAdd } }) as CharacterCalculationsProtPaladin;
                    }

                    CharacterCalculationsProtPaladin calcAtSubtract = calcBaseValue;
                    float agiToSubtract = 0f;
                    while (calcBaseValue.OverallPoints == calcAtSubtract.OverallPoints && agiToSubtract > -2)
                    {
                        agiToSubtract -= 0.01f;
                        calcAtSubtract = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Agility = agiToSubtract } }) as CharacterCalculationsProtPaladin;
                    }
                    agiToSubtract += 0.01f;

                    ComparisonCalculationProtPaladin comparisonAgi = new ComparisonCalculationProtPaladin()
                    {
                        Name = "10 Agility",
                        OverallPoints = 10 * (calcAtAdd.OverallPoints - calcBaseValue.OverallPoints) / (agiToAdd - agiToSubtract),
                        MitigationPoints = 10 * (calcAtAdd.MitigationPoints - calcBaseValue.MitigationPoints) / (agiToAdd - agiToSubtract),
                        SurvivalPoints = 10 * (calcAtAdd.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints) / (agiToAdd - agiToSubtract),
                        ThreatPoints = 10 * (calcAtAdd.ThreatPoints - calcBaseValue.ThreatPoints) / (agiToAdd - agiToSubtract)
                    };

                    //Differential Calculations for Str
                    calcAtAdd = calcBaseValue;
                    float strToAdd = 0f;
                    while (calcBaseValue.OverallPoints == calcAtAdd.OverallPoints && strToAdd <= 22)
                    {
                        strToAdd += 0.01f;
                        calcAtAdd = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Strength = strToAdd } }) as CharacterCalculationsProtPaladin;
                    }

                    calcAtSubtract = calcBaseValue;
                    float strToSubtract = 0f;
                    while (calcBaseValue.OverallPoints == calcAtSubtract.OverallPoints && strToSubtract >= -22)
                    {
                        strToSubtract -= 0.01f;
                        calcAtSubtract = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Strength = strToSubtract } }) as CharacterCalculationsProtPaladin;
                    }
                    strToSubtract += 0.01f;

                    ComparisonCalculationProtPaladin comparisonStr = new ComparisonCalculationProtPaladin()
                    {
                        Name = "10 Strength",
                        OverallPoints = 10 * (calcAtAdd.OverallPoints - calcBaseValue.OverallPoints) / (strToAdd - strToSubtract),
                        MitigationPoints = 10 * (calcAtAdd.MitigationPoints - calcBaseValue.MitigationPoints) / (strToAdd - strToSubtract),
                        SurvivalPoints = 10 * (calcAtAdd.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints) / (strToAdd - strToSubtract),
                        ThreatPoints = 10 * (calcAtAdd.ThreatPoints - calcBaseValue.ThreatPoints) / (strToAdd - strToSubtract)
                    };


                    //Differential Calculations for AC
                    calcAtAdd = calcBaseValue;
                    float acToAdd = 0f;
                    while (calcBaseValue.OverallPoints == calcAtAdd.OverallPoints && acToAdd < 2)
                    {
                        acToAdd += 0.01f;
                        calcAtAdd = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Armor = acToAdd } }) as CharacterCalculationsProtPaladin;
                    }

                    calcAtSubtract = calcBaseValue;
                    float acToSubtract = 0f;
                    while (calcBaseValue.OverallPoints == calcAtSubtract.OverallPoints && acToSubtract > -2)
                    {
                        acToSubtract -= 0.01f;
                        calcAtSubtract = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Armor = acToSubtract } }) as CharacterCalculationsProtPaladin;
                    }
                    acToSubtract += 0.01f;

                    ComparisonCalculationProtPaladin comparisonAC = new ComparisonCalculationProtPaladin()
                    {
                        Name = "100 Armor",
                        OverallPoints = 100f * (calcAtAdd.OverallPoints - calcBaseValue.OverallPoints) / (acToAdd - acToSubtract),
                        MitigationPoints = 100f * (calcAtAdd.MitigationPoints - calcBaseValue.MitigationPoints) / (acToAdd - acToSubtract),
                        SurvivalPoints = 100f * (calcAtAdd.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints) / (acToAdd - acToSubtract),
                        ThreatPoints = 100f * (calcAtAdd.ThreatPoints - calcBaseValue.ThreatPoints) / (acToAdd - acToSubtract),
                    };


                    //Differential Calculations for Sta
                    calcAtAdd = calcBaseValue;
                    float staToAdd = 0f;
                    while (calcBaseValue.OverallPoints == calcAtAdd.OverallPoints && staToAdd < 2)
                    {
                        staToAdd += 0.01f;
                        calcAtAdd = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Stamina = staToAdd } }) as CharacterCalculationsProtPaladin;
                    }

                    calcAtSubtract = calcBaseValue;
                    float staToSubtract = 0f;
                    while (calcBaseValue.OverallPoints == calcAtSubtract.OverallPoints && staToSubtract > -2)
                    {
                        staToSubtract -= 0.01f;
                        calcAtSubtract = GetCharacterCalculations(character, new Item() { Stats = new Stats() { Stamina = staToSubtract } }) as CharacterCalculationsProtPaladin;
                    }
                    staToSubtract += 0.01f;

                    ComparisonCalculationProtPaladin comparisonSta = new ComparisonCalculationProtPaladin()
                    {
                        Name = "15 Stamina",
                        OverallPoints = (10f / 0.667f) * (calcAtAdd.OverallPoints - calcBaseValue.OverallPoints) / (staToAdd - staToSubtract),
                        MitigationPoints = (10f / 0.667f) * (calcAtAdd.MitigationPoints - calcBaseValue.MitigationPoints) / (staToAdd - staToSubtract),
                        SurvivalPoints = (10f / 0.667f) * (calcAtAdd.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints) / (staToAdd - staToSubtract),
                        ThreatPoints = (10f / 0.667f) * (calcAtAdd.ThreatPoints - calcBaseValue.ThreatPoints) / (staToAdd - staToSubtract)
                    };

                    return new ComparisonCalculationBase[] { 
                        comparisonStr,
                        comparisonAgi,
                        comparisonAC,
                        comparisonSta,
                        new ComparisonCalculationProtPaladin() { Name = "10 Dodge Rating",
                            OverallPoints = (calcDodgeValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcDodgeValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcDodgeValue.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints),
                            ThreatPoints = (calcDodgeValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtPaladin() { Name = "10 Parry Rating",
                            OverallPoints = (calcParryValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcParryValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcParryValue.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints),
                            ThreatPoints = (calcParryValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtPaladin() { Name = "10 Block Rating",
                            OverallPoints = (calcBlockValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcBlockValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcBlockValue.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints),
                            ThreatPoints = (calcBlockValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtPaladin() { Name = "10 Haste Rating",
                            OverallPoints = (calcHasteValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcHasteValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcHasteValue.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints),
                            ThreatPoints = (calcHasteValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtPaladin() { Name = "10 Expertise Rating",
                            OverallPoints = (calcExpertiseValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcExpertiseValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcExpertiseValue.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints),
                            ThreatPoints = (calcExpertiseValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtPaladin() { Name = "10 Hit Rating",
                            OverallPoints = (calcHitValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcHitValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcHitValue.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints),
                            ThreatPoints = (calcHitValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtPaladin() { Name = "150 Health",
                            OverallPoints = (calcHealthValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcHealthValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcHealthValue.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints),
                            ThreatPoints = (calcHealthValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtPaladin() { Name = "10 Resilience",
                            OverallPoints = (calcResilValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcResilValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcResilValue.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints),
                            ThreatPoints = (calcResilValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                        new ComparisonCalculationProtPaladin() { Name = "10 Mastery Rating",
                            OverallPoints = (calcMasteryValue.OverallPoints - calcBaseValue.OverallPoints), 
                            MitigationPoints = (calcMasteryValue.MitigationPoints - calcBaseValue.MitigationPoints),
                            SurvivalPoints = (calcMasteryValue.SurvivabilityPoints - calcBaseValue.SurvivabilityPoints),
                            ThreatPoints = (calcMasteryValue.ThreatPoints - calcBaseValue.ThreatPoints)},
                    };
                #endregion 
                #region Spell Resistance
                case "Combat Table: Spell Resistance":
                    {
                        ComparisonCalculationProtPaladin calcSpellRes0   = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcSpellRes10  = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcSpellRes20  = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcSpellRes30  = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcSpellRes40  = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcSpellRes50  = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcSpellRes60  = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcSpellRes70  = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcSpellRes80  = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcSpellRes90  = new ComparisonCalculationProtPaladin();
                        ComparisonCalculationProtPaladin calcSpellRes100 = new ComparisonCalculationProtPaladin();
                        
                        if (calculations != null)
                        {
                            calcSpellRes0.Name   = "0.00";
                            calcSpellRes10.Name  = "0.10";
                            calcSpellRes20.Name  = "0.20";
                            calcSpellRes30.Name  = "0.30";
                            calcSpellRes40.Name  = "0.40";
                            calcSpellRes50.Name  = "0.50";
                            calcSpellRes60.Name  = "0.60";
                            calcSpellRes70.Name  = "0.70";
                            calcSpellRes80.Name  = "0.80";
                            calcSpellRes90.Name  = "0.90";
                            calcSpellRes100.Name = "1.00";

                            calcSpellRes0.OverallPoints   = calcSpellRes0.MitigationPoints = calculations.ResistanceTable[0] * 100.0f;
                            calcSpellRes10.OverallPoints  = calcSpellRes10.MitigationPoints = calculations.ResistanceTable[1] * 100.0f;
                            calcSpellRes20.OverallPoints  = calcSpellRes20.MitigationPoints = calculations.ResistanceTable[2] * 100.0f;
                            calcSpellRes30.OverallPoints  = calcSpellRes30.MitigationPoints = calculations.ResistanceTable[3] * 100.0f;
                            calcSpellRes40.OverallPoints  = calcSpellRes40.MitigationPoints = calculations.ResistanceTable[4] * 100.0f;
                            calcSpellRes50.OverallPoints  = calcSpellRes50.MitigationPoints = calculations.ResistanceTable[5] * 100.0f;
                            calcSpellRes60.OverallPoints  = calcSpellRes60.MitigationPoints = calculations.ResistanceTable[6] * 100.0f;
                            calcSpellRes70.OverallPoints  = calcSpellRes70.MitigationPoints = calculations.ResistanceTable[7] * 100.0f;
                            calcSpellRes80.OverallPoints  = calcSpellRes80.MitigationPoints = calculations.ResistanceTable[8] * 100.0f;
                            calcSpellRes90.OverallPoints  = calcSpellRes90.MitigationPoints = calculations.ResistanceTable[9] * 100.0f;
                            calcSpellRes100.OverallPoints = calcSpellRes100.MitigationPoints = calculations.ResistanceTable[10] * 100.0f;
                        }
                        return new ComparisonCalculationBase[] { calcSpellRes0, calcSpellRes10, calcSpellRes20, calcSpellRes30, calcSpellRes40, calcSpellRes50, calcSpellRes60, calcSpellRes70, calcSpellRes80, calcSpellRes90, calcSpellRes100 };
                    }
                #endregion
                default:
                    return new ComparisonCalculationBase[0];
            }
        }
Exemplo n.º 15
0
        public static void RenderScalingGraph(Graphics g, int graphWidth, int graphHeight, Character character, Stats[] statsList, Stats baseStat, bool requiresReferenceCalculations, Color[] colors, int scale, string explanatoryText, string calculation, Style style)
        {
            CharacterCalculationsBase baseCalc = Calculations.GetCharacterCalculations(character);

            g.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            float graphOffset = graphWidth / 2.0f, graphStep = (graphWidth - 100) / 2.0f / scale;

            if (statsList.Length == 0 || statsList.Length > colors.Length)
            {
                return;                                                            // more than 12 elements for the array would run out of colours
            }
            float minDpsChange = 0f, maxDpsChange = 0f;

            PointF[][] points = new PointF[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 PointF[2 * scale + 1];
            }
            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 PointF(graphOffset + count * graphStep, dpsChange);
                    if (dpsChange < minDpsChange)
                    {
                        minDpsChange = dpsChange;
                    }
                    if (dpsChange > maxDpsChange)
                    {
                        maxDpsChange = dpsChange;
                    }
                }
            }
            // restore reference calculation
            if (requiresReferenceCalculations)
            {
                Stats newStats = new Stats();
                Item  item     = new Item()
                {
                    Stats = newStats
                };
                Calculations.GetCharacterCalculations(character, item, true, false, false);
            }
            // increase the spread a bit to so that you can see if something is at the edges and straight
            float DpsVariance = maxDpsChange - minDpsChange;

            minDpsChange -= DpsVariance * 0.05f;
            maxDpsChange += DpsVariance * 0.05f;
            DpsVariance   = maxDpsChange - minDpsChange;
            if (DpsVariance == 0)
            {
                DpsVariance = 1;
            }
            for (int index = 0; index < statsList.Length; index++)
            {
                for (int count = -scale; count <= scale; count++)
                {
                    points[index][count + scale].Y = (int)((maxDpsChange - points[index][count + scale].Y) * (graphHeight - 48) / DpsVariance) + 20;
                }
                Brush statBrush = new SolidBrush(colors[index]);
                switch (style)
                {
                case Style.DpsWarr:
                    g.DrawLines(new Pen(statBrush, 3), points[index]);
                    break;

                case Style.Mage:
                    g.DrawLines(new Pen(statBrush, 1), points[index]);
                    break;
                }
            }
            float unit = 1f;
            var   bp   = baseStat.Values(x => x > 0);

            foreach (var kvp in bp)
            {
                unit = kvp.Value;
            }
            RenderGrid(g, graphWidth, graphHeight, character, statsList, colors, scale, unit, "F", explanatoryText, calculation, style, minDpsChange, maxDpsChange, DpsVariance, false);
        }
Exemplo n.º 16
0
        //
        // Data for custom charts:
        //
        public override ComparisonCalculationBase[] GetCustomChartData(Character character, string chartName)
        {
            CharacterCalculationsRestoSham calc = GetCharacterCalculations(character) as CharacterCalculationsRestoSham;

            if (calc == null)
            {
                calc = new CharacterCalculationsRestoSham();
            }

            CalculationOptionsRestoSham options = character.CalculationOptions as CalculationOptionsRestoSham;

            if (options == null)
            {
                options = new CalculationOptionsRestoSham();
            }

            List <ComparisonCalculationBase> list = new List <ComparisonCalculationBase>();

            switch (chartName)
            {
            case "Stat Relative Weights":
                StatRelativeWeight[] stats = new StatRelativeWeight[] {
                    new StatRelativeWeight("Int", new Stats()
                    {
                        Intellect = 1f
                    }),
                    new StatRelativeWeight("Spirit", new Stats()
                    {
                        Spirit = 1f
                    }),
                    new StatRelativeWeight("+Heal", new Stats()
                    {
                        Healing = 1f
                    }),
                    new StatRelativeWeight("Mp5", new Stats()
                    {
                        Mp5 = 1f
                    }),
                    new StatRelativeWeight("Spell Crit", new Stats()
                    {
                        SpellCritRating = 1f
                    })
                };

                // Get the percentage total healing is changed by a change in a single stat:

                float healPct = 0f;
                foreach (StatRelativeWeight weight in stats)
                {
                    CharacterCalculationsRestoSham statCalc = (CharacterCalculationsRestoSham)GetCharacterCalculations(character, null, weight.Stat);
                    weight.PctChange = (statCalc.TotalHealed - calc.TotalHealed) / calc.TotalHealed;
                    if (weight.Name == "+Heal")
                    {
                        healPct = weight.PctChange;
                    }
                }

                // Create the chart data points:

                foreach (StatRelativeWeight weight in stats)
                {
                    ComparisonCalculationRestoSham comp = new ComparisonCalculationRestoSham(weight.Name);
                    comp.OverallPoints = weight.PctChange / healPct;
                    comp.SubPoints[0]  = comp.OverallPoints;
                    list.Add(comp);
                }

                break;

            case "Healing Spell Ranks":
                // Healing Wave ranks:

                for (int i = 1; i <= 12; i++)
                {
                    HealingWave hw = new HealingWave(i);
                    hw.Calcluate(calc.BasicStats, character);
                    ComparisonCalculationRestoSham comp = new ComparisonCalculationRestoSham(hw.FullName);
                    comp.OverallPoints = hw.AverageHealed + hw.HealingWay;
                    comp.SubPoints[0]  = hw.AverageHealed;
                    comp.SubPoints[3]  = hw.HealingWay;
                    list.Add(comp);
                }

                // Lesser Healing Wave ranks:

                for (int i = 1; i <= 7; i++)
                {
                    LesserHealingWave lhw = new LesserHealingWave(i);
                    lhw.Calcluate(calc.BasicStats, character);
                    ComparisonCalculationRestoSham comp = new ComparisonCalculationRestoSham(lhw.FullName);
                    comp.OverallPoints = comp.SubPoints[0] = lhw.AverageHealed;
                    list.Add(comp);
                }

                // Chain Heal ranks:

                for (int i = 1; i <= 5; i++)
                {
                    ChainHeal ch = new ChainHeal(i);
                    ch.Calcluate(calc.BasicStats, character);
                    ComparisonCalculationRestoSham comp = new ComparisonCalculationRestoSham(ch.FullName);
                    comp.OverallPoints = ch.TotalHealed;
                    for (int j = 0; j < 3; j++)
                    {
                        comp.SubPoints[j] = ch.HealsOnTargets[j];
                    }
                    list.Add(comp);
                }

                // The Draenei racial:

                if (character.Race == Character.CharacterRace.Draenei)
                {
                    GiftOfTheNaaru gift = new GiftOfTheNaaru();
                    gift.Calcluate(calc.BasicStats, character);
                    ComparisonCalculationRestoSham comp = new ComparisonCalculationRestoSham(gift.FullName);
                    comp.OverallPoints = comp.SubPoints[0] = gift.AverageHealed;
                    list.Add(comp);
                }

                break;
            }

            ComparisonCalculationBase[] retVal = new ComparisonCalculationBase[list.Count];
            if (list.Count > 0)
            {
                list.CopyTo(retVal);
            }
            return(retVal);
        }
Exemplo n.º 17
0
        private ComparisonCalculationBase[] EvaluateItemBudget(Character character, Stats[] statsList)
        {
            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;
                }
            }
            Item item = new Item() { Stats = new Stats() };
            ComparisonCalculationBase[] result = new ComparisonCalculationBase[statsList.Length];
            for (int index = 0; index < statsList.Length; index++)
            {
                result[index] = CalculationsBase.GetRelativeStatValue(character, properties[index].Key, item, properties[index].Value);
            }

            return result;
        }
Exemplo n.º 18
0
 public ItemListItem(ComparisonCalculationBase calc, double maxValue, double maxWidth)
 {
     _calc = calc;
     _maxValue = maxValue;
     _maxWidth = maxWidth;
 }
Exemplo n.º 19
0
 private bool SearchPredicate(string searchText, ItemInstance source1, ComparisonCalculationBase source2) {
     if (CK_UseRegex.IsChecked.GetValueOrDefault(false)) {
         Regex regex = new Regex(searchText);
         if (source1 != null)  {
             if (regex.Match(source1.Name).Success) return true;
             if (!string.IsNullOrEmpty(source1.Item.SetName) && regex.Match(source1.Item.SetName).Success) return true;
             if (regex.Match(source1.Id.ToString()).Success) return true;
             if (regex.Match(source1.Item.GetFullLocationDesc).Success) return true;
         } else {
             if (regex.Match(source2.Name).Success) return true;
             if (!string.IsNullOrEmpty(source2.Item.SetName) && regex.Match(source2.Item.SetName).Success) return true;
             if (regex.Match(source2.Item.Id.ToString()).Success) return true;
             if (regex.Match(source2.Item.GetFullLocationDesc).Success) return true;
         }
     } else {
         if (source1 != null)  {
             if (source1.Name.Contains(searchText)) return true;
             if (!string.IsNullOrEmpty(source1.Item.SetName) && source1.Item.SetName.Contains(searchText)) return true;
             if (source1.Id.ToString().Contains(searchText)) return true;
             if (source1.Item.GetFullLocationDesc.Contains(searchText)) return true;
         } else {
             if (source2.Name.Contains(searchText)) return true;
             if (!string.IsNullOrEmpty(source2.Item.SetName) && source2.Item.SetName.Contains(searchText)) return true;
             if (source2.Item.Id.ToString().Contains(searchText)) return true;
             if (source2.Item.GetFullLocationDesc.Contains(searchText)) return true;
         }
     }
     // Return false because it didn't pass any of the above checks
     return false;
 }
Exemplo n.º 20
0
 private static float GetCalculationValue(ComparisonCalculationBase calcs, string calculation)
 {
     if (calculation == null || calculation == "Overall Rating")
         return calcs.OverallPoints;
     else
     {
         int index = 0;
         foreach (string subPoint in Calculations.SubPointNameColors.Keys)
         {
             if (calculation.StartsWith(subPoint, StringComparison.Ordinal))
                 return calcs.SubPoints[index];
             index++;
         }
         return 0f;
     }
 }