From 38900e0b291d5e0f59afaaa239cd237f733b6588 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Tue, 26 Nov 2024 14:03:23 +0200 Subject: Dying properly --- src/scalevalapokalypsi/Client/Client.scala | 9 +++++++-- src/scalevalapokalypsi/Client/GameEvent.scala | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/scalevalapokalypsi/Client') diff --git a/src/scalevalapokalypsi/Client/Client.scala b/src/scalevalapokalypsi/Client/Client.scala index e94fdb0..5364405 100644 --- a/src/scalevalapokalypsi/Client/Client.scala +++ b/src/scalevalapokalypsi/Client/Client.scala @@ -76,6 +76,7 @@ class Client(socket: Socket): "don't initialize with unexecuted turn" ) private val turnInfo = RoomState() + private var gameOver = false /** Takes a client step and optionally returns an in-game event for UI * @@ -108,7 +109,8 @@ class Client(socket: Socket): roomState, this.lineToSing, this.canAct, - Some(timeToTurnEnd).filter(p => this.lastTurnStart != 0) + Some(timeToTurnEnd).filter(p => this.lastTurnStart != 0), + !this.gameOver ) end clientStep @@ -157,6 +159,9 @@ class Client(socket: Socket): if line == TURN_INDICATOR then this.serverLineState = ServerLineState.TurnIndicator + if line == GAME_END_INDICATOR then + this.gameOver = true + serverLineState match case ServerLineState.WaitingForTimeLimit => @@ -185,7 +190,7 @@ class Client(socket: Socket): case ServerLineState.Directions => this.turnInfo.possibleDirections = line.split(LIST_SEPARATOR) - this.serverLineState = ServerLineState.Items // TODO: maybe use a list instead? + this.serverLineState = ServerLineState.Items case ServerLineState.Items => this.turnInfo.visibleItems = line.split(LIST_SEPARATOR) diff --git a/src/scalevalapokalypsi/Client/GameEvent.scala b/src/scalevalapokalypsi/Client/GameEvent.scala index 8aa1e1c..0397b48 100644 --- a/src/scalevalapokalypsi/Client/GameEvent.scala +++ b/src/scalevalapokalypsi/Client/GameEvent.scala @@ -5,7 +5,8 @@ class GameEvent( val roomState: Option[RoomState], val lineToSing: Option[String], val playerCanAct: Boolean, - val timeToNextTurn: Option[Long] + val timeToNextTurn: Option[Long], + val gameIsOn: Boolean ) -- cgit v1.2.3