示例#1
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");
            }
        }
示例#2
0
        public OptimizerResults(Character oldCharacter, Character newCharacter, bool cancelOptimization)
        {
            InitializeComponent();

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

            if (cancelOptimization)
            {
                CancelButton.Content = "Cancel";
                BT_StoreIt.Content   = "Continue";
            }

            CurrentCharacter = oldCharacter;
            BestCharacter    = newCharacter;

            int rows = ItemGrid.RowDefinitions.Count;
            for (int i = 0; i < Character.OptimizableSlotCount; i++)
            {
                CharacterSlot slot = (CharacterSlot)i;
                if ((oldCharacter[slot] == null && newCharacter[slot] != null) ||
                    (oldCharacter[slot] != null && !oldCharacter[slot].Equals(newCharacter[slot])))
                {
                    // Testing if the ring/trinket items were just swapped and not actually different
                    if (slot == CharacterSlot.Finger1 || slot == CharacterSlot.Finger2)
                    {
                        ItemInstance old1 = oldCharacter[CharacterSlot.Finger1];
                        ItemInstance old2 = oldCharacter[CharacterSlot.Finger2];
                        ItemInstance new1 = newCharacter[CharacterSlot.Finger1];
                        ItemInstance new2 = newCharacter[CharacterSlot.Finger2];
                        if (((old1 == null && new2 == null) || (old1 != null && old1.Equals(new2))) &&
                            ((old2 == null && new1 == null) || (old2 != null && old2.Equals(new1))))
                        {
                            continue;
                        }
                    }
                    else if (slot == CharacterSlot.Trinket1 || slot == CharacterSlot.Trinket2)
                    {
                        ItemInstance old1 = oldCharacter[CharacterSlot.Trinket1];
                        ItemInstance old2 = oldCharacter[CharacterSlot.Trinket2];
                        ItemInstance new1 = newCharacter[CharacterSlot.Trinket1];
                        ItemInstance new2 = newCharacter[CharacterSlot.Trinket2];
                        if (((old1 == null && new2 == null) || (old1 != null && old1.Equals(new2))) &&
                            ((old2 == null && new1 == null) || (old2 != null && old2.Equals(new1))))
                        {
                            continue;
                        }
                    }
                    ItemGrid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = GridLength.Auto
                    });

                    if (oldCharacter[slot] != null)
                    {
                        ItemDisplay oldItem = new ItemDisplay(oldCharacter[slot]);
                        oldItem.Style = Resources["ItemDisplayStyle"] as Style;
                        ItemGrid.Children.Add(oldItem);
                        Grid.SetRow(oldItem, rows);
                        Grid.SetColumn(oldItem, 0);
                    }

                    if (newCharacter[slot] != null)
                    {
                        ItemDisplay newItem = new ItemDisplay(newCharacter[slot]);
                        newItem.Style = Resources["ItemDisplayStyle"] as Style;
                        ItemGrid.Children.Add(newItem);
                        Grid.SetRow(newItem, rows);
                        Grid.SetColumn(newItem, 1);
                    }

                    rows++;
                }
            }

            currentCalc = oldCharacter.CurrentCalculations.GetCharacterCalculations(oldCharacter, null, false, true, true);
            var oldValue = Optimizer.ItemInstanceOptimizer.GetOptimizationValue(oldCharacter, currentCalc);
            CurrentScoreLabel.Text = string.Format("Current: {0}", oldValue);
            CurrentCalculations.SetCalculations(currentCalc.GetCharacterDisplayCalculationValues());
            CurrentTalents.Character = oldCharacter; //CurrentTalents.IsEnabled = false;
            CurrentBuffs.Character   = oldCharacter; //CurrentBuffs.IsEnabled = false;

            optimizedCalc = newCharacter.CurrentCalculations.GetCharacterCalculations(newCharacter, null, false, true, true);
            var newValue = Optimizer.ItemInstanceOptimizer.GetOptimizationValue(newCharacter, optimizedCalc);
            OptimizedScoreLabel.Text = string.Format("Optimized: {0} ({1:P} change)", newValue, (newValue - oldValue) / oldValue);
            OptimizedCalculations.SetCalculations(optimizedCalc.GetCharacterDisplayCalculationValues());
            OptimizedTalents.Character = newCharacter; //OptimizedTalents.IsEnabled = false;
            OptimizedBuffs.Character   = newCharacter; //OptimizedBuffs.IsEnabled = false;

            CharName1.Text = CharName2.Text = CharName1.Text = oldCharacter.Name;
        }
