From 38900e0b291d5e0f59afaaa239cd237f733b6588 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Tue, 26 Nov 2024 14:03:23 +0200 Subject: Dying properly --- src/scalevalapokalypsi/Model/Entities/NPCs/NPC.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/scalevalapokalypsi/Model/Entities/NPCs/NPC.scala') 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)) -- cgit v1.2.3