Changed at how the run command starts TUI GUI and the server. This is neccessary so that TUI GUI and server start and the game from the TUI/GUI is registered in the server.
This commit is contained in:
@@ -64,6 +64,7 @@ dependencies {
|
||||
implementation(project(":modules:rule"))
|
||||
implementation(project(":modules:api"))
|
||||
implementation(project(":modules:io"))
|
||||
implementation(project(":modules:server"))
|
||||
|
||||
// ScalaFX dependencies
|
||||
implementation("org.scalafx:scalafx_3:${versions["SCALAFX"]!!}")
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
package de.nowchess.ui
|
||||
|
||||
import de.nowchess.chess.engine.GameEngine
|
||||
import de.nowchess.server.ServerLauncher
|
||||
import de.nowchess.ui.terminal.TerminalUI
|
||||
import de.nowchess.ui.gui.ChessGUILauncher
|
||||
|
||||
/** Application entry point - starts both GUI and Terminal UI for the chess game.
|
||||
* Both views subscribe to the same GameEngine via Observer pattern.
|
||||
* The REST server shares the same engine instance, so API moves are reflected in the UI.
|
||||
*/
|
||||
object Main:
|
||||
def main(args: Array[String]): Unit =
|
||||
// Create the core game engine (single source of truth)
|
||||
val engine = new GameEngine()
|
||||
val gameId = ServerLauncher.start(engine)
|
||||
println(s"REST API ready — game ID: $gameId → http://localhost:8080/api/board/game/$gameId")
|
||||
|
||||
// Launch ScalaFX GUI in separate thread
|
||||
ChessGUILauncher.launch(engine)
|
||||
|
||||
// Create and start the terminal UI (blocks on main thread)
|
||||
val tui = new TerminalUI(engine)
|
||||
tui.start()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user