From a98f089035dbcc94c14c9cd6246c3150bee84241 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sun, 17 Nov 2024 22:32:25 +0200 Subject: Improved client recovery from singing & added better logic for observations The logic should still be implemented for all observations --- src/scalevalapokalypsi/Server/Server.scala | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/scalevalapokalypsi/Server/Server.scala') 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 */ -- cgit v1.2.3