aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Model/Adventure.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/scalevalapokalypsi/Model/Adventure.scala')
-rw-r--r--src/scalevalapokalypsi/Model/Adventure.scala23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/scalevalapokalypsi/Model/Adventure.scala b/src/scalevalapokalypsi/Model/Adventure.scala
index 9347bfa..09eed54 100644
--- a/src/scalevalapokalypsi/Model/Adventure.scala
+++ b/src/scalevalapokalypsi/Model/Adventure.scala
@@ -2,6 +2,7 @@ package scalevalapokalypsi.Model
import scala.collection.mutable.Map
import scalevalapokalypsi.Model.Entities.*
+import scalevalapokalypsi.Model.Entities.NPCs.*
/** The class `Adventure` holds data of the game world and provides methods
* for implementing a user interface for it.
@@ -20,7 +21,6 @@ class Adventure(val playerNames: Vector[String]):
private val clearing = Area("Forest Clearing", "You are at a small clearing in the middle of forest.\nNearly invisible, twisted paths lead in many directions.")
private val tangle = Area("Tangle of Bushes", "You are in a dense tangle of bushes. It's hard to see exactly where you're going.")
private val home = Area("Home", "Home sweet home! Now the only thing you need is a working remote control.")
- private val destination = home
middle.setNeighbors(Vector("north" -> northForest, "east" -> tangle, "south" -> southForest, "west" -> clearing))
northForest.setNeighbors(Vector("east" -> tangle, "south" -> middle, "west" -> clearing))
@@ -37,6 +37,23 @@ class Adventure(val playerNames: Vector[String]):
))
val entities: Map[String, Entity] = Map()
+
+ val npcs: Map[String, NPC] = Map()
+
+ private val zombieAttrs = Vector(
+ ("Weary zombie", clearing, 20),
+ ("Smelly zombie", home, 20),
+ ("Rotten zombie", tangle, 10)
+ )
+ zombieAttrs.foreach(z =>
+ val zombie = Zombie(z(0), z(1), z(2))
+ npcs += z(0) -> zombie
+ z(1).addEntity(zombie)
+ )
+
+ def takeNpcTurns(): Unit =
+ npcs.values.foreach(_.act())
+
private val gruu = Entity("Gruu", northForest)
northForest.addEntity(gruu)
this.entities += gruu.name -> gruu
@@ -64,7 +81,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))
+ this.players.get(name)
+ .orElse(this.npcs.get(name))
+ .getOrElse(this.entities.get(name))
end Adventure