aboutsummaryrefslogtreecommitdiff
path: root/src/scalevalapokalypsi/Client
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-26 14:03:23 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-26 14:10:45 +0200
commit38900e0b291d5e0f59afaaa239cd237f733b6588 (patch)
treeee04f697ab17a75c9563ee87763cbcdcde8d297b /src/scalevalapokalypsi/Client
parent27dd937617cce1e43df1c16e12050f6e88763d54 (diff)
downloadscalevalapokalypsi-38900e0b291d5e0f59afaaa239cd237f733b6588.tar.gz
scalevalapokalypsi-38900e0b291d5e0f59afaaa239cd237f733b6588.zip
Dying properly
Diffstat (limited to 'src/scalevalapokalypsi/Client')
-rw-r--r--src/scalevalapokalypsi/Client/Client.scala9
-rw-r--r--src/scalevalapokalypsi/Client/GameEvent.scala3
2 files changed, 9 insertions, 3 deletions
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
)