aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Server/Server.scala
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-27 12:29:43 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-27 12:29:43 +0200
commit98407b35ff477f372baa92bf582b90a961d4ad16 (patch)
treebb58925090075d1e9e30dd1593547db2cbe03bb6 /src/scalevalapokalypsi/Server/Server.scala
parent38900e0b291d5e0f59afaaa239cd237f733b6588 (diff)
downloadscalevalapokalypsi-98407b35ff477f372baa92bf582b90a961d4ad16.tar.gz
scalevalapokalypsi-98407b35ff477f372baa92bf582b90a961d4ad16.zip
Added part of story & improved singing with multiple verses & hemingway distance
Diffstat (limited to 'src/scalevalapokalypsi/Server/Server.scala')
-rw-r--r--src/scalevalapokalypsi/Server/Server.scala14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/scalevalapokalypsi/Server/Server.scala b/src/scalevalapokalypsi/Server/Server.scala
index 16a2128..6bf21d4 100644
--- a/src/scalevalapokalypsi/Server/Server.scala
+++ b/src/scalevalapokalypsi/Server/Server.scala
@@ -51,8 +51,8 @@ class Server(
this.receiveNewClient()
this.readFromAll()
this.clients.foreach(_.interpretData())
- this.writeClientDataToClients()
this.makeClientsSing()
+ this.writeClientDataToClients()
this.writeObservations()
this.endGameForDeadClients()
if this.canExecuteTurns then
@@ -61,7 +61,7 @@ class Server(
this.clients.foreach(c =>
this.writeToClient(this.turnStartInfo(c), c)
)
- this.previousTurn = currentTimeMillis() / 1000
+ this.previousTurn = currentTimeMillis().toDouble / 1000.0
if this.adventure.isDefined && this.joinAfterStart then
this.clients.foreach( c => if c.isReadyForGameStart then
this.adventure.foreach(a =>
@@ -76,7 +76,7 @@ class Server(
then
this.adventure = Some(Adventure(this.clients.names))
this.clients.foreach(startGameForClient(_))
- this.previousTurn = currentTimeMillis() / 1000
+ this.previousTurn = currentTimeMillis().toDouble / 1000.0
/** Helper function to start the game for the specified client c.
* MAY ONLY BE USED IF `this.adventure` is Some!
@@ -120,13 +120,7 @@ class Server(
private def makeClientsSing(): Unit =
this.clients.foreach(c =>
- val target = c.player.flatMap(_.getSingEffectTarget)
- target.foreach(t =>
- if c.player.exists(_.isSinging) && !c.clientHasSong then
- val verse = t.getVerseAgainst
- this.writeToClient(s"${SING_INDICATOR}$verse\r\n", c)
- c.startSong(verse)
- )
+ c.startSongIfNeeded()
)
/** Helper function to determine if the next turn can be taken */