Exemple #1
0
        public void LoadCurrentGearEnchantsBuffs(CharacterCalculationsBase currentCalculations)
        {
            List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>();

            if (Character != null)
            {
                foreach (CharacterSlot slot in Enum.GetValues(typeof(CharacterSlot)))
                {
                    if (Character[slot] != null)
                    {
                        itemCalculations.Add(Calculations.GetItemCalculations(Character[slot], Character, slot));
                    }
                }

                foreach (ComparisonCalculationBase calc in Calculations.GetEnchantCalculations(ItemSlot.None, Character, currentCalculations, true))
                {
                    itemCalculations.Add(calc);
                }

                foreach (ComparisonCalculationBase calc in Calculations.GetBuffCalculations(Character, currentCalculations, "Current"))
                {
                    itemCalculations.Add(calc);
                }
            }

            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.ItemCalculations = itemCalculations.ToArray();
            comparisonGraph1.EquipSlot        = CharacterSlot.None;
            _characterSlot = CharacterSlot.None;
        }
Exemple #2
0
        private void GetItemCalculations(object item)
        {
            //Trace.WriteLine("Starting Calculation for: " + item.ToString());
            ComparisonCalculationBase result = Calculations.GetItemCalculations((Item)item, Character, _characterSlot);

            _itemCalculations[Interlocked.Increment(ref _calculationCount) - 1] = result;
            if (_calculationCount == _itemCalculations.Length)
            {
                _autoResetEvent.Set();
            }
            //Trace.WriteLine("Finished Calculation for: " + item.ToString());
        }
Exemple #3
0
 public void LoadGearBySlot(Character.CharacterSlot slot)
 {
     if (slot != _characterSlot)
     {
         _characterSlot = slot;
         List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>();
         if (this.Items != null && this.Character != null)
         {
             foreach (Item item in this.Items)
             {
                 if (item.FitsInSlot(slot))
                 {
                     itemCalculations.Add(Calculations.GetItemCalculations(item, this.Character, slot));
                 }
             }
         }
         itemCalculations.Sort(new System.Comparison <ComparisonCalculationBase>(CompareItemCalculations));
         ItemCalculations = itemCalculations.ToArray();
     }
 }
Exemple #4
0
        public void LoadGearBySlot(Character.CharacterSlot slot)
        {
            Calculations.ClearCache();
            List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>();

            if (Items != null && Character != null)
            {
                foreach (Item item in Items)
                {
                    if (item.FitsInSlot(slot))
                    {
                        itemCalculations.Add(Calculations.GetItemCalculations(item, Character, slot));
                    }
                }
            }

            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.ItemCalculations = itemCalculations.ToArray();
            comparisonGraph1.EquipSlot        = slot == Character.CharacterSlot.Gems || slot == Character.CharacterSlot.Metas ?
                                                Character.CharacterSlot.None : slot;
        }
Exemple #5
0
 private void AddGemToItemCalculations(List <ComparisonCalculationBase> itemCalculations, Item item)
 {
     if (item.IsJewelersGem)
     {
         if (!Rawr.Properties.GeneralSettings.Default.HideProfEnchants || this.Character.HasProfession(Profession.Jewelcrafting))
         {
             if (Character.JewelersGemCount < 3)
             {
                 itemCalculations.Add(Calculations.GetItemCalculations(item, this.Character, CharacterSlot.Gems));
             }
             else
             {
                 Item nullItem = item.Clone();
                 nullItem.Stats = new Stats();
                 itemCalculations.Add(Calculations.GetItemCalculations(nullItem, this.Character, CharacterSlot.Gems));
             }
         }
     }
     else if (item.IsLimitedGem)
     {
         if (!Character.IsUniqueGemEquipped(item))
         {
             itemCalculations.Add(Calculations.GetItemCalculations(item, this.Character, CharacterSlot.Gems));
         }
         else
         {
             Item nullItem = item.Clone();
             nullItem.Stats = new Stats();
             itemCalculations.Add(Calculations.GetItemCalculations(nullItem, this.Character, CharacterSlot.Gems));
         }
     }
     else
     {
         itemCalculations.Add(Calculations.GetItemCalculations(item, this.Character, CharacterSlot.Gems));
     }
 }
