예제 #1
0
        public void ProcessItems()
        {
            // need to find all set properties with qualifying set bonuses and expand them into the item properties
            for (int i = 0; i < Properties.Count; i++)
            {
                var gsp = Properties[i];
                if (gsp.IsGroup && gsp.ItemProperties[0].Type == "set")
                {
                    List <ItemProperty> ips = new List <ItemProperty>();
                    DDOItemSet          set = DatasetManager.Dataset.Sets[gsp.ItemProperties[0].Property];
                    DDOItemSetBonus     sb  = set.GetSetBonuses(gsp.ItemProperties);

                    if (sb == null)
                    {
                        continue;
                    }

                    foreach (var sip in sb.Bonuses)
                    {
                        ItemProperty ip = new ItemProperty {
                            Property = sip.Property, Type = sip.Type, Value = sip.Value
                        };
                        ip.SetBonusOwner = set.Name;
                        ips.Add(ip);
                    }

                    if (ips.Count > 0)
                    {
                        AddProperties(ips);
                    }
                }
            }

            CalculatePropertyGroups();

            Properties.Sort((a, b) => string.Compare(a.Property, b.Property));
        }
예제 #2
0
        private void LvSets_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SlotPanel.Children.Clear();
            SlotPanel.Tag = null;
            SelectedItems.Clear();
            SelectedWeapon     = null;
            SelectedOffhand    = null;
            btnApply.IsEnabled = false;
            if (lvSets.SelectedItem == null)
            {
                return;
            }
            DDOItemSet set = (lvSets.SelectedItem as NamedSetInfo).Set;

            SlotPanel.Tag = set;
            foreach (var item in set.Items)
            {
                // don't show items that aren't allowed
                if (!QuestSourceManager.IsItemAllowed(item))
                {
                    continue;
                }

                string group = item.Slot.ToString() + " Slot";
                bool   ro    = false;
                // search for an existing groupbox first
                GroupBox   gb = null;
                StackPanel sp = null;
                foreach (GroupBox tgb in SlotPanel.Children)
                {
                    if ((tgb.Header as Label).Content.ToString() == group)
                    {
                        gb = tgb;
                        if ((gb.Header as Label).Foreground == Brushes.Red)
                        {
                            ro = true;
                        }
                        sp = gb.Content as StackPanel;
                        break;
                    }
                }
                if (gb == null)
                {
                    gb = new GroupBox();
                    Label header = new Label {
                        Content = group
                    };
                    header.Content = group;
                    gb.Header      = header;
                    sp             = new StackPanel();
                    gb.Content     = sp;
                    SlotPanel.Children.Add(gb);
                    foreach (var eq in EquipmentSlots)
                    {
                        if (item.Slot == eq.Value.SlotType)
                        {
                            if (eq.Value.SlotType != SlotType.Finger && eq.Value.SlotType != SlotType.Weapon && eq.Value.IsLocked)
                            {
                                ro = true;
                                break;
                            }
                        }
                    }

                    bool go = false;
                    if (item.Slot == SlotType.Finger)
                    {
                        if (FingerLimit <= 0)
                        {
                            ro = true;
                        }
                        else if (FingerLimit == 1)
                        {
                            go = true;
                        }
                    }
                    else if (item.Slot == SlotType.Weapon)
                    {
                        if (item.Handedness == 1)
                        {
                            if (WeaponSlot.IsLocked && OffhandSlot.IsLocked)
                            {
                                ro = true;
                            }
                            else if (WeaponSlot.IsLocked || OffhandSlot.IsLocked)
                            {
                                go = true;
                            }
                        }
                        else if (item.Handedness == 2)
                        {
                            if (WeaponSlot.IsLocked)
                            {
                                ro = true;
                            }
                            else if (OffhandSlot.IsLocked)
                            {
                                if (OffhandSlot.Item == null)
                                {
                                    ro = true;
                                }
                                else if (OffhandSlot.Item.Item.Slot == SlotType.Weapon)
                                {
                                    ro = true;
                                }
                                else if ((OffhandCategory)OffhandSlot.Item.Item.Category != OffhandCategory.RuneArm)
                                {
                                    ro = true;
                                }
                                else if (!DatasetManager.RuneArmCompatibleTwoHandedWeaponTypes.Contains(item.WeaponType))
                                {
                                    ro = true;
                                }
                                else
                                {
                                    go = true;
                                }
                            }
                        }
                    }

                    if (ro)
                    {
                        header.Foreground = Brushes.Red;
                    }
                    else if (go)
                    {
                        header.Foreground = Brushes.Goldenrod;
                    }
                }

                CheckBox cb = new CheckBox {
                    Content = item.Name, Tag = item
                };
                if (ro)
                {
                    cb.IsEnabled = false;
                }
                else
                {
                    // we do individual offhand evaluation here
                    if (item.Slot == SlotType.Offhand)
                    {
                        if (WeaponSlot.IsLocked && WeaponSlot.Item != null && WeaponSlot.Item.Item.Handedness == 2)
                        {
                            if (!DatasetManager.RuneArmCompatibleTwoHandedWeaponTypes.Contains(WeaponSlot.Item.Item.WeaponType) || (OffhandCategory)item.Category != OffhandCategory.RuneArm)
                            {
                                cb.IsEnabled = false;
                            }
                            else
                            {
                                cb.Click += ItemCheckBox_Clicked;
                            }
                        }
                        else
                        {
                            cb.Click += ItemCheckBox_Clicked;
                        }
                    }
                    else
                    {
                        cb.Click += ItemCheckBox_Clicked;
                    }
                }
                cb.ToolTip = item.Name;
                cb.MouseRightButtonDown += ItemCheckBox_MouseRightButtonDown;
                sp.Children.Add(cb);
            }

            tcSetBonuses.Items.Clear();
            foreach (var sb in set.SetBonuses)
            {
                TabItem ti = new TabItem {
                    Header = sb.MinimumItems + " Pieces"
                };
                ListViewItemProperties ip = new ListViewItemProperties();
                ip.SetSetBonuses(sb);
                ti.Content = ip;
                ti.Tag     = sb;

                tcSetBonuses.Items.Add(ti);
            }

            tcSetBonuses.SelectedIndex = 0;
        }