diff options
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 + |