Exemple #6
0
        public void LoadItemsBySlot(CharacterSlot slot)
        {
            if (_characterSlot != slot)
            {
                _characterSlot = slot;
                List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>();
                if ((int)slot >= 0 && (int)slot <= 20)
                {
                    if (this.Character != null)
                    {
                        bool seenEquippedItem = Character[slot] == null;
                        foreach (ItemInstance item in Character.GetRelevantItemInstances(slot))
                        {
                            if (!seenEquippedItem && Character[slot].Equals(item))
                            {
                                seenEquippedItem = true;
                            }
                            if (item.Item.FitsInSlot(slot, Character))
                            {
                                itemCalculations.Add(Calculations.GetItemCalculations(item, this.Character, slot));
                            }
                        }
                        if (!seenEquippedItem)
                        {
                            itemCalculations.Add(Calculations.GetItemCalculations(Character[slot], this.Character, slot));
                        }
                    }
                    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        = this.Character[slot] == null;
                    itemCalculations.Add(emptyCalcs);
                }
                else
                {
                    if (this.Character != null)
                    {
                        bool seenEquippedItem = false;
                        if (_button != null && _button.SelectedItem == null)
                        {
                            seenEquippedItem = true;
                        }
                        foreach (Item item in Character.GetRelevantItems(slot))
                        {
                            if (!seenEquippedItem && _button != null && item.Equals(_button.SelectedItem))
                            {
                                seenEquippedItem = true;
                            }
                            if (item.FitsInSlot(slot, Character))
                            {
                                if (slot == CharacterSlot.Gems)
                                {
                                    AddGemToItemCalculations(itemCalculations, item);
                                }
                                else
                                {
                                    itemCalculations.Add(Calculations.GetItemCalculations(item, this.Character, slot));
                                }
                            }
                        }
                        if (!seenEquippedItem && _button != null && _button.SelectedItem != null)
                        {
                            itemCalculations.Add(Calculations.GetItemCalculations(_button.SelectedItem, this.Character, slot));
                        }
                    }
                    ComparisonCalculationBase emptyCalcs = Calculations.CreateNewComparisonCalculation();
                    emptyCalcs.Name            = "Empty";
                    emptyCalcs.Item            = new Item();
                    emptyCalcs.Item.Name       = "Empty";
                    emptyCalcs.ItemInstance    = new ItemInstance();
                    emptyCalcs.ItemInstance.Id = -1;
                    if (_button != null && _button.SelectedItem != null)
                    {
                        emptyCalcs.Equipped = _button.SelectedItem == null;
                    }
                    else
                    {
                        emptyCalcs.Equipped = false;
                    }
                    itemCalculations.Add(emptyCalcs);
                }
                itemCalculations.Sort(new System.Comparison <ComparisonCalculationBase>(CompareItemCalculations));
                Dictionary <int, int>            countItem = new Dictionary <int, int>();
                List <ComparisonCalculationBase> filteredItemCalculations = new List <ComparisonCalculationBase>();

                for (int i = itemCalculations.Count - 1; i >= 0; i--)
                //foreach (ComparisonCalculationBase itemCalculation in itemCalculations)
                {
                    ComparisonCalculationBase itemCalculation = itemCalculations[i];
                    int itemId = (itemCalculation.ItemInstance == null ? itemCalculation.Item.Id : itemCalculation.ItemInstance.Id);
                    if (!countItem.ContainsKey(itemId))
                    {
                        countItem.Add(itemId, 0);
                    }
                    if (countItem[itemId]++ < Properties.GeneralSettings.Default.CountGemmingsShown ||
                        itemCalculation.Equipped || itemCalculation.ItemInstance.ForceDisplay)
                    {
                        filteredItemCalculations.Add(itemCalculation);
                    }
                }
                ItemCalculations = filteredItemCalculations.ToArray();
            }
        }
