diff options
Diffstat (limited to 'src/main/scala/Model/Area.scala')
-rw-r--r-- | src/main/scala/Model/Area.scala | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main/scala/Model/Area.scala b/src/main/scala/Model/Area.scala index 97c75bf..f5b5289 100644 --- a/src/main/scala/Model/Area.scala +++ b/src/main/scala/Model/Area.scala @@ -17,7 +17,16 @@ class Area(val name: String, var description: String): /** Returns the area that can be reached from this area by moving in the given direction. The result * is returned in an `Option`; `None` is returned if there is no exit in the given direction. */ - def neighbor(direction: String) = this.neighbors.get(direction) + def neighbor(direction: String): Option[Area] = + this.neighbors.get(direction) + + /** Tells whether this area has a neighbor in the given direction. + * + * @param direction the direction to check + * @return whether there is a neighbor in the direction + */ + def hasNeighbor(direction: String): Boolean = + this.neighbors.contains(direction) /** Adds an exit from this area to the given area. The neighboring area is reached by moving in * the specified direction from this area. */ @@ -44,6 +53,9 @@ class Area(val name: String, var description: String): def addItems(items: IterableOnce[Item]) = items.iterator.foreach(i => this.items += i.name -> i) + def hasItem(itemName: String) = this.items.contains(itemName) + + /** Removes the specified item if it exists. * * @param itemName the name of the item to remove |