From 165a89af296cf4f6bff0241477fced2e66e681d4 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Fri, 15 Nov 2024 17:00:41 +0200 Subject: Added join messages as observations --- src/main/scala/Server/Server.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main/scala/Server') 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))) ) -- cgit v1.2.3