Example #1
0
        // public override string ToString() {
        // return $"{base.ToString().TrimEnd('}')} HandType = {HandType} " +
        // $"Hands = {Hands}";
        // }
        public override bool Equals(object obj)
        {
            HandItem other = obj as HandItem;

            if ((other != null) && (base.Equals(obj)))
            {
                return((this.Hands == other.Hands) &&
                       (this.HandType == other.HandType));
            }
            return(false);
        }
Example #2
0
        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;
            }
        }