package scalevalapokalypsi.Model.Entities.NPCs import scala.collection.mutable.Buffer import scalevalapokalypsi.Model.* import scalevalapokalypsi.Model.Entities.* import scala.util.Random class Tentacle( adventure: Adventure, identifier: String, initialLocation: Area, ) extends NPC(adventure, identifier, initialLocation, 10, 10): private val damage = 5 private val dialogs = Vector( "splish", "splosh" ) override def getDialog: String = val dialogIndex = Random.between(0, this.dialogs.length) this.dialogs(dialogIndex) override def act(): Unit = val possibleVictims = this.location .getEntities .filter(_ != this) .filter(_ match case t: Tentacle => false case m: Miikkulainen => false case c: Cthulthu => 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.attack(possibleVictims(index)) ) private def attack(entity: Entity): Event = entity.takeDamage(this.damage) Event( Map.from(Vector(( entity, s"${this.name} iskee sinua!\n" + s"${entity.condition(0)}" ))), s"${this.name} iskee henkilöä ${entity.name}.\n" + s"${entity.condition(1)}" ) end Tentacle