From ef51d51372df08de05a1ac35903ee4d6d9490328 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 16 Apr 2014 00:54:30 +0200 Subject: Implement undroppable items --- src/esieequest/controller/Performer.java | 4 ++++ src/esieequest/model/items/Item.java | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index de8d814..8c61f3a 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java @@ -188,6 +188,10 @@ class Performer { * the item's name */ public void dropItem(final String itemName) { + if (!this.game.getPlayer().getInventory().getItem(itemName).isDroppable()) { + this.echo("This item cannot be dropped."); + return; + } this.moveItem(this.game.getPlayer().getInventory(), this.game.getPlayer().getCurrentRoom().getItems(), itemName); } diff --git a/src/esieequest/model/items/Item.java b/src/esieequest/model/items/Item.java index b9d6deb..8f5582b 100644 --- a/src/esieequest/model/items/Item.java +++ b/src/esieequest/model/items/Item.java @@ -48,4 +48,13 @@ public class Item { return this.weight; } + /** + * Tells whether the item is droppable. + * + * @return the droppability of the item. + */ + public boolean isDroppable() { + return this.droppable; + } + } -- cgit v1.2.3