aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Model/Entities/NPCs/Villager.scala
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-27 17:19:46 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-27 17:19:46 +0200
commit302455bac062080bf197b44e07ed53a3454be4c5 (patch)
tree8b189ba41699c9a095d27bf00d1114a65aaa420a /src/scalevalapokalypsi/Model/Entities/NPCs/Villager.scala
parent98407b35ff477f372baa92bf582b90a961d4ad16 (diff)
downloadscalevalapokalypsi-302455bac062080bf197b44e07ed53a3454be4c5.tar.gz
scalevalapokalypsi-302455bac062080bf197b44e07ed53a3454be4c5.zip
Finishing almost the adventure
Diffstat (limited to 'src/scalevalapokalypsi/Model/Entities/NPCs/Villager.scala')
-rw-r--r--src/scalevalapokalypsi/Model/Entities/NPCs/Villager.scala79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/scalevalapokalypsi/Model/Entities/NPCs/Villager.scala b/src/scalevalapokalypsi/Model/Entities/NPCs/Villager.scala
new file mode 100644
index 0000000..1b9629f
--- /dev/null
+++ b/src/scalevalapokalypsi/Model/Entities/NPCs/Villager.scala
@@ -0,0 +1,79 @@
+
+package scalevalapokalypsi.Model.Entities.NPCs
+
+import scalevalapokalypsi.Model.{Area,Event,Item,Adventure}
+
+class Villager(
+ adventure: Adventure,
+ name: String,
+ initialLocation: Area,
+ dialogs: Vector[(String, Option[Villager => Event])]
+) extends NPC(adventure, name, initialLocation, 100, 100):
+
+ private var dialogIndex = 0
+
+ def getDialog: String =
+ val (dialog, effect) = this.dialogs(dialogIndex)
+ effect.map(_(this)).map(this.location.observeEvent(_))
+ this.dialogIndex +=
+ (if dialogIndex < this.dialogs.length-1
+ then 1
+ else 0)
+ dialog
+
+ def act(): Unit = ()
+
+end Villager
+
+/*
+package scalevalapokalypsi.Model.Entities.NPCs
+
+import scalevalapokalypsi.Model.{Area,Event,Item,Adventure}
+import scala.math.min
+
+class Bartender(
+ adventure: Adventure,
+ initialLocation: Area
+) extends NPC(
+ adventure,
+ "baarimikko",
+ initialLocation,
+ 100,
+ 100
+):
+
+
+ private var dialogIndex = 0
+
+ private val dialogs = Vector(
+ "Onnea matkaan. Tarjoan sinulle tuopin olutta rohkaisuksi.",
+ "Onnea matkaan."
+ )
+
+ def getDialog: String =
+
+ if dialogIndex == 0 then
+ this.location.addItem(Item(
+ "oluttuoppi",
+ "Tuopillinen kuohuvaa ja raikasta olutta. Se tuoksuu aika vahvalta.",
+ 1
+ ))
+ this.location.observeEvent(
+ Event(
+ Map.empty,
+ "Baarimikko kaataa tuoppiin olutta ja asettaa oluttuopin pöydälle."
+ )
+ )
+
+ dialogIndex = min(dialogIndex + 1, this.dialogs.length)
+
+ dialogs(dialogIndex - 1)
+
+ end getDialog
+
+
+ def act(): Unit = ()
+
+
+end Bartender
+*/