Ejemplo n.º 1
0
        /// <summary>
        /// Has the <see cref="Actor"/> try to drop
        /// a given <see cref="Thing"/>.
        /// </summary>
        /// <param name="item">the <see cref="Thing"/> to drop</param>
        /// <exception cref="DroppingItemNotHeldException">
        /// if the <see cref="Thing"/> is not in the <see cref="Actor"/>'s
        /// <see cref="Inventory"/>
        /// </exception>
        /// <exception cref="DroppingCursedUndroppableItemException">
        /// if the <see cref="Thing"/> is cursed/undroppable
        /// </exception>
        public void Drop(Thing item)
        {
            // if the actor isn't carrying the item, throw an exception
            if(!this.Carries(item)) {
                throw new DroppingItemNotHeldException(); }

            // if the item is cursed/undroppable, throw an exception
            if(!item.CanBeDropped()) {
                throw new DroppingCursedUndroppableItemException(); }

            // actor is carrying the item and it is not cursed
            else {
                this.inventory.RemoveThing(item);
                item.SetLocation(this.GetLocation());
                this.GetLocation().AddThing(item);
                GameManager.ReportIfVisible(this, this.GetName() + ' ' +  this.GetConjugatedVerb(VerbSet.ToDrop) + ' ' + item.GetSpecificName() + '.'); }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Has the <see cref="Person"/> try to drop
        /// a given <see cref="Thing"/>.
        /// </summary>
        /// 
        /// <param name="item">the <see cref="Thing"/> to drop</param>
        /// 
        /// <exception cref="DroppingItemNotHeldException">
        /// if the <see cref="Thing"/> is not in the <see cref="Person"/>'s
        /// <see cref="Hands"/>
        /// </exception>
        /// 
        /// <exception cref="DroppingCursedUndroppableItemException">
        /// if the <see cref="Thing"/> is cursed/undroppable
        /// </exception>
        public override void Drop(Thing item)
        {
            // if the actor isn't carrying the item, throw an exception
            if(!this.Carries(item)) {
                throw new DroppingItemNotHeldException(); }

            // if the item is cursed/undroppable, throw an exception
            if(!item.CanBeDropped()) {
                throw new DroppingCursedUndroppableItemException(); }

            // actor is carrying the item and it is not cursed
            else {
                this.hands.RemoveThing(item);
                item.SetLocation(this.GetLocation());
                this.GetLocation().AddThing(item);
                GameManager.ReportIfVisible(this, VerbSet.ToDrop, item); }
        }