示例#3
0
        public OptimizerResults(Character oldCharacter, Character newCharacter)
        {
            InitializeComponent();

            CurrentCharacter = oldCharacter;
            BestCharacter    = newCharacter;

            int rows = 0;

            for (int i = 0; i < Character.OptimizableSlotCount; i++)
            {
                CharacterSlot slot = (CharacterSlot)i;
                if ((oldCharacter[slot] == null && newCharacter[slot] != null) ||
                    (oldCharacter[slot] != null && !oldCharacter[slot].Equals(newCharacter[slot])))
                {
                    //Testing if the ring/trinket items were just swapped and not actually different
                    if (slot == CharacterSlot.Finger1 || slot == CharacterSlot.Finger2)
                    {
                        ItemInstance old1 = oldCharacter[CharacterSlot.Finger1];
                        ItemInstance old2 = oldCharacter[CharacterSlot.Finger2];
                        ItemInstance new1 = newCharacter[CharacterSlot.Finger1];
                        ItemInstance new2 = newCharacter[CharacterSlot.Finger2];
                        if (((old1 == null && new2 == null) || (old1 != null && old1.Equals(new2))) &&
                            ((old2 == null && new1 == null) || (old2 != null && old2.Equals(new1))))
                        {
                            continue;
                        }
                    }
                    else if (slot == CharacterSlot.Trinket1 || slot == CharacterSlot.Trinket2)
                    {
                        ItemInstance old1 = oldCharacter[CharacterSlot.Trinket1];
                        ItemInstance old2 = oldCharacter[CharacterSlot.Trinket2];
                        ItemInstance new1 = newCharacter[CharacterSlot.Trinket1];
                        ItemInstance new2 = newCharacter[CharacterSlot.Trinket2];
                        if (((old1 == null && new2 == null) || (old1 != null && old1.Equals(new2))) &&
                            ((old2 == null && new1 == null) || (old2 != null && old2.Equals(new1))))
                        {
                            continue;
                        }
                    }
                    ItemGrid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = GridLength.Auto
                    });

                    if (oldCharacter[slot] != null)
                    {
                        ItemDisplay oldItem = new ItemDisplay(oldCharacter[slot]);
                        oldItem.Style = Resources["ItemDisplayStyle"] as Style;
                        ItemGrid.Children.Add(oldItem);
                        Grid.SetRow(oldItem, rows);
                        Grid.SetColumn(oldItem, 0);
                    }

                    if (newCharacter[slot] != null)
                    {
                        ItemDisplay newItem = new ItemDisplay(newCharacter[slot]);
                        newItem.Style = Resources["ItemDisplayStyle"] as Style;
                        ItemGrid.Children.Add(newItem);
                        Grid.SetRow(newItem, rows);
                        Grid.SetColumn(newItem, 1);
                    }

                    rows++;
                }
            }

            CharacterCalculationsBase currentCalc = Calculations.GetCharacterCalculations(oldCharacter, null, false, true, true);

            CurrentScoreLabel.Text = string.Format("Current: {0}", currentCalc.OverallPoints);
            CurrentCalculations.SetCalculations(currentCalc.GetCharacterDisplayCalculationValues());

            CharacterCalculationsBase optimizedCalc = Calculations.GetCharacterCalculations(newCharacter, null, false, true, true);

            OptimizedScoreLabel.Text = string.Format("Optimized: {0}", optimizedCalc.OverallPoints);
            OptimizedCalculations.SetCalculations(optimizedCalc.GetCharacterDisplayCalculationValues());
        }