예제 #1
0
        void _menuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menu    = sender as ToolStripMenuItem;
            Enchant           enchant = (Enchant)menu.Tag;

            Character.ToggleAvailableItemEnchantRestriction(_item, enchant);
        }
예제 #2
0
        private void reportItemDifferences(StringBuilder sb)
        {
            Enchant noEnchant = Enchant.FindEnchant(0, ItemSlot.None, _before);
            Item    noItem    = new Item();

            noItem.Name = "No item equipped";
            Item         noGem          = new Item();
            ItemInstance noItemInstance = new ItemInstance();

            ItemInstance[] beforeItems = _before.GetItems();
            ItemInstance[] afterItems  = _after.GetItems();
            int            changes     = 0;

            for (int i = 1; i < Character.SlotCount; i++)
            {
                CharacterSlot slot = (CharacterSlot)i;
                if (slot != CharacterSlot.Shirt && slot != CharacterSlot.Tabard)
                {
                    ItemInstance before             = beforeItems[i] ?? noItemInstance;
                    ItemInstance after              = afterItems[i] ?? noItemInstance;
                    bool         swappedRingTrinket = false;
                    if (slot == CharacterSlot.Finger1 || slot == CharacterSlot.Trinket1)
                    {
                        ItemInstance after2 = afterItems[i + 1] ?? noItemInstance;
                        if (before != noItemInstance && after2 != noItemInstance && before.Equals(after2))
                        {
                            swappedRingTrinket = true;
                            i++; // force skip over finger2 and trinket2.
                        }
                    }
                    if (!(before == noItemInstance && after == noItemInstance) && !before.Equals(after) && !swappedRingTrinket)
                    {
                        string itemname    = (before.Item ?? noItem).Name;
                        string gem1name    = before.Gem1 == null ? "" : "with " + before.Gem1.Name;
                        string gem2name    = before.Gem2 == null ? "" : ", " + before.Gem2.Name;
                        string gem3name    = before.Gem3 == null ? "" : ", " + before.Gem3.Name;
                        string enchantname = before.Enchant == null ? "" : ", " + before.Enchant.Name;
                        string reforgename = before.Reforging == null ? "" : ", " + before.Reforging.ToString();
                        sb.AppendFormat("{0}: Changed {1} {2}{3}{4}{5}{6}", slot, itemname, gem1name, gem2name, gem3name, enchantname, reforgename);
                        sb.AppendLine();
                        itemname    = (after.Item ?? noItem).Name;
                        gem1name    = after.Gem1 == null ? "" : "with " + after.Gem1.Name;
                        gem2name    = after.Gem2 == null ? "" : ", " + after.Gem2.Name;
                        gem3name    = after.Gem3 == null ? "" : ", " + after.Gem3.Name;
                        enchantname = after.Enchant == null ? "" : ", " + after.Enchant.Name;
                        reforgename = after.Reforging == null ? "" : ", " + after.Reforging.ToString();
                        sb.AppendFormat("               to {0} {1}{2}{3}{4}{5}", itemname, gem1name, gem2name, gem3name, enchantname, reforgename);
                        sb.AppendLine();
                        changes++;
                    }
                }
            }
            if (changes == 0)
            {
                sb.AppendLine("No item changes found");
            }
        }
예제 #3
0
 public void Show(Item item, Character itemCharacter, Enchant itemEnchant, IWin32Window window, Point point)
 {
     CurrentItem          = item;
     CurrentItemCharacter = itemCharacter;
     CurrentItemEnchant   = itemEnchant;
     if (CachedToolTipImage != null)
     {
         base.Show(item.Name, window, point);
     }
 }
예제 #4
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);
        }
예제 #5
0
 private void ShowTooltip(Item item, Character itemCharacter, Enchant itemEnchant, Point location)
 {
     if (_tooltipItem != item || _tooltipLocation != location)
     {
         _tooltipItem          = item;
         _tooltipItemCharacter = itemCharacter;
         _tooltipItemEnchant   = itemEnchant;
         _tooltipLocation      = location;
         ShowHideTooltip();
     }
 }
