Пример #1
0
        public void Show(Item item)
        {
            _item = item;
            _menuItemName.Text = item.Name;
            Character.ItemAvailability availability = Character.GetItemAvailability(_item);
            string gemmedId   = string.Empty;
            bool   allEnabled = false;

            switch (availability)
            {
            case Character.ItemAvailability.Available:
                gemmedId   = item.GemmedId;
                allEnabled = true;
                break;

            case Character.ItemAvailability.AvailableWithEnchantRestrictions:
                gemmedId = item.GemmedId;
                break;

            case Character.ItemAvailability.RegemmingAllowed:
                allEnabled = true;
                break;

            case Character.ItemAvailability.RegemmingAllowedWithEnchantRestrictions:
                gemmedId = item.Id.ToString() + ".*.*.*";
                break;

            case Character.ItemAvailability.NotAvailabe:
                gemmedId = item.Id.ToString() + ".*.*.*";
                break;
            }

            ((ToolStripMenuItem)Items[2]).Checked = allEnabled;
            List <Enchant> list = Enchant.FindEnchants(_item.Slot);

            for (int i = 0; i < list.Count; i++)
            {
                if (Items.Count <= i + 3)
                {
                    ToolStripMenuItem _menuItem = new ToolStripMenuItem();
                    _menuItem.Click += new EventHandler(_menuItem_Click);
                    this.Items.Add(_menuItem);
                }
                Items[i + 3].Tag     = list[i];
                Items[i + 3].Text    = list[i].ToString();
                Items[i + 3].Visible = true;
                ((ToolStripMenuItem)Items[i + 3]).Checked = (!allEnabled && Character.AvailableItems.Contains(gemmedId + "." + list[i].Id));
            }
            for (int i = list.Count + 3; i < Items.Count; i++)
            {
                Items[i].Visible = false;
            }

            this.Show(Control.MousePosition);
        }
Пример #2
0
        public virtual List <ComparisonCalculationBase> GetEnchantCalculations(Item.ItemSlot slot, Character character, CharacterCalculationsBase currentCalcs)
        {
            ClearCache();
            List <ComparisonCalculationBase> enchantCalcs    = new List <ComparisonCalculationBase>();
            CharacterCalculationsBase        calcsEquipped   = null;
            CharacterCalculationsBase        calcsUnequipped = null;

            foreach (Enchant enchant in Enchant.FindEnchants(slot))
            {
                //if (enchantCalcs.ContainsKey(enchant.Id)) continue;

                bool isEquipped = character.GetEnchantBySlot(enchant.Slot) == enchant;
                if (isEquipped)
                {
                    calcsEquipped = currentCalcs;
                    Character charUnequipped = character.Clone();
                    charUnequipped.SetEnchantBySlot(enchant.Slot, null);
                    calcsUnequipped = GetCharacterCalculations(charUnequipped);
                }
                else
                {
                    Character charUnequipped = character.Clone();
                    Character charEquipped   = character.Clone();
                    charUnequipped.SetEnchantBySlot(enchant.Slot, null);
                    charEquipped.SetEnchantBySlot(enchant.Slot, enchant);
                    calcsUnequipped = GetCharacterCalculations(charUnequipped);
                    calcsEquipped   = GetCharacterCalculations(charEquipped);
                }
                ComparisonCalculationBase enchantCalc = CreateNewComparisonCalculation();
                enchantCalc.Name = enchant.Name;
                enchantCalc.Item = new Item(enchant.Name, Item.ItemQuality.Temp, Item.ItemType.None,
                                            -1 * (enchant.Id + (10000 * (int)enchant.Slot)), null, Item.ItemSlot.None, null, false, enchant.Stats, new Sockets(), 0, 0, 0, 0, 0,
                                            Item.ItemDamageType.Physical, 0, null);
                enchantCalc.Item.Name     = enchant.Name;
                enchantCalc.Item.Stats    = enchant.Stats;
                enchantCalc.Equipped      = isEquipped;
                enchantCalc.OverallPoints = calcsEquipped.OverallPoints - calcsUnequipped.OverallPoints;
                float[] subPoints = new float[calcsEquipped.SubPoints.Length];
                for (int i = 0; i < calcsEquipped.SubPoints.Length; i++)
                {
                    subPoints[i] = calcsEquipped.SubPoints[i] - calcsUnequipped.SubPoints[i];
                }
                enchantCalc.SubPoints = subPoints;
                enchantCalcs.Add(enchantCalc);
            }
            return(enchantCalcs);
        }