aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/Model/Area.scala
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-07 22:52:25 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-07 22:52:25 +0200
commit239571e3408a3187953bef1dd5d516461bad0e31 (patch)
tree67c062a635affc90c08a92ac61adfed2445985d8 /src/main/scala/Model/Area.scala
parentdef8975617e5c6da431e41cc889d167b0f2e2bb0 (diff)
downloadscalevalapokalypsi-239571e3408a3187953bef1dd5d516461bad0e31.tar.gz
scalevalapokalypsi-239571e3408a3187953bef1dd5d516461bad0e31.zip
Added turns, time limits and turn order randomization (feature/bug?)
Diffstat (limited to 'src/main/scala/Model/Area.scala')
-rw-r--r--src/main/scala/Model/Area.scala14
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