aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Server
diff options
context:
space:
mode:
Diffstat (limited to 'src/scalevalapokalypsi/Server')
-rw-r--r--src/scalevalapokalypsi/Server/Client.scala4
-rw-r--r--src/scalevalapokalypsi/Server/Server.scala16
2 files changed, 11 insertions, 9 deletions
diff --git a/src/scalevalapokalypsi/Server/Client.scala b/src/scalevalapokalypsi/Server/Client.scala
index ceeff1f..1af83bf 100644
--- a/src/scalevalapokalypsi/Server/Client.scala
+++ b/src/scalevalapokalypsi/Server/Client.scala
@@ -169,10 +169,8 @@ class Client(val socket: Socket):
this.singStartTime match
case Some(t) =>
val timePassed = currentTimeMillis()/1000 - t
- this.player.flatMap(_.applySingEffect(
+ this.player.foreach(_.applySingEffect(
5 / max(5, timePassed)
- )).foreach(s => this.player.foreach((c: Player) =>
- c.observe(s"Lakkaat laulamasta.\n$s")
))
this.singStartTime = None
case None =>
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 */