diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-15 17:00:41 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-15 17:00:41 +0200 |
commit | 165a89af296cf4f6bff0241477fced2e66e681d4 (patch) | |
tree | eaf4c22b9399706a26c35dd39bd30cbbd4b4b982 | |
parent | eeb83ca379e7f4ab1a86596b80e206df48371454 (diff) | |
download | scalevalapokalypsi-165a89af296cf4f6bff0241477fced2e66e681d4.tar.gz scalevalapokalypsi-165a89af296cf4f6bff0241477fced2e66e681d4.zip |
Added join messages as observations
-rw-r--r-- | src/main/scala/Client/Client.scala | 2 | ||||
-rw-r--r-- | src/main/scala/Server/Server.scala | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/main/scala/Client/Client.scala b/src/main/scala/Client/Client.scala index 26b9264..1c5d1b4 100644 --- a/src/main/scala/Client/Client.scala +++ b/src/main/scala/Client/Client.scala @@ -112,7 +112,7 @@ class Client(socket: Socket): s"\n\n${this.turnInfo}\n${this.actionGetterIndicator}" private def displayAction(action: String): Unit = - println(s"> $action") + println(s"$action") if this.canAct then print(this.actionGetterIndicator) diff --git a/src/main/scala/Server/Server.scala b/src/main/scala/Server/Server.scala index ac0e010..230fe59 100644 --- a/src/main/scala/Server/Server.scala +++ b/src/main/scala/Server/Server.scala @@ -95,12 +95,15 @@ class Server( s"$timeLimit\r\n${this.turnStartInfo(c)}", c ) + this.clients.foreach(c => + if c.player != playerEntity then + c.player.foreach(_.observe(s"${name.getOrElse("Unknown player")} joins the game.")) + ) + private def writeObservations(): Unit = this.clients.foreach(c => val observations = c.player.map(_.readAndClearObservations()) -// if observations.filter(_.length > 0).isDefined then -// println(s"Observations of $c: ```$observations```") observations.foreach(_.foreach((s: String) => this.writeToClient(s"$s\r\n", c))) ) |