public void SetSetBonuses(DDOItemSetBonus sb)
 {
     lvDetails.Items.Clear();
     foreach (var p in sb.Bonuses)
     {
         lvDetails.Items.Add(new { p.Property, p.Type, p.Value });
     }
 }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        private void ItemCheckBox_Clicked(object sender, RoutedEventArgs e)
        {
            CheckBox cb = sender as CheckBox;

            if (cb.IsChecked.Value)
            {
                DDOItemData si = cb.Tag as DDOItemData;
                DDOItemData ci;
                int         fi = 0;
                for (int i = 0; i < SelectedItems.Count; i++)
                {
                    ci = SelectedItems[i].Tag as DDOItemData;
                    if (si.Slot == ci.Slot)
                    {
                        // finger slots don't get unchecked, since there could be two of them
                        if (si.Slot == SlotType.Finger)
                        {
                            fi++;
                        }
                        // weapon slot doesn't get checked, since a weapon could be in the offhand
                        else if (si.Slot != SlotType.Weapon)
                        {
                            SelectedItems[i].IsChecked = false;
                            SelectedItems.RemoveAt(i);
                            if (SelectedOffhand == ci)
                            {
                                SelectedOffhand = null;
                            }
                            break;
                        }
                    }
                }
                if (si.Slot == SlotType.Finger)
                {
                    if (fi >= FingerLimit)
                    {
                        MessageBox.Show("Can't use more than " + (FingerLimit == 1 ? "one finger item" : "two finger items") + ". Remove one before adding another.", "Finger slots at capacity", MessageBoxButton.OK, MessageBoxImage.Stop);
                        cb.IsChecked = false;
                    }
                    else
                    {
                        SelectedItems.Add(cb);
                    }
                }
                else if (si.Slot == SlotType.Weapon)
                {
                    bool allow = false;
                    if (si.Handedness == 1)
                    {
                        if (WeaponSlot.IsLocked)
                        {
                            if (WeaponSlot.Item == null || WeaponSlot.Item.Item.Handedness == 1)
                            {
                                if (SelectedOffhand == null)
                                {
                                    SelectedOffhand = si;
                                    allow           = true;
                                }
                            }
                        }
                        else if (SelectedWeapon == null)
                        {
                            SelectedWeapon = si;
                            allow          = true;
                        }
                        else if (SelectedWeapon.Handedness == 1 && !OffhandSlot.IsLocked && SelectedOffhand == null)
                        {
                            SelectedOffhand = si;
                            allow           = true;
                        }
                    }
                    else if (si.Handedness == 2)
                    {
                        if (SelectedWeapon == null)
                        {
                            if (OffhandSlot.Item == null)
                            {
                                allow = true;
                            }
                            else if (OffhandSlot.IsLocked)
                            {
                                if (OffhandSlot.Item.Item.Slot == SlotType.Offhand && DatasetManager.CanBeUsedTogether(si, OffhandSlot.Item.Item))
                                {
                                    allow = true;
                                }
                            }
                            else if (SelectedOffhand == null)
                            {
                                allow = true;
                            }
                            else if (SelectedOffhand.Slot == SlotType.Offhand && DatasetManager.CanBeUsedTogether(si, SelectedOffhand))
                            {
                                allow = true;
                            }

                            if (allow)
                            {
                                SelectedWeapon = si;
                            }
                        }
                    }

                    if (!allow)
                    {
                        MessageBox.Show("There are no hands available to use the selected weapon. Free up a weapon or offhand item to add another.", "Weapon/Offhand slots at capacity", MessageBoxButton.OK, MessageBoxImage.Stop);
                        cb.IsChecked = false;
                    }
                    else
                    {
                        SelectedItems.Add(cb);
                    }
                }
                else if (si.Slot == SlotType.Offhand)
                {
                    bool allow = false;
                    if (SelectedOffhand == null)
                    {
                        if (SelectedWeapon != null)
                        {
                            allow = DatasetManager.CanBeUsedTogether(SelectedWeapon, si);
                        }
                        else if (WeaponSlot.Item != null)
                        {
                            allow = DatasetManager.CanBeUsedTogether(WeaponSlot.Item.Item, si);
                        }
                        else
                        {
                            allow = true;
                        }
                    }

                    if (!allow)
                    {
                        MessageBox.Show("There are no hands available to use the selected offhand. Free up a weapon item first.", "Weapon/Offhand slots at capacity", MessageBoxButton.OK, MessageBoxImage.Stop);
                        cb.IsChecked = false;
                    }
                    else
                    {
                        SelectedItems.Add(cb);
                        SelectedOffhand = si;
                    }
                }
                else
                {
                    SelectedItems.Add(cb);
                }
            }
            // item is being deselected by user
            else
            {
                SelectedItems.Remove(cb);
                DDOItemData id = cb.Tag as DDOItemData;
                if (id.Slot == SlotType.Offhand)
                {
                    SelectedOffhand = null;
                }
                else if (id.Slot == SlotType.Weapon)
                {
                    if (SelectedWeapon == id)
                    {
                        SelectedWeapon = null;
                        if (SelectedOffhand != null && SelectedOffhand.Slot == SlotType.Weapon)
                        {
                            SelectedWeapon  = SelectedOffhand;
                            SelectedOffhand = null;
                        }
                    }
                    else if (SelectedOffhand == id)
                    {
                        SelectedOffhand = null;
                    }
                }
            }

            // update minimum item notification for bonuses tabs
            TabItem sti = null;

            foreach (TabItem ti in tcSetBonuses.Items)
            {
                DDOItemSetBonus sb = ti.Tag as DDOItemSetBonus;
                if (sb.MinimumItems <= SelectedItems.Count)
                {
                    sti = ti;
                }
                ti.Header = sb.MinimumItems.ToString() + " Pieces";
            }
            if (sti != null)
            {
                sti.Header = (sti.Tag as DDOItemSetBonus).MinimumItems.ToString() + " Pieces *";
            }

            btnApply.IsEnabled = SelectedItems.Count > 0;
        }