aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Model/Entities/Entity.scala
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-17 22:32:25 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-17 22:32:25 +0200
commita98f089035dbcc94c14c9cd6246c3150bee84241 (patch)
tree228ffa0d5e4a3e86c454cd297644c97abc994ef3 /src/scalevalapokalypsi/Model/Entities/Entity.scala
parentc954ca4d1ec677a34a6d787a23f9d01396f7e585 (diff)
downloadscalevalapokalypsi-a98f089035dbcc94c14c9cd6246c3150bee84241.tar.gz
scalevalapokalypsi-a98f089035dbcc94c14c9cd6246c3150bee84241.zip
Improved client recovery from singing & added better logic for observations
The logic should still be implemented for all observations
Diffstat (limited to 'src/scalevalapokalypsi/Model/Entities/Entity.scala')
-rw-r--r--src/scalevalapokalypsi/Model/Entities/Entity.scala41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/scalevalapokalypsi/Model/Entities/Entity.scala b/src/scalevalapokalypsi/Model/Entities/Entity.scala
index 1592f2e..26dd7dc 100644
--- a/src/scalevalapokalypsi/Model/Entities/Entity.scala
+++ b/src/scalevalapokalypsi/Model/Entities/Entity.scala
@@ -20,25 +20,46 @@ class Entity(
private var quitCommandGiven = false // one-way flag
private val inventory: Map[String, Item] = Map()
private var hp = initialHP
-
+
+ // TODO: add logic for choosing from multiplu lines - can depend on HP etc.
+ /** Gets a verse to sing when attacking against this entity.
+ *
+ * @return the verse to sing against this entity
+ */
+ def getVerseAgainst: String = "Esimerkkirivi laulettavaksi"
+
def takeDamage(amount: Int): Unit =
hp -= amount
if hp < 0 then
println("Oh no, I died!")
-
- def condition: String =
+
+ /** Returns a description of the physical condition of this entity,
+ * i.e. the damage it has taken.
+ *
+ * @return a pair of strings, both of which describe the condition of this
+ * entity, the first of which is in first person and the second in
+ * third person.
+ */
+ def condition: (String, String) =
if hp < maxHP * .25 then
- s"$name näyttää maansa myyneeltä."
+ ("Sinua heikottaa ja tunnet olevasi lähellä häviötä.",
+ s"$name näyttää maansa myyneeltä.")
else if hp < maxHP * .50 then
- s"$name näyttää sinnittelevän yhä."
+ ("Sinnittelet yhä, mutta kuntosi on laskenut suuresti.",
+ s"$name näyttää sinnittelevän yhä.")
else if hp < maxHP * .75 then
- s"$name näyttää aavistuksen lannistuneelta."
+ ("Tunnet koettelemusten vaikutuksen, mutta et anna niiden lannistaa itseäsi",
+ s"$name näyttää aavistuksen lannistuneelta.")
+ else if hp < maxHP then
+ ("Olet voimissasi.", s"$name on yhä voimissaan.")
else
- s"$name on yhä täysissä voimissaan."
+ ("Olet täysin kunnossa.", s"$name näyttää kuin vastasyntyneeltä.")
/** Does nothing, except possibly in inherited classes. */
- def observe(observation: String): Unit =
- println("[debug] entity got observation & discarded it")
+ def observeString(observation: String): Unit =
+ println(" [debug] entity got observation string & discarded it")
+ def observe(event: Event): Unit =
+ println(" [debug] entity got observation event & discarded it")
/** Returns the player’s current location. */
def location = this.currentLocation
@@ -83,7 +104,7 @@ class Entity(
)
def sayTo(entity: Entity, message: String): (String, String) =
- entity.observe(s"${this.name}: \"$message\"")
+ entity.observeString(s"${this.name}: \"$message\"")
(s"You say so to ${entity.name}.", "")
def say(message: String): (String, String) =