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.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/scalevalapokalypsi/Server/Server.scala b/src/scalevalapokalypsi/Server/Server.scala
index 2ea8bd4..16a2128 100644
--- a/src/scalevalapokalypsi/Server/Server.scala
+++ b/src/scalevalapokalypsi/Server/Server.scala
@@ -54,6 +54,7 @@ class Server(
this.writeClientDataToClients()
this.makeClientsSing()
this.writeObservations()
+ this.endGameForDeadClients()
if this.canExecuteTurns then
this.clients.foreach(_.giveTurn())
this.adventure.foreach(_.takeNpcTurns())
@@ -183,6 +184,18 @@ class Server(
output.flush()
)
+ private def endGameForDeadClients(): Unit =
+ this.clients.removeNonSatisfying(c =>
+ c.player.forall((p: Player) =>
+ if !p.isAlive then
+ this.writeToClient(s"$GAME_END_INDICATOR\r\n", c)
+ false
+ else
+ true
+ )
+ )
+
+
private def writeToClient(message: String, client: Client): Unit =
try {
val output = client.socket.getOutputStream