public void AddArmour(Armour a) { bool duplicate = false; a.SetEquip(false); foreach (Armour armour in armours) { if (armour.GetId() == a.GetId() && armour.GetName() == a.GetName()) { armour.IncrementQuantity(); duplicate = true; break; } } if (!duplicate) { armours.Add(a); } UpdateInventory(); }
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(); }