public ItemControl(Armour a) { InitializeComponent(); lbName.Content = a.GetName(); lbType.Content = a.GetItemType(); lbWeight.Content = a.GetWeight(); lbAttune.Content = a.GetAttunement(); lbProficiency.Content = "WIP"; lbQuantity.Content = a.GetQuantity(); this.item = a; this.typeItem = "Armour"; }
public void Equip(Item item) { Item toAdd = new Item(); toAdd.SetItemType(item.GetItemType()); bool dup = false; if (item.GetQuantity() > 1) { switch (toAdd.GetItemType()) { default: MessageBox.Show("Added item has an invalid item type. Can not equip."); break; case "Weapon": Weapon wep = (Weapon)item; toAdd = new Weapon(item.GetId(), item.GetName(), item.GetDescription(), wep.GetDamageForCopy(), wep.GetItemType(), wep.GetProficient(), wep.GetAttunement(), wep.GetWeight(), wep.GetModifier(), (float)wep.GetBonusDamage(), wep.GetBaseDamageType(), wep.GetBonusDamageType(), 1); toAdd.SetItemType("Weapon"); item.DecrementQuantity(); break; case "Armour": Armour arm = (Armour)item; toAdd = new Armour(arm.GetId(), arm.GetName(), arm.GetDescription(), arm.GetItemType(), arm.GetProficient(), arm.GetAttunement(), arm.GetWeight(), arm.GetStealthDis(), arm.GetBaseArmour(), arm.GetBonusArmour(), arm.GetModifier(), 1, arm.GetStrReq(), arm.GetValue()); toAdd.SetItemType("Armour"); item.DecrementQuantity(); break; case "Item": toAdd.SetItemType("Item"); // Add all items. No logic here. :3 break; } toAdd.SetEquip(true); dup = true; } switch (item.GetType().Name) { default: MessageBox.Show("NO ITEM TYPE."); break; case "Weapon": if (!dup) { item.SetEquip(true); weapons.Remove((Weapon)item); equipedItems.Add(item); } else { toAdd.SetEquip(true); equipedItems.Add(toAdd); } break; case "Armour": if (!dup) { item.SetEquip(true); armours.Remove((Armour)item); equipedItems.Add(item); } else { toAdd.SetEquip(true); equipedItems.Add(toAdd); } break; case "Item": item.SetEquip(true); items.Remove((Item)item); equipedItems.Add(item); break; } UpdateInventory(); }