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/Player.scala | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/scalevalapokalypsi/Model/Entities/Player.scala') diff --git a/src/scalevalapokalypsi/Model/Entities/Player.scala b/src/scalevalapokalypsi/Model/Entities/Player.scala index d6b3529..9fc929d 100644 --- a/src/scalevalapokalypsi/Model/Entities/Player.scala +++ b/src/scalevalapokalypsi/Model/Entities/Player.scala @@ -12,7 +12,11 @@ import scalevalapokalypsi.Model.* * @param name the player's name * @param initialLocation the player’s initial location */ -class Player(name: String, initialLocation: Area) extends Entity(name, initialLocation): +class Player( + adventure: Adventure, + name: String, + initialLocation: Area +) extends Entity(adventure, name, initialLocation): private val observations: Buffer[String] = Buffer.empty private val observedEvents: Buffer[Event] = Buffer.empty @@ -49,8 +53,6 @@ class Player(name: String, initialLocation: Area) extends Entity(name, initialLo * @param singQuality the quality of the song */ def applySingEffect(singQuality: Float): Unit = - val res = this.pendingSingEffect.map(ef => ef(singQuality)) - this.pendingSingEffect = None val qualityDescriptions = if singQuality < .10 then ("säälittävää", "epsilonin suuruinen") @@ -63,11 +65,10 @@ class Player(name: String, initialLocation: Area) extends Entity(name, initialLo else ("erinomaista", "merkittävä") val quality = s"Laulu on ${qualityDescriptions(0)} ja sen vaikutus on ${qualityDescriptions(1)}." - val event = res.map(ev => Event( - ev.inFirstPersons.map((k, v) => (k, s"$quality\n$v")), - s"$quality\n${ev.inThirdPerson}" - )) - event.foreach(this.location.observeEvent(_)) + val event = Event(Map.empty, s"$quality") + this.location.observeEvent(event) + this.pendingSingEffect.map(ef => ef(singQuality)) + this.pendingSingEffect = None -- cgit v1.2.3