From 4de67b497e0e229fe4a42f66f833640b6e50fd5a Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sun, 17 Nov 2024 13:45:44 +0200 Subject: Moved the project to an IDEA project & wrote part of README.txt --- src/scalevalapokalypsi/main.scala | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/scalevalapokalypsi/main.scala (limited to 'src/scalevalapokalypsi/main.scala') diff --git a/src/scalevalapokalypsi/main.scala b/src/scalevalapokalypsi/main.scala new file mode 100644 index 0000000..9633f73 --- /dev/null +++ b/src/scalevalapokalypsi/main.scala @@ -0,0 +1,27 @@ +package scalevalapokalypsi + +import scalevalapokalypsi.Client.newClient +import scalevalapokalypsi.Server.Server +import java.lang.Thread +import scala.concurrent.Future +import scala.concurrent.ExecutionContext.Implicits.global + +import scala.io.StdIn.readLine + +// TODO: add proper logic for starting the game +@main def main(): Unit = + print("How do you want to play?\n1) Host and join local game\n2) Join local game\n> ") + readLine().toIntOption match + case Some(1) => + Thread(() => new Server(2267, 5, 30, true).startServer()).start() + println("Server started in background.") + print("Choose a name:\n> ") + val name = readLine() + newClient(name, "127.0.0.1", 2267).map(_.startClient()) + case Some(2) => + print("Choose a name:\n> ") + val name = readLine() + newClient(name, "127.0.0.1", 2267).map(_.startClient()) + case _ => println("Invalid input") + + -- cgit v1.2.3