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"; }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { if (System.Text.RegularExpressions.Regex.IsMatch(tbArmourBonus.Text, minusRegex)) { armour = new Armour(tbName.Text, (new TextRange(rtbDescription.Document.ContentStart, rtbDescription.Document.ContentEnd).Text), false, Convert.ToInt32(tbArmourBonus.Text), Convert.ToInt32(tbBaseArmour.Text), (string)cbMod.SelectedItem, Convert.ToInt32(tbStrReq.Text), (bool)chkStealth.IsChecked, tbWeight.Text, "0", (string)cbType.SelectedItem, (bool)chkAttune.IsChecked); int newItemId = db.InsertNewArmour(armour); db.InsertInItemTable(newItemId, 2); MessageBox.Show(armour.GetName() + " added to the collection."); } else { MessageBox.Show("Incorrect armour bonus. (Can be negative.)"); } }
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(); }