Exemple #7
0
        public void LoadGearBySlot(CharacterSlot slot, ItemSlot gemColour)
        {
            Calculations.ClearCache();
            //_itemCalculations = new List<ComparisonCalculationBase>();
            _characterSlot = slot;
            bool useMultithreading = Calculations.SupportsMultithreading && Rawr.Properties.GeneralSettings.Default.UseMultithreading;
            bool presorted         = false;

            if (Character != null)
            {
                if ((int)slot >= 0 && (int)slot <= 20)
                { //Normal Gear Slots
                    presorted = true;
                    bool seenEquippedItem = (Character[slot] == null);

                    List <ItemInstance> relevantItemInstances = Character.GetRelevantItemInstances(slot);
                    _itemCalculations = new ComparisonCalculationBase[relevantItemInstances.Count];
                    _calculationCount = 0;
                    _autoResetEvent   = new AutoResetEvent(!useMultithreading);
                    DateTime before = DateTime.Now;
                    if (relevantItemInstances.Count > 0)
                    {
                        foreach (ItemInstance item in relevantItemInstances)
                        {
                            if (!seenEquippedItem && Character[slot].Equals(item))
                            {
                                seenEquippedItem = true;
                            }
                            //Trace.WriteLine("Queuing WorkItem for item: " + item.ToString());
                            //Queue each item into the ThreadPool
                            if (useMultithreading)
                            {
                                ThreadPool.QueueUserWorkItem(GetItemInstanceCalculations, item);
                            }
                            else
                            {
                                GetItemInstanceCalculations(item);
                            }
                        }
                        //Wait for all items to be processed
                        _autoResetEvent.WaitOne();
                        //Trace.WriteLine(DateTime.Now.Subtract(before).Ticks);
                        //Trace.WriteLine("Finished all Calculations");
                    }

                    // add item
                    List <ComparisonCalculationBase> listItemCalculations = new List <ComparisonCalculationBase>(_itemCalculations);
                    if (!seenEquippedItem)
                    {
                        listItemCalculations.Add(Calculations.GetItemCalculations(Character[slot], Character, slot));
                    }

                    _itemCalculations = FilterTopXGemmings(listItemCalculations);
                }
                else
                {                                  //Gems/Metas
                    Character.ClearRelevantGems(); // we need to reset relevant items for gems to allow colour selection
                    List <Item> relevantItems = Character.GetRelevantItems(slot, gemColour);
                    _itemCalculations = new ComparisonCalculationBase[relevantItems.Count];
                    _calculationCount = 0;
                    if (relevantItems.Count > 0)
                    {
                        _autoResetEvent = new AutoResetEvent(!useMultithreading);
                        //DateTime before = DateTime.Now;
                        foreach (Item item in relevantItems)
                        {
                            if (useMultithreading)
                            {
                                ThreadPool.QueueUserWorkItem(GetItemCalculations, item);
                            }
                            else
                            {
                                GetItemCalculations(item);
                            }
                        }
                        //Wait for all items to be processed
                        _autoResetEvent.WaitOne();
                        //Trace.WriteLine(DateTime.Now.Subtract(before).Ticks);
                    }
                }
            }

            comparisonGraph1.RoundValues    = true;
            comparisonGraph1.CustomRendered = false;
            if (presorted)
            {
                comparisonGraph1.LoadItemCalculationsPreSorted(_itemCalculations);
            }
            else
            {
                comparisonGraph1.ItemCalculations = _itemCalculations;
            }
            comparisonGraph1.EquipSlot = slot == CharacterSlot.Gems || slot == CharacterSlot.Metas ?
                                         CharacterSlot.None : slot;
        }
