diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-26 14:03:23 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-26 14:10:45 +0200 |
commit | 38900e0b291d5e0f59afaaa239cd237f733b6588 (patch) | |
tree | ee04f697ab17a75c9563ee87763cbcdcde8d297b /src/scalevalapokalypsi/Model/Entities/NPCs/NPC.scala | |
parent | 27dd937617cce1e43df1c16e12050f6e88763d54 (diff) | |
download | scalevalapokalypsi-38900e0b291d5e0f59afaaa239cd237f733b6588.tar.gz scalevalapokalypsi-38900e0b291d5e0f59afaaa239cd237f733b6588.zip |
Dying properly
Diffstat (limited to 'src/scalevalapokalypsi/Model/Entities/NPCs/NPC.scala')
-rw-r--r-- | src/scalevalapokalypsi/Model/Entities/NPCs/NPC.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/scalevalapokalypsi/Model/Entities/NPCs/NPC.scala b/src/scalevalapokalypsi/Model/Entities/NPCs/NPC.scala index 21709ba..944f2e6 100644 --- a/src/scalevalapokalypsi/Model/Entities/NPCs/NPC.scala +++ b/src/scalevalapokalypsi/Model/Entities/NPCs/NPC.scala @@ -17,19 +17,21 @@ import scala.util.Random * @param initialLocation the NPC’s initial location */ abstract class NPC( + adventure: Adventure, name: String, initialLocation: Area, initialHP: Int, maxHp: Int -) extends Entity(name, initialLocation, initialHP, maxHp): +) extends Entity(adventure, name, initialLocation, initialHP, maxHp): def getDialog: String def act(): Unit class Zombie( + adventure: Adventure, identifier: String, initialLocation: Area, initialHP: Int = 20 -) extends NPC(identifier, initialLocation, initialHP, 20): +) extends NPC(adventure, identifier, initialLocation, initialHP, 20): private val damage = 10 private val dialogs = Vector( @@ -60,7 +62,7 @@ class Zombie( .toVector .lift(directionIndex) .flatMap(this.go(_)) - .map(this.location.observeEvent(_)) + .foreach(this.location.observeEvent(_)) else this.location.observeEvent( this.attack(possibleVictims(index)) |