aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/scala/Client/Client.scala9
-rw-r--r--src/main/scala/main.scala3
2 files changed, 4 insertions, 8 deletions
diff --git a/src/main/scala/Client/Client.scala b/src/main/scala/Client/Client.scala
index ef98ef3..2503cdf 100644
--- a/src/main/scala/Client/Client.scala
+++ b/src/main/scala/Client/Client.scala
@@ -147,24 +147,19 @@ class Client(socket: Socket):
val directionDesc = "There are exits to " +
this.possibleDirections.mkString(", ")
(s"\n$actionDesc\n\n$areaDescription\n$directionDesc\n" +
- s"\n$itemDesc\n$entityDesc")
+ s"\n$itemDesc\n$entityDesc\n")
def startClient(): Unit =
stdinReader.startReading()
- // TODO: read data from server and store it in the turn description
- // TODO: if turn isn't executed since lastturnstart, display the data
- // and clean STDIN
- // TODO: write data from stdin and send it to the server
- // TODO: display timer to next turn end
while true do
sleep(POLL_INTERVAL)
this.readAndParseDataFromServer()
if this.lastExecutedTurn < this.lastTurnStart then
- println(this.giveTurn())
+ print(this.giveTurn())
stdinReader.newLine().foreach((s: String) =>
output.write(stringToByteArray(s+"\r\n"))
diff --git a/src/main/scala/main.scala b/src/main/scala/main.scala
index 362c270..d68664a 100644
--- a/src/main/scala/main.scala
+++ b/src/main/scala/main.scala
@@ -1,6 +1,7 @@
import o1game.Client.newClient
import o1game.Server.Server
+import java.lang.Thread
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
@@ -11,7 +12,7 @@ import scala.io.StdIn.readLine
print("How do you want to play?\n1) Host and join local game\n2) Join local game\n> ")
readLine().toIntOption match
case Some(1) =>
- Future(Server(2267, 5, 30, true).startServer())
+ Thread(() => Server(2267, 5, 30, true).startServer()).start()
println("Server started in background.")
print("Choose a name:\n> ")
val name = readLine()