diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-27 12:29:43 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-27 12:29:43 +0200 |
commit | 98407b35ff477f372baa92bf582b90a961d4ad16 (patch) | |
tree | bb58925090075d1e9e30dd1593547db2cbe03bb6 /src/scalevalapokalypsi/Model/Entities/NPCs/Cultist.scala | |
parent | 38900e0b291d5e0f59afaaa239cd237f733b6588 (diff) | |
download | scalevalapokalypsi-98407b35ff477f372baa92bf582b90a961d4ad16.tar.gz scalevalapokalypsi-98407b35ff477f372baa92bf582b90a961d4ad16.zip |
Added part of story & improved singing with multiple verses & hemingway distance
Diffstat (limited to 'src/scalevalapokalypsi/Model/Entities/NPCs/Cultist.scala')
-rw-r--r-- | src/scalevalapokalypsi/Model/Entities/NPCs/Cultist.scala | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/scalevalapokalypsi/Model/Entities/NPCs/Cultist.scala b/src/scalevalapokalypsi/Model/Entities/NPCs/Cultist.scala new file mode 100644 index 0000000..fa5602e --- /dev/null +++ b/src/scalevalapokalypsi/Model/Entities/NPCs/Cultist.scala @@ -0,0 +1,53 @@ + +package scalevalapokalypsi.Model.Entities.NPCs + +import scala.collection.mutable.Buffer +import scalevalapokalypsi.Model.* +import scalevalapokalypsi.Model.Entities.* +import scala.util.Random + +class Cultist( + adventure: Adventure, + identifier: String, + initialLocation: Area, + initialHP: Int = 100, + maxHP: Int = 100 +) extends NPC(adventure, identifier, initialLocation, initialHP, maxHP): + + private val damage = 20 + + override def getDialog: String = + "Verta! Lisää verta!" + + override def act(): Unit = + val possibleVictims = this.location + .getEntities + .filter(_ != this) + .filter(_ match + case c: Cultist => false + case other => true + ) + .toVector + val index: Int = + if possibleVictims.isEmpty then 0 + else Random.between(0, possibleVictims.length) + if !possibleVictims.isEmpty then + this.location.observeEvent( + this.curse(possibleVictims(index)) + ) + + + private def curse(entity: Entity): Event = + entity.takeDamage(this.damage) + Event( + Map.from(Vector(( + entity, + s"${this.name} lausuu pimeän loitsun. Näet varjon pyyhältävän sinua kohti ja sinut valtaa kylmyys.\n" + + s"${entity.condition(0)}" + ))), + s"${this.name} käyttää kirousta henkilöön ${entity.name}\n" + + s"${entity.condition(1)}" + ) + +end Cultist + |