public void UnEquip(Item item) { switch (item.Type) { case (EquipmentType.Hand): WeoponItem weopon = item as WeoponItem; if ((weopon != null) && (weopon == this.MainHand)) { this.MainHand = null; break; } ShieldItem shield = item as ShieldItem; if ((shield != null) && (shield == this.OffHand)) { this.OffHand = null; break; } throw new EquipmentException("Weopon is not a shield or" + "weopon but of EquipmentTypeHand"); case (EquipmentType.Armor): if ((ArmorItem)item == this.Armor) { this.Armor = null; break; } throw new EquipmentException("Armor Not Equiped!"); case (EquipmentType.Trinket): // int length = this.Trinket.length; // TODO: does this throw an error??? this.Trinket.Remove((TrinketItem)item); break; } }
// public override string ToString() { // return $"{base.ToString().TrimEnd('}')} AttackDice = {AttackDice}"; // } public override bool Equals(object obj) { WeoponItem other = obj as WeoponItem; if ((other != null) && (base.Equals(obj))) { return(this.AttackDice.SequenceEqual(other.AttackDice)); } return(false); }
public void Equip(Item item) { switch (item.Type) { case (EquipmentType.Hand): HandItem hand = item as HandItem; if (hand.Hands + this.UsedHands > 2) { throw new EquipmentException("Hands are already full"); } WeoponItem weopon = item as WeoponItem; if (weopon != null) { this.MainHand = weopon; break; } ShieldItem shield = item as ShieldItem; if (shield != null) { this.OffHand = shield; break; } throw new EquipmentException("Weopon is not a shield or " + "weopon but of EquipmentTypeHand"); case (EquipmentType.Armor): if (this.Armor != null) { throw new EquipmentException("Armor already equiped!"); } this.Armor = (ArmorItem)item; break; case (EquipmentType.Trinket): if (this.Trinket.Count > 2) { throw new EquipmentException( "Can not equip more than 2 Trinkets"); } this.Trinket.Add((TrinketItem)item); break; } }