aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/main.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/main.scala')
-rw-r--r--src/main/scala/main.scala22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/main/scala/main.scala b/src/main/scala/main.scala
index 145dc1c..362c270 100644
--- a/src/main/scala/main.scala
+++ b/src/main/scala/main.scala
@@ -1,15 +1,25 @@
-import o1game.Client.Client
+import o1game.Client.newClient
import o1game.Server.Server
+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("Please choose:\n1) Client.Client\n2) Server\n> ")
- readLine().toIntOption match
- case Some(1) => Client("127.0.0.1", 2267).startClient()
- case Some(2) => Server(2267, 5, 30, true).startServer()
- case _ => println("Invalid input")
+ 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())
+ 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")