aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Server/Server.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/scalevalapokalypsi/Server/Server.scala')
-rw-r--r--src/scalevalapokalypsi/Server/Server.scala21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/scalevalapokalypsi/Server/Server.scala b/src/scalevalapokalypsi/Server/Server.scala
index f18d5c0..db30283 100644
--- a/src/scalevalapokalypsi/Server/Server.scala
+++ b/src/scalevalapokalypsi/Server/Server.scala
@@ -52,6 +52,7 @@ class Server(
this.readFromAll()
this.clients.foreach(_.interpretData())
this.writeClientDataToClients()
+ this.makeClientsSing()
this.writeObservations()
if this.canExecuteTurns then
this.clients.inRandomOrder(_.act())
@@ -68,7 +69,11 @@ class Server(
)
startGameForClient(c)
)
- else if this.adventure.isEmpty && !this.clients.isEmpty && this.clients.forall(_.isReadyForGameStart) then
+ else if
+ this.adventure.isEmpty &&
+ !this.clients.isEmpty &&
+ this.clients.forall(_.isReadyForGameStart)
+ then
this.adventure = Some(Adventure(this.clients.names))
this.clients.foreach(startGameForClient(_))
this.previousTurn = currentTimeMillis() / 1000
@@ -97,7 +102,9 @@ class Server(
this.clients.foreach(c =>
if c.player != playerEntity then
- c.player.foreach(_.observe(s"${name.getOrElse("Unknown player")} joins the game."))
+ c.player.foreach(_.observe(
+ s"${name.getOrElse("Unknown player")} joins the game.")
+ )
)
@@ -109,6 +116,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
+ )
+ c.startSong()
+ )
+
/** Helper function to determine if the next turn can be taken */
private def canExecuteTurns: Boolean =
val requirement1 = this.adventure.isDefined