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"); } }
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; } } } } } } } }
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; } }