aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/Model/Area.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/Model/Area.scala')
-rw-r--r--src/main/scala/Model/Area.scala10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/scala/Model/Area.scala b/src/main/scala/Model/Area.scala
index 5a8de2a..6721957 100644
--- a/src/main/scala/Model/Area.scala
+++ b/src/main/scala/Model/Area.scala
@@ -22,7 +22,8 @@ class Area(val name: String, var description: String):
def getNeighborNames: Iterable[String] = this.neighbors.keys
def getItemNames: Iterable[String] = this.items.keys
- def getEntityNames: Iterable[String] = this.entities.keys
+ def getEntityNames: Iterable[String] = this.entities.values.map(_.name)
+ def getEntity(name: String): Option[Entity] = this.entities.get(name)
def getEntities: Iterable[Entity] = this.entities.values
/** Tells whether this area has a neighbor in the given direction.
@@ -73,7 +74,8 @@ class Area(val name: String, var description: String):
*
* @param entity the entity to add.
*/
- def addEntity(entity: Entity): Unit = this.entities += entity.name -> entity
+ def addEntity(entity: Entity): Unit =
+ this.entities += entity.name.toLowerCase -> entity
/** Removes the entity with the name `entityName`.
*
@@ -81,7 +83,7 @@ class Area(val name: String, var description: String):
* @return an option containing the removed entity if it was in the area
*/
def removeEntity(entityName: String): Option[Entity] =
- this.entities.remove(entityName)
+ this.entities.remove(entityName.toLowerCase())
/** Returns a multi-line description of the area as a player sees it. This includes a basic
* description of the area as well as information about exits and items. If there are no
@@ -92,7 +94,7 @@ class Area(val name: String, var description: String):
def fullDescription: String =
val exitList = this.neighbors.keys.mkString(" ")
val itemList = this.items.keys.mkString(" ")
- val entityList = this.entities.keys.mkString(" ")
+ val entityList = this.getEntityNames.mkString(" ")
val itemDescription =
if this.items.nonEmpty then
s"\nYou see here: ${itemList}"