From ea18a265a22ffc4c3f6ec3ca9d2f542552da9705 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Thu, 14 Nov 2024 19:52:24 +0200 Subject: Added immediate turn start for client, required minor protocol tweak --- src/main/scala/Client/Client.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/main/scala/Client') diff --git a/src/main/scala/Client/Client.scala b/src/main/scala/Client/Client.scala index e9d3074..7b0f8b2 100644 --- a/src/main/scala/Client/Client.scala +++ b/src/main/scala/Client/Client.scala @@ -17,7 +17,7 @@ import java.lang.System.currentTimeMillis /** A helper enum for `Client` to keep track of communications with the server */ enum ServerLineState: - case WaitingForGameStart, + case WaitingForTimeLimit, ActionDescription, TurnIndicator, AreaDescription, @@ -63,7 +63,7 @@ class Client(socket: Socket): private val serverLineParser = ReceivedLineParser() private val stdinReader = StdinLineReader() - private var serverLineState = ServerLineState.WaitingForGameStart + private var serverLineState = ServerLineState.WaitingForTimeLimit /** Variables about the status of the current turn for the client */ private var canAct = false @@ -140,12 +140,13 @@ class Client(socket: Socket): serverLineState match - case ServerLineState.WaitingForGameStart => + case ServerLineState.WaitingForTimeLimit => val time = line.toLongOption time match case Some(t) => this.timeLimit = t case None => print("Invalid time limit, oh no!!!") - this.serverLineState = ServerLineState.ActionDescription + this.serverLineState = ServerLineState.TurnIndicator + this.lastTurnStart = currentTimeMillis / 1000 case ServerLineState.ActionDescription => if line.head == ACTION_BLOCKING_INDICATOR then -- cgit v1.2.3