aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Model/Entities/NPCs/Tentacle.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/scalevalapokalypsi/Model/Entities/NPCs/Tentacle.scala')
-rw-r--r--src/scalevalapokalypsi/Model/Entities/NPCs/Tentacle.scala59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/scalevalapokalypsi/Model/Entities/NPCs/Tentacle.scala b/src/scalevalapokalypsi/Model/Entities/NPCs/Tentacle.scala
new file mode 100644
index 0000000..8535551
--- /dev/null
+++ b/src/scalevalapokalypsi/Model/Entities/NPCs/Tentacle.scala
@@ -0,0 +1,59 @@
+
+
+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
+