diff options
Diffstat (limited to 'src/main/scala/Model/Adventure.scala')
-rw-r--r-- | src/main/scala/Model/Adventure.scala | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main/scala/Model/Adventure.scala b/src/main/scala/Model/Adventure.scala index 7d5a061..dfcb100 100644 --- a/src/main/scala/Model/Adventure.scala +++ b/src/main/scala/Model/Adventure.scala @@ -1,6 +1,7 @@ package o1game.Model import scala.collection.mutable.Map + /** The class `Adventure` represents text adventure games. An adventure consists of a player and * a number of areas that make up the game world. It provides methods for playing the game one * turn at a time and for checking the state of the game. @@ -38,6 +39,9 @@ class Adventure(val playerNames: Vector[String]): playerNames.foreach(this.addPlayer(_)) val entities: Map[String, Entity] = Map() + private val gruu = Entity("Gruu", northForest) + northForest.addEntity(gruu) + this.entities += gruu.name -> gruu /** Adds a player entity with the specified name to the game. * @@ -57,6 +61,9 @@ class Adventure(val playerNames: Vector[String]): */ def getPlayer(name: String): Option[Player] = this.players.get(name) + def getEntity[A >: Entity](name: String) = + this.players.getOrElse(name, this.entities.get(name)) + /** Returns a message that is to be displayed to the player at the beginning of the game. */ def welcomeMessage = "Generic welcome message" |