aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/Client
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-14 19:52:24 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2024-11-14 19:52:24 +0200
commitea18a265a22ffc4c3f6ec3ca9d2f542552da9705 (patch)
treed1c9c832d9fdb2592227c5a05254a28d178a0efd /src/main/scala/Client
parenta43812ed462630850edbf29bda182fbf1e5e1263 (diff)
downloadscalevalapokalypsi-ea18a265a22ffc4c3f6ec3ca9d2f542552da9705.tar.gz
scalevalapokalypsi-ea18a265a22ffc4c3f6ec3ca9d2f542552da9705.zip
Added immediate turn start for client, required minor protocol tweak
Diffstat (limited to 'src/main/scala/Client')
-rw-r--r--src/main/scala/Client/Client.scala9
1 files changed, 5 insertions, 4 deletions
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