Exemple #8
0
        /// <summary>
        /// Direct Upgrades
        /// </summary>
        /// <param name="currentCalculations"></param>
        /// <param name="divideByCost">When true it only includes items with positive cost and shows upgrade value / cost</param>
        public void LoadAvailableGear(CharacterCalculationsBase currentCalculations, bool divideByCost)
        {
            List <ComparisonCalculationBase>     itemCalculations = new List <ComparisonCalculationBase>();
            SortedList <ItemSlot, CharacterSlot> slotMap          = new SortedList <ItemSlot, CharacterSlot>();

            if (Character != null)
            {
                SortedList <string, ItemInstance> items = new SortedList <string, ItemInstance>();

                float Finger1 = (Character[CharacterSlot.Finger1] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[CharacterSlot.Finger1], Character, CharacterSlot.Finger1).OverallPoints);
                float Finger2 = (Character[CharacterSlot.Finger2] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[CharacterSlot.Finger2], Character, CharacterSlot.Finger2).OverallPoints);

                float Trinket1 = (Character[CharacterSlot.Trinket1] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[CharacterSlot.Trinket1], Character, CharacterSlot.Trinket1).OverallPoints);
                float Trinket2 = (Character[CharacterSlot.Trinket2] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[CharacterSlot.Trinket2], Character, CharacterSlot.Trinket2).OverallPoints);

                if (Finger2 < Finger1)
                {
                    slotMap[ItemSlot.Finger] = CharacterSlot.Finger2;
                }

                if (Trinket2 < Trinket1)
                {
                    slotMap[ItemSlot.Trinket] = CharacterSlot.Trinket2;
                }

                float MainHand = (Character[CharacterSlot.MainHand] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[CharacterSlot.MainHand], Character, CharacterSlot.MainHand).OverallPoints);
                float OffHand = (Character[CharacterSlot.OffHand] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[CharacterSlot.OffHand], Character, CharacterSlot.OffHand).OverallPoints);

                if (MainHand > OffHand)
                {
                    slotMap[ItemSlot.OneHand] = CharacterSlot.OffHand;
                }

                foreach (KeyValuePair <ItemSlot, CharacterSlot> kvp in Item.DefaultSlotMap)
                {
                    try
                    {
                        ItemSlot      iSlot = kvp.Key;
                        CharacterSlot slot;

                        if (slotMap.ContainsKey(iSlot))
                        {
                            slot = slotMap[iSlot];
                        }
                        else
                        {
                            slot = kvp.Value;
                        }
                        if (slot != CharacterSlot.None)
                        {
                            ComparisonCalculationBase slotCalc;
                            ItemInstance currentItem = Character[slot];
                            if (currentItem == null)
                            {
                                slotCalc = Calculations.CreateNewComparisonCalculation();
                            }
                            else
                            {
                                slotCalc = Calculations.GetItemCalculations(currentItem, Character, slot);
                            }

                            foreach (ItemInstance item in Character.GetRelevantItemInstances(slot))
                            {
                                if (!items.ContainsKey(item.GemmedId) && (currentItem == null || currentItem.GemmedId != item.GemmedId))
                                {
                                    if (currentItem != null && currentItem.Item.Unique)
                                    {
                                        CharacterSlot otherSlot = CharacterSlot.None;
                                        switch (slot)
                                        {
                                        case CharacterSlot.Finger1:
                                            otherSlot = CharacterSlot.Finger2;
                                            break;

                                        case CharacterSlot.Finger2:
                                            otherSlot = CharacterSlot.Finger1;
                                            break;

                                        case CharacterSlot.Trinket1:
                                            otherSlot = CharacterSlot.Trinket2;
                                            break;

                                        case CharacterSlot.Trinket2:
                                            otherSlot = CharacterSlot.Trinket1;
                                            break;

                                        case CharacterSlot.MainHand:
                                            otherSlot = CharacterSlot.OffHand;
                                            break;

                                        case CharacterSlot.OffHand:
                                            otherSlot = CharacterSlot.MainHand;
                                            break;
                                        }
                                        if (otherSlot != CharacterSlot.None && Character[otherSlot] != null && (Character[otherSlot].Id == item.Id || (item.Item.UniqueId != null && item.Item.UniqueId.Contains(Character[otherSlot].Id))))
                                        {
                                            continue;
                                        }
                                    }

                                    if (!divideByCost || item.Item.Cost > 0.0f)
                                    {
                                        ComparisonCalculationBase itemCalc = Calculations.GetItemCalculations(item, Character, slot);
                                        //bool include = false;
                                        //for (int i = 0; i < itemCalc.SubPoints.Length; i++)
                                        //{
                                        //    itemCalc.SubPoints[i] -= slotCalc.SubPoints[i];
                                        //    include |= itemCalc.SubPoints[i] > 0;
                                        //}
                                        //itemCalc.OverallPoints -= slotCalc.OverallPoints;
                                        //if ( itemCalc.OverallPoints > 0)
                                        //{
                                        //    itemCalculations.Add(itemCalc);
                                        //}

                                        float difference = itemCalc.OverallPoints - slotCalc.OverallPoints;
                                        if (difference > 0)
                                        {
                                            itemCalc.SubPoints = new float[itemCalc.SubPoints.Length];
                                            if (divideByCost)
                                            {
                                                itemCalc.OverallPoints = difference / item.Item.Cost;
                                            }
                                            else
                                            {
                                                itemCalc.OverallPoints = difference;
                                            }
                                            itemCalculations.Add(itemCalc);
                                        }
                                    }

                                    items[item.GemmedId] = item;
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.DisplayMode      = ComparisonGraph.GraphDisplayMode.Overall;
            comparisonGraph1.ItemCalculations = FilterTopXGemmings(itemCalculations);
            comparisonGraph1.EquipSlot        = CharacterSlot.AutoSelect;
            comparisonGraph1.SlotMap          = slotMap;
            _characterSlot = CharacterSlot.None;
        }
Exemple #9
0
        public void LoadAvailableGear(CharacterCalculationsBase currentCalculations)
        {
            List <ComparisonCalculationBase> itemCalculations           = new List <ComparisonCalculationBase>();
            SortedList <Item.ItemSlot, Character.CharacterSlot> slotMap = new SortedList <Item.ItemSlot, Character.CharacterSlot>();

            if (Items != null && Character != null)
            {
                SortedList <string, Item> items = new SortedList <string, Item>();

                float Finger1 = (Character[Character.CharacterSlot.Finger1] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[Character.CharacterSlot.Finger1], Character, Character.CharacterSlot.Finger1).OverallPoints);
                float Finger2 = (Character[Character.CharacterSlot.Finger2] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[Character.CharacterSlot.Finger2], Character, Character.CharacterSlot.Finger2).OverallPoints);

                float Trinket1 = (Character[Character.CharacterSlot.Trinket1] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[Character.CharacterSlot.Trinket1], Character, Character.CharacterSlot.Trinket1).OverallPoints);
                float Trinket2 = (Character[Character.CharacterSlot.Trinket2] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[Character.CharacterSlot.Trinket2], Character, Character.CharacterSlot.Trinket2).OverallPoints);

                if (Finger2 < Finger1)
                {
                    slotMap[Item.ItemSlot.Finger] = Character.CharacterSlot.Finger2;
                }

                if (Trinket2 < Trinket1)
                {
                    slotMap[Item.ItemSlot.Trinket] = Character.CharacterSlot.Trinket2;
                }

                float MainHand = (Character[Character.CharacterSlot.MainHand] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[Character.CharacterSlot.MainHand], Character, Character.CharacterSlot.MainHand).OverallPoints);
                float OffHand = (Character[Character.CharacterSlot.OffHand] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[Character.CharacterSlot.OffHand], Character, Character.CharacterSlot.OffHand).OverallPoints);

                if (MainHand > OffHand)
                {
                    slotMap[Item.ItemSlot.OneHand] = Character.CharacterSlot.OffHand;
                }



                foreach (Item relevantItem in ItemCache.RelevantItems)
                {
                    try
                    {
                        Item.ItemSlot           iSlot = relevantItem.Slot;
                        Character.CharacterSlot slot;

                        if (slotMap.ContainsKey(iSlot))
                        {
                            slot = slotMap[iSlot];
                        }
                        else
                        {
                            slot = Item.DefaultSlotMap[iSlot];
                        }
                        if (slot != Character.CharacterSlot.None)
                        {
                            ComparisonCalculationBase slotCalc;
                            Item currentItem = Character[slot];
                            if (currentItem == null)
                            {
                                slotCalc = Calculations.CreateNewComparisonCalculation();
                            }
                            else
                            {
                                slotCalc = Calculations.GetItemCalculations(currentItem, Character, slot);
                            }

                            foreach (Item item in ItemCache.Instance.FindAllItemsById(relevantItem.Id))
                            {
                                if (!items.ContainsKey(item.GemmedId) && (currentItem == null || currentItem.GemmedId != item.GemmedId))
                                {
                                    if (currentItem != null && currentItem.Unique)
                                    {
                                        Character.CharacterSlot otherSlot = Character.CharacterSlot.None;
                                        switch (slot)
                                        {
                                        case Character.CharacterSlot.Finger1:
                                            otherSlot = Character.CharacterSlot.Finger2;
                                            break;

                                        case Character.CharacterSlot.Finger2:
                                            otherSlot = Character.CharacterSlot.Finger1;
                                            break;

                                        case Character.CharacterSlot.Trinket1:
                                            otherSlot = Character.CharacterSlot.Trinket2;
                                            break;

                                        case Character.CharacterSlot.Trinket2:
                                            otherSlot = Character.CharacterSlot.Trinket1;
                                            break;

                                        case Character.CharacterSlot.MainHand:
                                            otherSlot = Character.CharacterSlot.OffHand;
                                            break;

                                        case Character.CharacterSlot.OffHand:
                                            otherSlot = Character.CharacterSlot.MainHand;
                                            break;
                                        }
                                        if (otherSlot != Character.CharacterSlot.None && Character[otherSlot] != null && Character[otherSlot].Id == item.Id)
                                        {
                                            continue;
                                        }
                                    }

                                    ComparisonCalculationBase itemCalc = Calculations.GetItemCalculations(item, Character, slot);
                                    bool include = false;
                                    for (int i = 0; i < itemCalc.SubPoints.Length; i++)
                                    {
                                        itemCalc.SubPoints[i] -= slotCalc.SubPoints[i];
                                        include |= itemCalc.SubPoints[i] > 0;
                                    }
                                    itemCalc.OverallPoints -= slotCalc.OverallPoints;
                                    if (itemCalc.OverallPoints > 0)
                                    {
                                        itemCalculations.Add(itemCalc);
                                    }
                                    items[item.GemmedId] = item;
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.DisplayMode      = ComparisonGraph.GraphDisplayMode.Overall;
            comparisonGraph1.ItemCalculations = itemCalculations.ToArray();
            comparisonGraph1.EquipSlot        = Character.CharacterSlot.AutoSelect;
            comparisonGraph1.SlotMap          = slotMap;
        }