예제 #6
0
        public override bool Equals(object obj)
        {
            Enchant temp = obj as Enchant;

            if (temp != null)
            {
                return(Name.Equals(temp.Name) && Id == temp.Id && Slot == temp.Slot && Stats.Equals(temp.Stats));
            }
            else
            {
                return(false);
            }
        }
예제 #7
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);
        }
예제 #8
0
        private void ComparisonGraph_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Location != _lastPoint)
            {
                _lastPoint = e.Location;
                Cursor cursor = Cursors.Default;
                if (e.X <= 118)
                {
                    int itemIndex = (int)Math.Floor(((float)(e.Y - 44f + _scrollBar.Value)) / 36f);
                    if (itemIndex >= 0 && itemIndex < ItemCalculations.Length)
                    {
                        Item      item          = ItemCalculations[itemIndex].Item;
                        Character itemCharacter = ItemCalculations[itemIndex].Character;
                        Enchant   itemEnchant   = ItemCalculations[itemIndex].Enchant;
                        if (e.X < 10 && item != null && item.Id != 0)
                        {
                            cursor = Cursors.Hand;
                        }

                        if (item != _tooltipItem)
                        {
                            int tipX = 118;
                            if (Parent.PointToScreen(Location).X + tipX + 249 > System.Windows.Forms.Screen.GetWorkingArea(this).Right)
                            {
                                tipX = -249;
                            }

                            ShowTooltip(item, itemCharacter, itemEnchant, new Point(tipX, 26 + (itemIndex * 36) - _scrollBar.Value));
                        }
                    }
                    else
                    {
                        HideTooltip();
                    }
                }
                else
                {
                    HideTooltip();
                    //ItemTooltip.Instance.HideTooltip();
                }
                if (Cursor != cursor)
                {
                    Cursor = cursor;
                }
            }
        }
