From 5060c66738898913ca880d83b0fdcd5be2e0b59d Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sun, 17 Nov 2024 14:19:58 +0200 Subject: Small style fixes (mostly shortening comment lines written by others...) --- src/scalevalapokalypsi/Model/Area.scala | 56 ++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'src/scalevalapokalypsi/Model/Area.scala') diff --git a/src/scalevalapokalypsi/Model/Area.scala b/src/scalevalapokalypsi/Model/Area.scala index c891af8..a11b0e5 100644 --- a/src/scalevalapokalypsi/Model/Area.scala +++ b/src/scalevalapokalypsi/Model/Area.scala @@ -1,22 +1,29 @@ package scalevalapokalypsi.Model import scala.collection.mutable.Map - -/** The class `Area` represents locations in a text adventure game world. A game world - * consists of areas. In general, an “area” can be pretty much anything: a room, a building, - * an acre of forest, or something completely different. What different areas have in - * common is that players can be located in them and that they can have exits leading to - * other, neighboring areas. An area also has a name and a description. +import scalevalapokalypsi.Model.Entities.* + +/** The class `Area` represents locations in a text adventure game world. A game + * world consists of areas. In general, an “area” can be pretty much anything: + * a room, a building, an acre of forest, or something completely different. + * What different areas have in common is that players can be located in them + * and that they can have exits leading to other, neighboring areas. An area + * also has a name and a description. + * * @param name the name of the area - * @param description a basic description of the area (typically not including information about items) */ + * @param description a basic description of the area (typically not including + * information about items) + */ class Area(val name: String, var description: String): private val neighbors = Map[String, Area]() private val items: Map[String, Item] = Map() private val entities: Map[String, Entity] = Map() - /** 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. */ + /** 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): Option[Area] = this.neighbors.get(direction) @@ -34,15 +41,19 @@ class Area(val name: String, var description: String): 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. */ + /** Adds an exit from this area to the given area. The neighboring area is + * reached by moving in the specified direction from this area. */ def setNeighbor(direction: String, neighbor: Area) = this.neighbors += direction -> neighbor - /** Adds exits from this area to the given areas. Calling this method is equivalent to calling - * the `setNeighbor` method on each of the given direction–area pairs. - * @param exits contains pairs consisting of a direction and the neighboring area in that direction - * @see [[setNeighbor]] */ + /** Adds exits from this area to the given areas. Calling this method is + * equivalent to calling the `setNeighbor` method on each of the given + * direction–area pairs. + * + * @param exits contains pairs consisting of a direction and the + * neighboring area in that direction + * @see [[setNeighbor]] + */ def setNeighbors(exits: Vector[(String, Area)]) = this.neighbors ++= exits @@ -85,12 +96,15 @@ class Area(val name: String, var description: String): def removeEntity(entityName: String): Option[Entity] = 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 - * items present, the return value has the form "DESCRIPTION\n\nExits available: - * DIRECTIONS SEPARATED BY SPACES". If there are one or more items present, the return - * value has the form "DESCRIPTION\nYou see here: ITEMS SEPARATED BY SPACES\n\nExits available: - * DIRECTIONS SEPARATED BY SPACES". The items and directions are listed in an arbitrary order. */ + /** 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 items present, the return value has the + * form "DESCRIPTION\n\nExits available: + * DIRECTIONS SEPARATED BY SPACES". If there are one or more items present, + * the return value has the form "DESCRIPTION\nYou see here: ITEMS + * SEPARATED BY SPACES\n\nExits available: DIRECTIONS SEPARATED BY SPACES". + * The items and directions are listed in an arbitrary order. + */ def fullDescription: String = val exitList = this.neighbors.keys.mkString(" ") val itemList = this.items.keys.mkString(" ") -- cgit v1.2.3