aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/Model/Entity.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/Model/Entity.scala')
-rw-r--r--src/main/scala/Model/Entity.scala10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/scala/Model/Entity.scala b/src/main/scala/Model/Entity.scala
index 37fdbc2..d8e8559 100644
--- a/src/main/scala/Model/Entity.scala
+++ b/src/main/scala/Model/Entity.scala
@@ -52,7 +52,8 @@ class Entity(val name: String, initialLocation: Area):
def go(direction: String): (String, String) =
val destination = this.location.neighbor(direction)
if destination.isDefined then
- this.currentLocation.removeEntity(this.name)
+ val removeSuccess = this.currentLocation.removeEntity(this.name)
+ assert(removeSuccess.isDefined) // Production - assertions off
this.currentLocation = destination.getOrElse(this.currentLocation)
destination.foreach(_.addEntity(this))
(s"You go $direction.", s"$name goes $direction")
@@ -76,6 +77,13 @@ class Entity(val name: String, initialLocation: Area):
(s"You drop the $itemName", s"$name drops the $itemName")
case None => ("You don't have that!", s"$name reaches their backpack to drop $itemName but miserably fails to find it there.")
+ def sayTo(entity: Entity, message: String): (String, String) =
+ entity.observe(s"Alice: \"$message\"")
+ (s"You say so to ${entity.name}.", "")
+
+ def say(message: String): (String, String) =
+ ("You say that aloud.", s"$name: \"$message\"")
+
/** Tells whether this entity can drop the specified item
* (if an action were to specify so).
*