예제 #9
0
 private void replaceUnavailableToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (BatchCharacter character in BatchCharacterList)
     {
         if (character.Character != null)
         {
             for (int slot = 0; slot < 19; slot++)
             {
                 Item    item    = character.Character[(Character.CharacterSlot)slot];
                 Enchant enchant = character.Character.GetEnchantBySlot((Character.CharacterSlot)slot);
                 if (item != null)
                 {
                     string        id     = item.Id.ToString();
                     string        anyGem = id + ".*.*.*";
                     List <string> list   = character.Character.AvailableItems.FindAll(x => x.StartsWith(id));
                     List <string> sublist;
                     if (list.Contains(item.GemmedId + ".*"))
                     {
                         // available
                     }
                     else if ((sublist = list.FindAll(x => x.StartsWith(item.GemmedId))).Count > 0)
                     {
                         if (sublist.Contains(item.GemmedId + "." + (enchant != null ? enchant.Id.ToString() : "0")))
                         {
                             // available
                         }
                         else
                         {
                             // have to replace enchant
                             string s = sublist[0];
                             character.Character.SetEnchantBySlot((Character.CharacterSlot)slot, Enchant.FindEnchant(int.Parse(s.Substring(s.LastIndexOf('.') + 1)), item.Slot));
                             character.UnsavedChanges = true;
                         }
                     }
                     else if (list.Contains(id))
                     {
                         // available
                     }
                     else if ((sublist = list.FindAll(x => x.StartsWith(anyGem))).Count > 0)
                     {
                         if (sublist.Contains(anyGem + "." + (enchant != null ? enchant.Id.ToString() : "0")))
                         {
                             // available
                         }
                         else
                         {
                             // have to replace enchant
                             string s = sublist[0];
                             character.Character.SetEnchantBySlot((Character.CharacterSlot)slot, Enchant.FindEnchant(int.Parse(s.Substring(s.LastIndexOf('.') + 1)), item.Slot));
                             character.UnsavedChanges = true;
                         }
                     }
                     else if (list.Count > 0)
                     {
                         string s = list[0];
                         item = ItemCache.FindItemById(s.Substring(0, s.LastIndexOf('.')));
                         character.Character[(Character.CharacterSlot)slot] = item;
                         string se = s.Substring(s.LastIndexOf('.') + 1);
                         if (se != "*")
                         {
                             character.Character.SetEnchantBySlot((Character.CharacterSlot)slot, Enchant.FindEnchant(int.Parse(se), item.Slot));
                         }
                         character.UnsavedChanges = true;
                     }
                     else
                     {
                         foreach (string s in character.Character.AvailableItems)
                         {
                             if (s.IndexOf('.') < 0)
                             {
                                 item = ItemCache.FindItemById(int.Parse(s));
                             }
                             else
                             {
                                 string[] slist = s.Split('.');
                                 if (slist[1] == "*")
                                 {
                                     item = ItemCache.FindItemById(int.Parse(slist[0]));
                                 }
                                 else
                                 {
                                     item = ItemCache.FindItemById(s.Substring(0, s.LastIndexOf('.')));
                                 }
                             }
                             if (item != null && item.FitsInSlot((Character.CharacterSlot)slot))
                             {
                                 character.Character[(Character.CharacterSlot)slot] = item;
                                 string se = s.Substring(s.LastIndexOf('.') + 1);
                                 if (se != "*")
                                 {
                                     character.Character.SetEnchantBySlot((Character.CharacterSlot)slot, Enchant.FindEnchant(int.Parse(se), item.Slot));
                                 }
                                 character.UnsavedChanges = true;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #10
0
        public ItemInstance GetItemInstance(Item item, int randomSuffixId, Enchant enchant, Reforging reforging, Tinkering tinkering, bool blacksmithingSocket)
        {
            if (item == null)
            {
                return(null);
            }
            Item gem1     = null;
            Item gem2     = null;
            Item gem3     = null;
            bool cog1used = false;

            switch (item.SocketColor1)
            {
            case ItemSlot.Meta: gem1 = MetaGem; break;

            case ItemSlot.Red: gem1 = RedGem; break;

            case ItemSlot.Yellow: gem1 = YellowGem; break;

            case ItemSlot.Blue: gem1 = BlueGem; break;

            case ItemSlot.Prismatic: gem1 = PrismaticGem; break;

            case ItemSlot.Cogwheel: gem1 = Cogwheel; cog1used = true; break;

            case ItemSlot.Hydraulic: gem1 = Hydraulic; break;

            case ItemSlot.None:
                if (blacksmithingSocket)
                {
                    gem1 = PrismaticGem;
                    blacksmithingSocket = false;
                }
                break;
            }
            switch (item.SocketColor2)
            {
            case ItemSlot.Meta: gem2 = MetaGem; break;

            case ItemSlot.Red: gem2 = RedGem; break;

            case ItemSlot.Yellow: gem2 = YellowGem; break;

            case ItemSlot.Blue: gem2 = BlueGem; break;

            case ItemSlot.Prismatic: gem2 = PrismaticGem; break;

            case ItemSlot.Cogwheel: if (cog1used)
                {
                    gem2 = Cogwheel2;
                }
                else
                {
                    gem2 = Cogwheel; cog1used = true;
                } break;

            case ItemSlot.Hydraulic: gem2 = Hydraulic; break;

            case ItemSlot.None:
                if (blacksmithingSocket)
                {
                    gem2 = PrismaticGem;
                    blacksmithingSocket = false;
                }
                break;
            }
            switch (item.SocketColor3)
            {
            case ItemSlot.Meta: gem3 = MetaGem; break;

            case ItemSlot.Red: gem3 = RedGem; break;

            case ItemSlot.Yellow: gem3 = YellowGem; break;

            case ItemSlot.Blue: gem3 = BlueGem; break;

            case ItemSlot.Prismatic: gem3 = PrismaticGem; break;

            case ItemSlot.Cogwheel: if (cog1used)
                {
                    gem3 = Cogwheel2;
                }
                else
                {
                    gem3 = Cogwheel; cog1used = true;
                } break;

            case ItemSlot.Hydraulic: gem3 = Hydraulic; break;

            case ItemSlot.None:
                if (blacksmithingSocket)
                {
                    gem3 = PrismaticGem;
                    blacksmithingSocket = false;
                }
                break;
            }
            return(new ItemInstance(item, randomSuffixId, gem1, gem2, gem3, enchant, reforging, tinkering));
        }
예제 #11
0
 public ItemInstance GetItemInstance(Item item, int randomSuffixId, Enchant enchant, bool blacksmithingSocket)
 {
     return(GetItemInstance(item, randomSuffixId, enchant, null, null, blacksmithingSocket));
 }
예제 #12
0
        private void RemoveUnchangedItems()
        {
            Enchant noEnchant = Enchant.FindEnchant(0, ItemSlot.None, paperDollBefore.Character);

            paperDollBefore.ShirtHidden  = true;
            paperDollBefore.TabardHidden = true;
            paperDollAfter.ShirtHidden   = true;
            paperDollAfter.TabardHidden  = true;

            if (paperDollBefore.Head.Equals(paperDollAfter.Head))
            {
                paperDollBefore.HeadHidden = true;
                paperDollAfter.HeadHidden  = true;
            }
            if (paperDollBefore.Neck.Equals(paperDollAfter.Neck))
            {
                paperDollBefore.NeckHidden = true;
                paperDollAfter.NeckHidden  = true;
            }
            if (paperDollBefore.Shoulders.Equals(paperDollAfter.Shoulders))
            {
                paperDollBefore.ShouldersHidden = true;
                paperDollAfter.ShouldersHidden  = true;
            }
            if (paperDollBefore.Back.Equals(paperDollAfter.Back))
            {
                paperDollBefore.BackHidden = true;
                paperDollAfter.BackHidden  = true;
            }
            if (paperDollBefore.Chest.Equals(paperDollAfter.Chest))
            {
                paperDollBefore.ChestHidden = true;
                paperDollAfter.ChestHidden  = true;
            }
            if (paperDollBefore.Wrist.Equals(paperDollAfter.Wrist))
            {
                paperDollBefore.WristHidden = true;
                paperDollAfter.WristHidden  = true;
            }
            if (paperDollBefore.MainHand.Equals(paperDollAfter.MainHand))
            {
                paperDollBefore.MainHandHidden = true;
                paperDollAfter.MainHandHidden  = true;
            }
            if (paperDollBefore.OffHand.Equals(paperDollAfter.OffHand))
            {
                paperDollBefore.OffHandHidden = true;
                paperDollAfter.OffHandHidden  = true;
            }
            if (paperDollBefore.Ranged.Equals(paperDollAfter.Ranged))
            {
                paperDollBefore.RangedHidden = true;
                paperDollAfter.RangedHidden  = true;
            }
            if (paperDollBefore.Projectile.Equals(paperDollAfter.Projectile))
            {
                paperDollBefore.ProjectileHidden = true;
                paperDollAfter.ProjectileHidden  = true;
            }
            if (paperDollBefore.ProjectileBag.Equals(paperDollAfter.ProjectileBag))
            {
                paperDollBefore.ProjectileBagHidden = true;
                paperDollAfter.ProjectileBagHidden  = true;
            }
            if (paperDollBefore.Hands.Equals(paperDollAfter.Hands))
            {
                paperDollBefore.HandsHidden = true;
                paperDollAfter.HandsHidden  = true;
            }
            if (paperDollBefore.Waist.Equals(paperDollAfter.Waist))
            {
                paperDollBefore.WaistHidden = true;
                paperDollAfter.WaistHidden  = true;
            }
            if (paperDollBefore.Legs.Equals(paperDollAfter.Legs))
            {
                paperDollBefore.LegsHidden = true;
                paperDollAfter.LegsHidden  = true;
            }
            if (paperDollBefore.Feet.Equals(paperDollAfter.Feet))
            {
                paperDollBefore.FeetHidden = true;
                paperDollAfter.FeetHidden  = true;
            }
            if (paperDollBefore.Finger1.Equals(paperDollAfter.Finger1))
            {
                paperDollBefore.Finger1Hidden = true;
                paperDollAfter.Finger1Hidden  = true;
            }
            if (paperDollBefore.Finger2.Equals(paperDollAfter.Finger2))
            {
                paperDollBefore.Finger2Hidden = true;
                paperDollAfter.Finger2Hidden  = true;
            }
            if (paperDollBefore.Trinket1.Equals(paperDollAfter.Trinket1))
            {
                paperDollBefore.Trinket1Hidden = true;
                paperDollAfter.Trinket1Hidden  = true;
            }
            if (paperDollBefore.Trinket2.Equals(paperDollAfter.Trinket2))
            {
                paperDollBefore.Trinket2Hidden = true;
                paperDollAfter.Trinket2Hidden  = true;
            }

            // now check swapped slot rings & trinkets
            if (paperDollBefore.Finger1.Equals(paperDollAfter.Finger2))
            {
                paperDollBefore.Finger1Hidden = true;
                paperDollAfter.Finger2Hidden  = true;
            }
            if (paperDollBefore.Finger2.Equals(paperDollAfter.Finger1))
            {
                paperDollBefore.Finger2Hidden = true;
                paperDollAfter.Finger1Hidden  = true;
            }
            if (paperDollBefore.Trinket1.Equals(paperDollAfter.Trinket2))
            {
                paperDollBefore.Trinket1Hidden = true;
                paperDollAfter.Trinket2Hidden  = true;
            }
            if (paperDollBefore.Trinket2.Equals(paperDollAfter.Trinket1))
            {
                paperDollBefore.Trinket2Hidden = true;
                paperDollAfter.Trinket1Hidden  = true;
            }

            // also hide offhands if they're not actually used
            if (!Calculations.IncludeOffHandInCalculations(paperDollBefore.Character) && !Calculations.IncludeOffHandInCalculations(paperDollAfter.Character))
            {
                paperDollBefore.OffHandHidden = true;
                paperDollAfter.OffHandHidden  = true;
            }
        }
예제 #13
0
        public ItemInstance GetItemInstance(Item item, Enchant enchant, bool blacksmithingSocket)
        {
            if (item == null)
            {
                return(null);
            }
            Item gem1 = null;
            Item gem2 = null;
            Item gem3 = null;

            switch (item.SocketColor1)
            {
            case ItemSlot.Meta: gem1 = MetaGem; break;

            case ItemSlot.Red: gem1 = RedGem; break;

            case ItemSlot.Yellow: gem1 = YellowGem; break;

            case ItemSlot.Blue: gem1 = BlueGem; break;

            case ItemSlot.Prismatic: gem1 = PrismaticGem; break;

            case ItemSlot.None:
                if (blacksmithingSocket)
                {
                    gem1 = PrismaticGem;
                    blacksmithingSocket = false;
                }
                break;
            }
            switch (item.SocketColor2)
            {
            case ItemSlot.Meta: gem2 = MetaGem; break;

            case ItemSlot.Red: gem2 = RedGem; break;

            case ItemSlot.Yellow: gem2 = YellowGem; break;

            case ItemSlot.Blue: gem2 = BlueGem; break;

            case ItemSlot.Prismatic: gem2 = PrismaticGem; break;

            case ItemSlot.None:
                if (blacksmithingSocket)
                {
                    gem2 = PrismaticGem;
                    blacksmithingSocket = false;
                }
                break;
            }
            switch (item.SocketColor3)
            {
            case ItemSlot.Meta: gem3 = MetaGem; break;

            case ItemSlot.Red: gem3 = RedGem; break;

            case ItemSlot.Yellow: gem3 = YellowGem; break;

            case ItemSlot.Blue: gem3 = BlueGem; break;

            case ItemSlot.Prismatic: gem3 = PrismaticGem; break;

            case ItemSlot.None:
                if (blacksmithingSocket)
                {
                    gem3 = PrismaticGem;
                    blacksmithingSocket = false;
                }
                break;
            }
            return(new ItemInstance(item, gem1, gem2, gem3, enchant));
        }