aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Server/Server.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/Server/Server.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/Server/Server.scala')
-rw-r--r--src/scalevalapokalypsi/Server/Server.scala16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/scalevalapokalypsi/Server/Server.scala b/src/scalevalapokalypsi/Server/Server.scala
index db30283..609b581 100644
--- a/src/scalevalapokalypsi/Server/Server.scala
+++ b/src/scalevalapokalypsi/Server/Server.scala
@@ -102,7 +102,7 @@ class Server(
this.clients.foreach(c =>
if c.player != playerEntity then
- c.player.foreach(_.observe(
+ c.player.foreach(_.observeString(
s"${name.getOrElse("Unknown player")} joins the game.")
)
)
@@ -118,12 +118,16 @@ class Server(
private def makeClientsSing(): Unit =
this.clients.foreach(c =>
- if c.player.exists(_.isSinging) && !c.clientHasSong then
- this.writeToClient(
- s"${SING_INDICATOR}Esimerkkirivi laulettavaksi, lirulirulei\r\n",
- c
- )
+ val target = c.player.flatMap(_.getSingEffectTarget)
+ target.foreach(t =>
+ if c.player.exists(_.isSinging) && !c.clientHasSong then
+ this.writeToClient(
+ s"${SING_INDICATOR}${t.getVerseAgainst}\r\n",
+ // TODO: store the verse and check how close client input is when determining sing quality
+ c
+ )
c.startSong()
+ )
)
/** Helper function to determine if the next turn can be taken */