+
+
+
\ No newline at end of file
diff --git a/.idea/scala_compiler.xml b/.idea/scala_compiler.xml
index 3af8876..a99d21e 100644
--- a/.idea/scala_compiler.xml
+++ b/.idea/scala_compiler.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/bruno/bruno.json b/bruno/bruno.json
new file mode 100644
index 0000000..95fa1d4
--- /dev/null
+++ b/bruno/bruno.json
@@ -0,0 +1,6 @@
+{
+ "version": "1",
+ "name": "NowChess API",
+ "type": "collection",
+ "ignore": []
+}
diff --git a/bruno/collection.bru b/bruno/collection.bru
new file mode 100644
index 0000000..e69de29
diff --git a/bruno/draw/01 Offer Draw.bru b/bruno/draw/01 Offer Draw.bru
new file mode 100644
index 0000000..2dc488b
--- /dev/null
+++ b/bruno/draw/01 Offer Draw.bru
@@ -0,0 +1,12 @@
+meta {
+ name: Offer Draw
+ type: http
+ seq: 1
+}
+
+http {
+ method: POST
+ url: {{baseUrl}}/api/board/game/{{gameId}}/draw/offer
+ body: none
+ auth: none
+}
diff --git a/bruno/draw/02 Accept Draw.bru b/bruno/draw/02 Accept Draw.bru
new file mode 100644
index 0000000..83495fb
--- /dev/null
+++ b/bruno/draw/02 Accept Draw.bru
@@ -0,0 +1,12 @@
+meta {
+ name: Accept Draw
+ type: http
+ seq: 2
+}
+
+http {
+ method: POST
+ url: {{baseUrl}}/api/board/game/{{gameId}}/draw/accept
+ body: none
+ auth: none
+}
diff --git a/bruno/draw/03 Decline Draw.bru b/bruno/draw/03 Decline Draw.bru
new file mode 100644
index 0000000..2dad7ec
--- /dev/null
+++ b/bruno/draw/03 Decline Draw.bru
@@ -0,0 +1,12 @@
+meta {
+ name: Decline Draw
+ type: http
+ seq: 3
+}
+
+http {
+ method: POST
+ url: {{baseUrl}}/api/board/game/{{gameId}}/draw/decline
+ body: none
+ auth: none
+}
diff --git a/bruno/draw/04 Claim Draw.bru b/bruno/draw/04 Claim Draw.bru
new file mode 100644
index 0000000..967992f
--- /dev/null
+++ b/bruno/draw/04 Claim Draw.bru
@@ -0,0 +1,12 @@
+meta {
+ name: Claim Draw
+ type: http
+ seq: 4
+}
+
+http {
+ method: POST
+ url: {{baseUrl}}/api/board/game/{{gameId}}/draw/claim
+ body: none
+ auth: none
+}
diff --git a/bruno/draw/folder.bru b/bruno/draw/folder.bru
new file mode 100644
index 0000000..51b3758
--- /dev/null
+++ b/bruno/draw/folder.bru
@@ -0,0 +1,4 @@
+meta {
+ name: draw
+ seq: 2
+}
diff --git a/bruno/environments/local.bru b/bruno/environments/local.bru
new file mode 100644
index 0000000..85aff34
--- /dev/null
+++ b/bruno/environments/local.bru
@@ -0,0 +1,3 @@
+vars {
+ baseUrl: http://localhost:8080
+}
diff --git a/bruno/export/01 Export FEN.bru b/bruno/export/01 Export FEN.bru
new file mode 100644
index 0000000..c6b3592
--- /dev/null
+++ b/bruno/export/01 Export FEN.bru
@@ -0,0 +1,12 @@
+meta {
+ name: Export FEN
+ type: http
+ seq: 1
+}
+
+http {
+ method: GET
+ url: {{baseUrl}}/api/board/game/{{gameId}}/export/fen
+ body: none
+ auth: none
+}
diff --git a/bruno/export/02 Export PGN.bru b/bruno/export/02 Export PGN.bru
new file mode 100644
index 0000000..ded0a2e
--- /dev/null
+++ b/bruno/export/02 Export PGN.bru
@@ -0,0 +1,12 @@
+meta {
+ name: Export PGN
+ type: http
+ seq: 2
+}
+
+http {
+ method: GET
+ url: {{baseUrl}}/api/board/game/{{gameId}}/export/pgn
+ body: none
+ auth: none
+}
diff --git a/bruno/export/folder.bru b/bruno/export/folder.bru
new file mode 100644
index 0000000..fcdb012
--- /dev/null
+++ b/bruno/export/folder.bru
@@ -0,0 +1,4 @@
+meta {
+ name: export
+ seq: 6
+}
diff --git a/bruno/game/01 Create Game.bru b/bruno/game/01 Create Game.bru
new file mode 100644
index 0000000..85139dc
--- /dev/null
+++ b/bruno/game/01 Create Game.bru
@@ -0,0 +1,23 @@
+meta {
+ name: Create Game
+ type: http
+ seq: 1
+}
+
+http {
+ method: POST
+ url: {{baseUrl}}/api/board/game
+ body: json
+ auth: none
+}
+
+headers {
+ Content-Type: application/json
+}
+
+body:json {
+ {
+ "white": {"id": "p1", "displayName": "Alice"},
+ "black": {"id": "p2", "displayName": "Bob"}
+ }
+}
diff --git a/bruno/game/02 Get Game.bru b/bruno/game/02 Get Game.bru
new file mode 100644
index 0000000..b9f0e65
--- /dev/null
+++ b/bruno/game/02 Get Game.bru
@@ -0,0 +1,12 @@
+meta {
+ name: Get Game
+ type: http
+ seq: 2
+}
+
+http {
+ method: GET
+ url: {{baseUrl}}/api/board/game/{{gameId}}
+ body: none
+ auth: none
+}
diff --git a/bruno/game/03 Stream Game.bru b/bruno/game/03 Stream Game.bru
new file mode 100644
index 0000000..e85e594
--- /dev/null
+++ b/bruno/game/03 Stream Game.bru
@@ -0,0 +1,19 @@
+meta {
+ name: Stream Game
+ type: http
+ seq: 3
+}
+
+get {
+ url: {{baseUrl}}/api/board/game/{{gameId}}/stream
+ body: none
+ auth: none
+}
+
+headers {
+ Accept: application/x-ndjson
+}
+
+vars:pre-request {
+ gameId: tjOgyEcS
+}
diff --git a/bruno/game/04 Resign.bru b/bruno/game/04 Resign.bru
new file mode 100644
index 0000000..e9ccd11
--- /dev/null
+++ b/bruno/game/04 Resign.bru
@@ -0,0 +1,12 @@
+meta {
+ name: Resign
+ type: http
+ seq: 4
+}
+
+http {
+ method: POST
+ url: {{baseUrl}}/api/board/game/{{gameId}}/resign
+ body: none
+ auth: none
+}
diff --git a/bruno/game/folder.bru b/bruno/game/folder.bru
new file mode 100644
index 0000000..428a895
--- /dev/null
+++ b/bruno/game/folder.bru
@@ -0,0 +1,4 @@
+meta {
+ name: game
+ seq: 3
+}
diff --git a/bruno/import/01 Import FEN.bru b/bruno/import/01 Import FEN.bru
new file mode 100644
index 0000000..ddd86d4
--- /dev/null
+++ b/bruno/import/01 Import FEN.bru
@@ -0,0 +1,24 @@
+meta {
+ name: Import FEN
+ type: http
+ seq: 1
+}
+
+http {
+ method: POST
+ url: {{baseUrl}}/api/board/game/import/fen
+ body: json
+ auth: none
+}
+
+headers {
+ Content-Type: application/json
+}
+
+body:json {
+ {
+ "fen": "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1",
+ "white": {"id": "p1", "displayName": "Alice"},
+ "black": {"id": "p2", "displayName": "Bob"}
+ }
+}
diff --git a/bruno/import/02 Import PGN.bru b/bruno/import/02 Import PGN.bru
new file mode 100644
index 0000000..930e96a
--- /dev/null
+++ b/bruno/import/02 Import PGN.bru
@@ -0,0 +1,22 @@
+meta {
+ name: Import PGN
+ type: http
+ seq: 2
+}
+
+http {
+ method: POST
+ url: {{baseUrl}}/api/board/game/import/pgn
+ body: json
+ auth: none
+}
+
+headers {
+ Content-Type: application/json
+}
+
+body:json {
+ {
+ "pgn": "1. e4 e5 2. Nf3 Nc6 *"
+ }
+}
diff --git a/bruno/import/folder.bru b/bruno/import/folder.bru
new file mode 100644
index 0000000..719f1b5
--- /dev/null
+++ b/bruno/import/folder.bru
@@ -0,0 +1,4 @@
+meta {
+ name: import
+ seq: 5
+}
diff --git a/bruno/move/01 Make Move.bru b/bruno/move/01 Make Move.bru
new file mode 100644
index 0000000..8600477
--- /dev/null
+++ b/bruno/move/01 Make Move.bru
@@ -0,0 +1,15 @@
+meta {
+ name: Make Move
+ type: http
+ seq: 1
+}
+
+post {
+ url: {{baseUrl}}/api/board/game/{{gameId}}/move/b1c3
+ body: none
+ auth: none
+}
+
+vars:pre-request {
+ gameId: tjOgyEcS
+}
diff --git a/bruno/move/02 Get Legal Moves.bru b/bruno/move/02 Get Legal Moves.bru
new file mode 100644
index 0000000..1226024
--- /dev/null
+++ b/bruno/move/02 Get Legal Moves.bru
@@ -0,0 +1,19 @@
+meta {
+ name: Get Legal Moves
+ type: http
+ seq: 2
+}
+
+get {
+ url: {{baseUrl}}/api/board/game/{{gameId}}/moves
+ body: none
+ auth: none
+}
+
+params:query {
+ square: e2
+}
+
+vars:pre-request {
+ gameId: tjOgyEcS
+}
diff --git a/bruno/move/03 Undo Move.bru b/bruno/move/03 Undo Move.bru
new file mode 100644
index 0000000..a240931
--- /dev/null
+++ b/bruno/move/03 Undo Move.bru
@@ -0,0 +1,12 @@
+meta {
+ name: Undo Move
+ type: http
+ seq: 3
+}
+
+http {
+ method: POST
+ url: {{baseUrl}}/api/board/game/{{gameId}}/undo
+ body: none
+ auth: none
+}
diff --git a/bruno/move/04 Redo Move.bru b/bruno/move/04 Redo Move.bru
new file mode 100644
index 0000000..70b6250
--- /dev/null
+++ b/bruno/move/04 Redo Move.bru
@@ -0,0 +1,12 @@
+meta {
+ name: Redo Move
+ type: http
+ seq: 4
+}
+
+http {
+ method: POST
+ url: {{baseUrl}}/api/board/game/{{gameId}}/redo
+ body: none
+ auth: none
+}
diff --git a/bruno/move/folder.bru b/bruno/move/folder.bru
new file mode 100644
index 0000000..64aca60
--- /dev/null
+++ b/bruno/move/folder.bru
@@ -0,0 +1,3 @@
+meta {
+ name: move
+}
diff --git a/docs/api-spec.yaml b/docs/board-api-spec.yaml
similarity index 98%
rename from docs/api-spec.yaml
rename to docs/board-api-spec.yaml
index 8b20333..61bf241 100644
--- a/docs/api-spec.yaml
+++ b/docs/board-api-spec.yaml
@@ -1,6 +1,6 @@
openapi: 3.0.3
info:
- title: NowChess API
+ title: NowChess Board API
description: |
REST API for the NowChess application. Designed to feel familiar to users
of the [lichess API](https://lichess.org/api).
@@ -186,11 +186,8 @@ paths:
currently to move.
For promotion moves include the target piece as the fifth character:
- `e7e8q`, `a2a1r`, etc.
-
- If the move results in a pawn reaching the back rank and no promotion
- character is supplied, the game enters `promotionPending` status and
- the move is not yet applied — resubmit with the promotion character.
+ `e7e8q`, `a2a1r`, etc. Promotion moves without the fifth character
+ are rejected with `400 INVALID_MOVE`.
security:
- bearerAuth: []
parameters:
@@ -630,7 +627,6 @@ components:
| `draw` | Draw agreed or claimed — game over |
| `drawOffered` | Waiting for the opponent to accept or decline a draw offer |
| `fiftyMoveAvailable` | Fifty-move rule threshold reached; active player may claim draw |
- | `promotionPending` | A pawn reached the back rank; awaiting promotion piece selection |
| `insufficientMaterial` | Neither side has enough pieces to deliver checkmate — game over (draw) |
enum:
- started
@@ -641,7 +637,6 @@ components:
- draw
- drawOffered
- fiftyMoveAvailable
- - promotionPending
- insufficientMaterial
# -------------------------------------------------------------------------
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/ApiErrorDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/ApiErrorDto.scala
new file mode 100644
index 0000000..cb2864e
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/ApiErrorDto.scala
@@ -0,0 +1,3 @@
+package de.nowchess.api.dto
+
+final case class ApiErrorDto(code: String, message: String, field: Option[String])
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/CreateGameRequestDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/CreateGameRequestDto.scala
new file mode 100644
index 0000000..7f18de4
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/CreateGameRequestDto.scala
@@ -0,0 +1,6 @@
+package de.nowchess.api.dto
+
+final case class CreateGameRequestDto(
+ white: Option[PlayerInfoDto],
+ black: Option[PlayerInfoDto],
+)
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/ErrorEventDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/ErrorEventDto.scala
new file mode 100644
index 0000000..a93cd6f
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/ErrorEventDto.scala
@@ -0,0 +1,6 @@
+package de.nowchess.api.dto
+
+final case class ErrorEventDto(`type`: String, error: ApiErrorDto)
+
+object ErrorEventDto:
+ def apply(error: ApiErrorDto): ErrorEventDto = ErrorEventDto("error", error)
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/GameFullDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/GameFullDto.scala
new file mode 100644
index 0000000..5de6a75
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/GameFullDto.scala
@@ -0,0 +1,8 @@
+package de.nowchess.api.dto
+
+final case class GameFullDto(
+ gameId: String,
+ white: PlayerInfoDto,
+ black: PlayerInfoDto,
+ state: GameStateDto,
+)
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/GameFullEventDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/GameFullEventDto.scala
new file mode 100644
index 0000000..20fcaeb
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/GameFullEventDto.scala
@@ -0,0 +1,6 @@
+package de.nowchess.api.dto
+
+final case class GameFullEventDto(`type`: String, game: GameFullDto)
+
+object GameFullEventDto:
+ def apply(game: GameFullDto): GameFullEventDto = GameFullEventDto("gameFull", game)
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/GameStateDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/GameStateDto.scala
new file mode 100644
index 0000000..5556d3c
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/GameStateDto.scala
@@ -0,0 +1,12 @@
+package de.nowchess.api.dto
+
+final case class GameStateDto(
+ fen: String,
+ pgn: String,
+ turn: String,
+ status: String,
+ winner: Option[String],
+ moves: List[String],
+ undoAvailable: Boolean,
+ redoAvailable: Boolean,
+)
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/GameStateEventDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/GameStateEventDto.scala
new file mode 100644
index 0000000..e9e5e58
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/GameStateEventDto.scala
@@ -0,0 +1,6 @@
+package de.nowchess.api.dto
+
+final case class GameStateEventDto(`type`: String, state: GameStateDto)
+
+object GameStateEventDto:
+ def apply(state: GameStateDto): GameStateEventDto = GameStateEventDto("gameState", state)
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/ImportFenRequestDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/ImportFenRequestDto.scala
new file mode 100644
index 0000000..19f35b6
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/ImportFenRequestDto.scala
@@ -0,0 +1,7 @@
+package de.nowchess.api.dto
+
+final case class ImportFenRequestDto(
+ fen: String,
+ white: Option[PlayerInfoDto],
+ black: Option[PlayerInfoDto],
+)
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/ImportPgnRequestDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/ImportPgnRequestDto.scala
new file mode 100644
index 0000000..ac09011
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/ImportPgnRequestDto.scala
@@ -0,0 +1,3 @@
+package de.nowchess.api.dto
+
+final case class ImportPgnRequestDto(pgn: String)
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/LegalMoveDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/LegalMoveDto.scala
new file mode 100644
index 0000000..81c0223
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/LegalMoveDto.scala
@@ -0,0 +1,9 @@
+package de.nowchess.api.dto
+
+final case class LegalMoveDto(
+ from: String,
+ to: String,
+ uci: String,
+ moveType: String,
+ promotion: Option[String],
+)
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/LegalMovesResponseDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/LegalMovesResponseDto.scala
new file mode 100644
index 0000000..6149ceb
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/LegalMovesResponseDto.scala
@@ -0,0 +1,3 @@
+package de.nowchess.api.dto
+
+final case class LegalMovesResponseDto(moves: List[LegalMoveDto])
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/OkResponseDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/OkResponseDto.scala
new file mode 100644
index 0000000..35da71d
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/OkResponseDto.scala
@@ -0,0 +1,3 @@
+package de.nowchess.api.dto
+
+final case class OkResponseDto(ok: Boolean = true)
diff --git a/modules/api/src/main/scala/de/nowchess/api/dto/PlayerInfoDto.scala b/modules/api/src/main/scala/de/nowchess/api/dto/PlayerInfoDto.scala
new file mode 100644
index 0000000..ee00f74
--- /dev/null
+++ b/modules/api/src/main/scala/de/nowchess/api/dto/PlayerInfoDto.scala
@@ -0,0 +1,3 @@
+package de.nowchess.api.dto
+
+final case class PlayerInfoDto(id: String, displayName: String)
diff --git a/modules/core/build.gradle.kts b/modules/core/build.gradle.kts
index c61a0e2..be07b0d 100644
--- a/modules/core/build.gradle.kts
+++ b/modules/core/build.gradle.kts
@@ -63,6 +63,8 @@ dependencies {
implementation("io.quarkus:quarkus-micrometer")
implementation("io.quarkus:quarkus-arc")
+ implementation("com.fasterxml.jackson.module:jackson-module-scala_3:${versions["JACKSON_SCALA"]!!}")
+
testImplementation(platform("org.junit:junit-bom:5.13.4"))
testImplementation("org.junit.jupiter:junit-jupiter")
diff --git a/modules/core/src/main/scala/de/nowchess/chess/config/JacksonConfig.scala b/modules/core/src/main/scala/de/nowchess/chess/config/JacksonConfig.scala
new file mode 100644
index 0000000..188a328
--- /dev/null
+++ b/modules/core/src/main/scala/de/nowchess/chess/config/JacksonConfig.scala
@@ -0,0 +1,11 @@
+package de.nowchess.chess.config
+
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.module.scala.DefaultScalaModule
+import io.quarkus.jackson.ObjectMapperCustomizer
+import jakarta.inject.Singleton
+
+@Singleton
+class JacksonConfig extends ObjectMapperCustomizer:
+ def customize(mapper: ObjectMapper): Unit =
+ mapper.registerModule(DefaultScalaModule)
diff --git a/modules/core/src/main/scala/de/nowchess/chess/engine/GameEngine.scala b/modules/core/src/main/scala/de/nowchess/chess/engine/GameEngine.scala
index 872098d..aff04eb 100644
--- a/modules/core/src/main/scala/de/nowchess/chess/engine/GameEngine.scala
+++ b/modules/core/src/main/scala/de/nowchess/chess/engine/GameEngine.scala
@@ -258,6 +258,22 @@ class GameEngine(
notifyObservers(BoardResetEvent(currentContext))
}
+ /** Resign the game on behalf of the side to move. */
+ def resign(): Unit = synchronized {
+ if currentContext.result.isEmpty then
+ val winner = currentContext.turn.opposite
+ currentContext = currentContext.withResult(Some(GameResult.Win(winner)))
+ invoker.clear()
+ }
+
+ /** Apply a draw result directly (for agreement, fifty-move claim, etc.). */
+ def applyDraw(reason: DrawReason): Unit = synchronized {
+ if currentContext.result.isEmpty then
+ currentContext = currentContext.withResult(Some(GameResult.Draw(reason)))
+ invoker.clear()
+ notifyObservers(DrawEvent(currentContext, reason))
+ }
+
/** Kick off play when the side to move is a bot (e.g. bot-vs-bot from initial position). */
def startGame(): Unit = synchronized(requestBotMoveIfNeeded())
diff --git a/modules/core/src/main/scala/de/nowchess/chess/exception/ApiException.scala b/modules/core/src/main/scala/de/nowchess/chess/exception/ApiException.scala
new file mode 100644
index 0000000..24fd729
--- /dev/null
+++ b/modules/core/src/main/scala/de/nowchess/chess/exception/ApiException.scala
@@ -0,0 +1,13 @@
+package de.nowchess.chess.exception
+
+class ApiException(
+ val status: Int,
+ val code: String,
+ message: String,
+ val field: Option[String] = None,
+) extends RuntimeException(message)
+
+class GameNotFoundException(gameId: String) extends ApiException(404, "GAME_NOT_FOUND", s"Game $gameId not found")
+
+class BadRequestException(code: String, message: String, field: Option[String] = None)
+ extends ApiException(400, code, message, field)
diff --git a/modules/core/src/main/scala/de/nowchess/chess/exception/ApiExceptionMapper.scala b/modules/core/src/main/scala/de/nowchess/chess/exception/ApiExceptionMapper.scala
new file mode 100644
index 0000000..50595d0
--- /dev/null
+++ b/modules/core/src/main/scala/de/nowchess/chess/exception/ApiExceptionMapper.scala
@@ -0,0 +1,14 @@
+package de.nowchess.chess.exception
+
+import de.nowchess.api.dto.ApiErrorDto
+import jakarta.ws.rs.core.{MediaType, Response}
+import jakarta.ws.rs.ext.{ExceptionMapper, Provider}
+
+@Provider
+class ApiExceptionMapper extends ExceptionMapper[ApiException]:
+ def toResponse(ex: ApiException): Response =
+ Response
+ .status(ex.status)
+ .entity(ApiErrorDto(ex.code, ex.getMessage, ex.field))
+ .`type`(MediaType.APPLICATION_JSON)
+ .build()
diff --git a/modules/core/src/main/scala/de/nowchess/chess/registry/GameEntry.scala b/modules/core/src/main/scala/de/nowchess/chess/registry/GameEntry.scala
new file mode 100644
index 0000000..74c240e
--- /dev/null
+++ b/modules/core/src/main/scala/de/nowchess/chess/registry/GameEntry.scala
@@ -0,0 +1,14 @@
+package de.nowchess.chess.registry
+
+import de.nowchess.api.board.Color
+import de.nowchess.api.player.PlayerInfo
+import de.nowchess.chess.engine.GameEngine
+
+final case class GameEntry(
+ gameId: String,
+ engine: GameEngine,
+ white: PlayerInfo,
+ black: PlayerInfo,
+ drawOfferedBy: Option[Color] = None,
+ resigned: Boolean = false,
+)
diff --git a/modules/core/src/main/scala/de/nowchess/chess/registry/GameRegistry.scala b/modules/core/src/main/scala/de/nowchess/chess/registry/GameRegistry.scala
new file mode 100644
index 0000000..be25fd7
--- /dev/null
+++ b/modules/core/src/main/scala/de/nowchess/chess/registry/GameRegistry.scala
@@ -0,0 +1,7 @@
+package de.nowchess.chess.registry
+
+trait GameRegistry:
+ def store(entry: GameEntry): Unit
+ def get(gameId: String): Option[GameEntry]
+ def update(entry: GameEntry): Unit
+ def generateId(): String
diff --git a/modules/core/src/main/scala/de/nowchess/chess/registry/GameRegistryImpl.scala b/modules/core/src/main/scala/de/nowchess/chess/registry/GameRegistryImpl.scala
new file mode 100644
index 0000000..8b338f5
--- /dev/null
+++ b/modules/core/src/main/scala/de/nowchess/chess/registry/GameRegistryImpl.scala
@@ -0,0 +1,22 @@
+package de.nowchess.chess.registry
+
+import jakarta.enterprise.context.ApplicationScoped
+import java.util.concurrent.ConcurrentHashMap
+import scala.util.Random
+
+@ApplicationScoped
+class GameRegistryImpl extends GameRegistry:
+ private val games = ConcurrentHashMap[String, GameEntry]()
+
+ def store(entry: GameEntry): Unit =
+ games.put(entry.gameId, entry)
+
+ def get(gameId: String): Option[GameEntry] =
+ Option(games.get(gameId))
+
+ def update(entry: GameEntry): Unit =
+ games.put(entry.gameId, entry)
+
+ def generateId(): String =
+ val chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
+ Iterator.continually(Random.nextInt(chars.length)).map(chars).take(8).mkString
diff --git a/modules/core/src/main/scala/de/nowchess/chess/resource/GameResource.scala b/modules/core/src/main/scala/de/nowchess/chess/resource/GameResource.scala
new file mode 100644
index 0000000..356da6e
--- /dev/null
+++ b/modules/core/src/main/scala/de/nowchess/chess/resource/GameResource.scala
@@ -0,0 +1,306 @@
+package de.nowchess.chess.resource
+
+import com.fasterxml.jackson.databind.ObjectMapper
+import de.nowchess.api.board.Square
+import de.nowchess.api.dto.*
+import de.nowchess.api.game.{DrawReason, GameContext, GameResult}
+import de.nowchess.api.move.{Move, MoveType, PromotionPiece}
+import de.nowchess.api.player.{PlayerId, PlayerInfo}
+import de.nowchess.chess.controller.Parser
+import de.nowchess.chess.engine.GameEngine
+import de.nowchess.chess.exception.{BadRequestException, GameNotFoundException}
+import de.nowchess.chess.observer.*
+import de.nowchess.chess.registry.{GameEntry, GameRegistry}
+import de.nowchess.io.fen.{FenExporter, FenParser}
+import de.nowchess.io.pgn.{PgnExporter, PgnParser}
+import io.smallrye.mutiny.Multi
+import jakarta.enterprise.context.ApplicationScoped
+import jakarta.inject.Inject
+import jakarta.ws.rs.*
+import jakarta.ws.rs.core.{MediaType, Response}
+
+import java.util.concurrent.atomic.AtomicReference
+
+@Path("/api/board/game")
+@ApplicationScoped
+class GameResource(@Inject val registry: GameRegistry, @Inject val objectMapper: ObjectMapper):
+
+ private val DefaultWhite = PlayerInfo(PlayerId("p1"), "Player 1")
+ private val DefaultBlack = PlayerInfo(PlayerId("p2"), "Player 2")
+
+ // ── mapping ──────────────────────────────────────────────────────────────
+
+ private def statusOf(entry: GameEntry): String =
+ if entry.drawOfferedBy.isDefined then "drawOffered"
+ else
+ val ctx = entry.engine.context
+ ctx.result match
+ case Some(GameResult.Win(_)) =>
+ if entry.resigned then "resign" else "checkmate"
+ case Some(GameResult.Draw(DrawReason.Stalemate)) => "stalemate"
+ case Some(GameResult.Draw(DrawReason.InsufficientMaterial)) => "insufficientMaterial"
+ case Some(GameResult.Draw(_)) => "draw"
+ case None =>
+ if ctx.halfMoveClock >= 100 then "fiftyMoveAvailable"
+ else if entry.engine.ruleSet.isCheck(ctx) then "check"
+ else "started"
+
+ private def moveToUci(move: Move): String =
+ val base = s"${move.from}${move.to}"
+ move.moveType match
+ case MoveType.Promotion(PromotionPiece.Queen) => s"${base}q"
+ case MoveType.Promotion(PromotionPiece.Rook) => s"${base}r"
+ case MoveType.Promotion(PromotionPiece.Bishop) => s"${base}b"
+ case MoveType.Promotion(PromotionPiece.Knight) => s"${base}n"
+ case _ => base
+
+ private def toLegalMoveDto(move: Move): LegalMoveDto =
+ val (moveTypeStr, promotionStr) = move.moveType match
+ case MoveType.Normal(false) => ("normal", None)
+ case MoveType.Normal(true) => ("capture", None)
+ case MoveType.CastleKingside => ("castleKingside", None)
+ case MoveType.CastleQueenside => ("castleQueenside", None)
+ case MoveType.EnPassant => ("enPassant", None)
+ case MoveType.Promotion(PromotionPiece.Queen) => ("promotion", Some("queen"))
+ case MoveType.Promotion(PromotionPiece.Rook) => ("promotion", Some("rook"))
+ case MoveType.Promotion(PromotionPiece.Bishop) => ("promotion", Some("bishop"))
+ case MoveType.Promotion(PromotionPiece.Knight) => ("promotion", Some("knight"))
+ LegalMoveDto(move.from.toString, move.to.toString, moveToUci(move), moveTypeStr, promotionStr)
+
+ private def toPlayerDto(info: PlayerInfo): PlayerInfoDto =
+ PlayerInfoDto(info.id.value, info.displayName)
+
+ private def toGameStateDto(entry: GameEntry): GameStateDto =
+ val ctx = entry.engine.context
+ GameStateDto(
+ fen = FenExporter.exportGameContext(ctx),
+ pgn = PgnExporter.exportGame(
+ Map(
+ "Event" -> "NowChess game",
+ "White" -> entry.white.displayName,
+ "Black" -> entry.black.displayName,
+ "Result" -> "*",
+ ),
+ ctx.moves,
+ ),
+ turn = ctx.turn.label.toLowerCase,
+ status = statusOf(entry),
+ winner = ctx.result.collect { case GameResult.Win(c) => c.label.toLowerCase },
+ moves = ctx.moves.map(moveToUci),
+ undoAvailable = entry.engine.canUndo,
+ redoAvailable = entry.engine.canRedo,
+ )
+
+ private def toGameFullDto(entry: GameEntry): GameFullDto =
+ GameFullDto(entry.gameId, toPlayerDto(entry.white), toPlayerDto(entry.black), toGameStateDto(entry))
+
+ private def playerInfoFrom(dto: Option[PlayerInfoDto], default: PlayerInfo): PlayerInfo =
+ dto.fold(default)(d => PlayerInfo(PlayerId(d.id), d.displayName))
+
+ private def newEntry(ctx: GameContext, white: PlayerInfo, black: PlayerInfo): GameEntry =
+ GameEntry(registry.generateId(), GameEngine(initialContext = ctx), white, black)
+
+ private def applyMoveInput(engine: GameEngine, uci: String): Option[String] =
+ val error = new AtomicReference[Option[String]](None)
+ val obs = new Observer:
+ def onGameEvent(e: GameEvent): Unit = e match
+ case InvalidMoveEvent(_, reason) => error.set(Some(reason))
+ case _ => ()
+ engine.subscribe(obs)
+ engine.processUserInput(uci)
+ engine.unsubscribe(obs)
+ error.get()
+
+ // ── response helpers ─────────────────────────────────────────────────────
+
+ private def ok(body: AnyRef): Response = Response.ok(body).build()
+ private def created(body: AnyRef): Response = Response.status(Response.Status.CREATED).entity(body).build()
+
+ // ── endpoints ────────────────────────────────────────────────────────────
+ // scalafix:off DisableSyntax.throw
+
+ @POST
+ @Consumes(Array(MediaType.APPLICATION_JSON))
+ @Produces(Array(MediaType.APPLICATION_JSON))
+ def createGame(body: CreateGameRequestDto): Response =
+ val req = Option(body).getOrElse(CreateGameRequestDto(None, None))
+ val white = playerInfoFrom(req.white, DefaultWhite)
+ val black = playerInfoFrom(req.black, DefaultBlack)
+ val entry = newEntry(GameContext.initial, white, black)
+ registry.store(entry)
+ created(toGameFullDto(entry))
+
+ @GET
+ @Path("/{gameId}")
+ @Produces(Array(MediaType.APPLICATION_JSON))
+ def getGame(@PathParam("gameId") gameId: String): Response =
+ val entry = registry.get(gameId).getOrElse(throw GameNotFoundException(gameId))
+ ok(toGameFullDto(entry))
+
+ @GET
+ @Path("/{gameId}/stream")
+ @Produces(Array("application/x-ndjson"))
+ def streamGame(@PathParam("gameId") gameId: String): Multi[String] =
+ val entry = registry.get(gameId).getOrElse(throw GameNotFoundException(gameId))
+ Multi
+ .createFrom()
+ .emitter[String] { emitter =>
+ emitter.emit(objectMapper.writeValueAsString(GameFullEventDto(toGameFullDto(entry))) + "\n")
+ val obs = new Observer:
+ def onGameEvent(event: GameEvent): Unit =
+ registry.get(gameId).foreach { updated =>
+ emitter.emit(
+ objectMapper.writeValueAsString(GameStateEventDto(toGameStateDto(updated))) + "\n",
+ )
+ }
+ entry.engine.subscribe(obs)
+ emitter.onTermination(() => entry.engine.unsubscribe(obs))
+ }
+
+ @POST
+ @Path("/{gameId}/resign")
+ @Produces(Array(MediaType.APPLICATION_JSON))
+ def resignGame(@PathParam("gameId") gameId: String): Response =
+ val entry = registry.get(gameId).getOrElse(throw GameNotFoundException(gameId))
+ if entry.engine.context.result.isDefined then throw BadRequestException("GAME_OVER", "Game is already over")
+ entry.engine.resign()
+ registry.update(entry.copy(resigned = true))
+ ok(OkResponseDto())
+
+ @POST
+ @Path("/{gameId}/move/{uci}")
+ @Produces(Array(MediaType.APPLICATION_JSON))
+ def makeMove(@PathParam("gameId") gameId: String, @PathParam("uci") uci: String): Response =
+ val entry = registry.get(gameId).getOrElse(throw GameNotFoundException(gameId))
+ if entry.engine.context.result.isDefined then throw BadRequestException("GAME_OVER", "Game is already over")
+ val (from, to, promoOpt) = Parser
+ .parseMove(uci)
+ .getOrElse(throw BadRequestException("INVALID_UCI", s"Invalid UCI notation: $uci", Some("uci")))
+ val candidates = entry.engine.ruleSet.legalMoves(entry.engine.context)(from).filter(_.to == to)
+ val isPromotion = candidates.exists { case Move(_, _, MoveType.Promotion(_)) => true; case _ => false }
+ if candidates.isEmpty || (isPromotion && promoOpt.isEmpty) then
+ throw BadRequestException("INVALID_MOVE", s"$uci is not a legal move", Some("uci"))
+ applyMoveInput(entry.engine, uci).foreach(err => throw BadRequestException("INVALID_MOVE", err, Some("uci")))
+ ok(toGameStateDto(entry))
+
+ @GET
+ @Path("/{gameId}/moves")
+ @Produces(Array(MediaType.APPLICATION_JSON))
+ def getLegalMoves(
+ @PathParam("gameId") gameId: String,
+ @QueryParam("square") square: String,
+ ): Response =
+ val entry = registry.get(gameId).getOrElse(throw GameNotFoundException(gameId))
+ val ctx = entry.engine.context
+ val moves =
+ if Option(square).isEmpty || square.isEmpty then entry.engine.ruleSet.allLegalMoves(ctx)
+ else
+ val sq = Square
+ .fromAlgebraic(square)
+ .getOrElse(throw BadRequestException("INVALID_SQUARE", s"Invalid square: $square", Some("square")))
+ entry.engine.ruleSet.legalMoves(ctx)(sq)
+ ok(LegalMovesResponseDto(moves.map(toLegalMoveDto)))
+
+ @POST
+ @Path("/{gameId}/undo")
+ @Produces(Array(MediaType.APPLICATION_JSON))
+ def undoMove(@PathParam("gameId") gameId: String): Response =
+ val entry = registry.get(gameId).getOrElse(throw GameNotFoundException(gameId))
+ if !entry.engine.canUndo then throw BadRequestException("NO_UNDO", "No moves to undo")
+ entry.engine.undo()
+ ok(toGameStateDto(entry))
+
+ @POST
+ @Path("/{gameId}/redo")
+ @Produces(Array(MediaType.APPLICATION_JSON))
+ def redoMove(@PathParam("gameId") gameId: String): Response =
+ val entry = registry.get(gameId).getOrElse(throw GameNotFoundException(gameId))
+ if !entry.engine.canRedo then throw BadRequestException("NO_REDO", "No moves to redo")
+ entry.engine.redo()
+ ok(toGameStateDto(entry))
+
+ @POST
+ @Path("/{gameId}/draw/{action}")
+ @Produces(Array(MediaType.APPLICATION_JSON))
+ def drawAction(
+ @PathParam("gameId") gameId: String,
+ @PathParam("action") action: String,
+ ): Response =
+ val entry = registry.get(gameId).getOrElse(throw GameNotFoundException(gameId))
+ if entry.engine.context.result.isDefined then throw BadRequestException("GAME_OVER", "Game is already over")
+ action match
+ case "offer" =>
+ registry.update(entry.copy(drawOfferedBy = Some(entry.engine.context.turn)))
+ ok(OkResponseDto())
+ case "accept" =>
+ entry.drawOfferedBy match
+ case None =>
+ throw BadRequestException("NO_DRAW_OFFER", "No draw offer to accept")
+ case Some(offerer) if offerer == entry.engine.context.turn =>
+ throw BadRequestException("CANNOT_ACCEPT_OWN_OFFER", "Cannot accept your own draw offer")
+ case _ =>
+ entry.engine.applyDraw(DrawReason.Agreement)
+ registry.update(entry.copy(drawOfferedBy = None))
+ ok(OkResponseDto())
+ case "decline" =>
+ if entry.drawOfferedBy.isEmpty then throw BadRequestException("NO_DRAW_OFFER", "No draw offer to decline")
+ registry.update(entry.copy(drawOfferedBy = None))
+ ok(OkResponseDto())
+ case "claim" =>
+ if entry.engine.context.halfMoveClock < 100 then
+ throw BadRequestException("CLAIM_NOT_AVAILABLE", "Fifty-move rule draw is not available")
+ entry.engine.applyDraw(DrawReason.FiftyMoveRule)
+ ok(OkResponseDto())
+ case _ =>
+ throw BadRequestException("INVALID_ACTION", s"Unknown draw action: $action", Some("action"))
+
+ @POST
+ @Path("/import/fen")
+ @Consumes(Array(MediaType.APPLICATION_JSON))
+ @Produces(Array(MediaType.APPLICATION_JSON))
+ def importFen(body: ImportFenRequestDto): Response =
+ val ctx = FenParser.parseFen(body.fen) match
+ case Left(err) => throw BadRequestException("INVALID_FEN", err, Some("fen"))
+ case Right(ctx) => ctx
+ val white = playerInfoFrom(body.white, DefaultWhite)
+ val black = playerInfoFrom(body.black, DefaultBlack)
+ val entry = newEntry(ctx, white, black)
+ registry.store(entry)
+ created(toGameFullDto(entry))
+
+ @POST
+ @Path("/import/pgn")
+ @Consumes(Array(MediaType.APPLICATION_JSON))
+ @Produces(Array(MediaType.APPLICATION_JSON))
+ def importPgn(body: ImportPgnRequestDto): Response =
+ val engine = GameEngine()
+ engine.loadGame(PgnParser, body.pgn) match
+ case Left(err) => throw BadRequestException("INVALID_PGN", err, Some("pgn"))
+ case Right(_) => ()
+ val entry = GameEntry(registry.generateId(), engine, DefaultWhite, DefaultBlack)
+ registry.store(entry)
+ created(toGameFullDto(entry))
+
+ @GET
+ @Path("/{gameId}/export/fen")
+ @Produces(Array(MediaType.TEXT_PLAIN))
+ def exportFen(@PathParam("gameId") gameId: String): Response =
+ val entry = registry.get(gameId).getOrElse(throw GameNotFoundException(gameId))
+ ok(FenExporter.exportGameContext(entry.engine.context))
+
+ @GET
+ @Path("/{gameId}/export/pgn")
+ @Produces(Array("application/x-chess-pgn"))
+ def exportPgn(@PathParam("gameId") gameId: String): Response =
+ val entry = registry.get(gameId).getOrElse(throw GameNotFoundException(gameId))
+ val pgn = PgnExporter.exportGame(
+ Map(
+ "Event" -> "NowChess game",
+ "White" -> entry.white.displayName,
+ "Black" -> entry.black.displayName,
+ "Result" -> "*",
+ ),
+ entry.engine.context.moves,
+ )
+ ok(pgn)
+ // scalafix:on DisableSyntax.throw
diff --git a/modules/ui/CHANGELOG.md b/modules/ui/CHANGELOG.md
deleted file mode 100644
index cb97510..0000000
--- a/modules/ui/CHANGELOG.md
+++ /dev/null
@@ -1,106 +0,0 @@
-## (2026-04-01)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-## (2026-04-01)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-## (2026-04-01)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
-## (2026-04-02)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
-* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
-## (2026-04-03)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
-* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
-## (2026-04-07)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
-* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
-## (2026-04-07)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
-* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
-## (2026-04-12)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
-* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
-* NCS-29 JSON - Cherry Picked ([#28](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/28)) ([dbcafd2](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/dbcafd286993e0604a6fa286c5543581a149439e))
-## (2026-04-12)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
-* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
-* NCS-25 Add linters to keep quality up ([#27](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/27)) ([fd4e67d](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/fd4e67d4f782a7e955822d90cb909d0a81676fb2))
-* NCS-29 JSON - Cherry Picked ([#28](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/28)) ([dbcafd2](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/dbcafd286993e0604a6fa286c5543581a149439e))
-## (2026-04-14)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-14 implemented insufficient moves rule ([#30](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/30)) ([b0399a4](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/b0399a4e489950083066c9538df9a84dcc7a4613))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
-* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
-* NCS-25 Add linters to keep quality up ([#27](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/27)) ([fd4e67d](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/fd4e67d4f782a7e955822d90cb909d0a81676fb2))
-* NCS-29 JSON - Cherry Picked ([#28](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/28)) ([dbcafd2](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/dbcafd286993e0604a6fa286c5543581a149439e))
-## (2026-04-16)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-13 Implement Threefold Repetition ([#31](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/31)) ([767d305](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/767d3051a76c266050b6335774d66e2db2273c16))
-* NCS-14 implemented insufficient moves rule ([#30](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/30)) ([b0399a4](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/b0399a4e489950083066c9538df9a84dcc7a4613))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
-* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
-* NCS-25 Add linters to keep quality up ([#27](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/27)) ([fd4e67d](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/fd4e67d4f782a7e955822d90cb909d0a81676fb2))
-* NCS-29 JSON - Cherry Picked ([#28](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/28)) ([dbcafd2](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/dbcafd286993e0604a6fa286c5543581a149439e))
-## (2026-04-19)
-
-### Features
-
-* NCS-10 Implement Pawn Promotion ([#12](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/12)) ([13bfc16](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/13bfc16cfe25db78ec607db523ca6d993c13430c))
-* NCS-13 Implement Threefold Repetition ([#31](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/31)) ([767d305](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/767d3051a76c266050b6335774d66e2db2273c16))
-* NCS-14 implemented insufficient moves rule ([#30](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/30)) ([b0399a4](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/b0399a4e489950083066c9538df9a84dcc7a4613))
-* NCS-16 Core Separation via Patterns ([#10](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/10)) ([1361dfc](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/1361dfc89553b146864fb8ff3526cf12cf3f293a))
-* NCS-17 Implement basic ScalaFX UI ([#14](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/14)) ([3ff8031](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/3ff80318b4f16c59733a46498581a5c27f048287))
-* NCS-21 Write Scripts to automate certain tasks ([#15](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/15)) ([8051871](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/80518719d536a087d339fe02530825dc07f8b388))
-* NCS-25 Add linters to keep quality up ([#27](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/27)) ([fd4e67d](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/fd4e67d4f782a7e955822d90cb909d0a81676fb2))
-* NCS-29 JSON - Cherry Picked ([#28](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/28)) ([dbcafd2](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/dbcafd286993e0604a6fa286c5543581a149439e))
-* NCS-41 Bot Platform ([#33](https://git.janis-eccarius.de/NowChess/NowChessSystems/issues/33)) ([dceab08](https://git.janis-eccarius.de/NowChess/NowChessSystems/commit/dceab0875e6d15f7d3958633cf5dd5b29a851b1d))
diff --git a/modules/ui/build.gradle.kts b/modules/ui/build.gradle.kts
deleted file mode 100644
index 2a930c2..0000000
--- a/modules/ui/build.gradle.kts
+++ /dev/null
@@ -1,101 +0,0 @@
-import org.gradle.api.file.DuplicatesStrategy
-import org.gradle.jvm.tasks.Jar
-
-plugins {
- id("scala")
- id("org.scoverage")
- application
-}
-
-group = "de.nowchess"
-version = "1.0-SNAPSHOT"
-
-@Suppress("UNCHECKED_CAST")
-val versions = rootProject.extra["VERSIONS"] as Map
-
-repositories {
- mavenCentral()
-}
-
-scala {
- scalaVersion = versions["SCALA3"]!!
-}
-
-scoverage {
- scoverageVersion.set(versions["SCOVERAGE"]!!)
- excludedPackages.set(listOf("de\\.nowchess\\.ui\\..*"))
-}
-
-application {
- mainClass.set("de.nowchess.ui.Main")
-}
-
-tasks.withType {
- scalaCompileOptions.additionalParameters = listOf("-encoding", "UTF-8")
-}
-
-tasks.named("run") {
- jvmArgs("-Dfile.encoding=UTF-8", "-Dstdout.encoding=UTF-8", "-Dstderr.encoding=UTF-8")
- standardInput = System.`in`
-}
-
-tasks.named("jar") {
- duplicatesStrategy = DuplicatesStrategy.EXCLUDE
-}
-
-dependencies {
-
- implementation("org.scala-lang:scala3-compiler_3") {
- version {
- strictly(versions["SCALA3"]!!)
- }
- }
- implementation("org.scala-lang:scala3-library_3") {
- version {
- strictly(versions["SCALA3"]!!)
- }
- }
-
- implementation(project(":modules:core"))
- implementation(project(":modules:rule"))
- implementation(project(":modules:api"))
- implementation(project(":modules:io"))
- implementation(project(":modules:bot"))
-
- // ScalaFX dependencies
- implementation("org.scalafx:scalafx_3:${versions["SCALAFX"]!!}")
-
- // JavaFX dependencies for the current platform
- val javaFXVersion = versions["JAVAFX"]!!
- val osName = System.getProperty("os.name").lowercase()
- val platform = when {
- osName.contains("win") -> "win"
- osName.contains("mac") -> "mac"
- osName.contains("linux") -> "linux"
- else -> "linux"
- }
-
- listOf("base", "controls", "graphics", "media").forEach { module ->
- implementation("org.openjfx:javafx-$module:$javaFXVersion:$platform")
- }
-
- testImplementation(platform("org.junit:junit-bom:${versions["JUNIT_BOM"]!!}"))
- testImplementation("org.junit.jupiter:junit-jupiter")
- testImplementation("org.scalatest:scalatest_3:${versions["SCALATEST"]!!}")
- testImplementation("co.helmethair:scalatest-junit-runner:${versions["SCALATEST_JUNIT"]!!}")
-
- testRuntimeOnly("org.junit.platform:junit-platform-launcher")
-}
-
-tasks.test {
- useJUnitPlatform {
- includeEngines("scalatest")
- testLogging {
- events("skipped", "failed")
- }
- }
- finalizedBy(tasks.reportScoverage)
-}
-tasks.reportScoverage {
- dependsOn(tasks.test)
-}
diff --git a/modules/ui/src/main/resources/sprites/board/board_bottom.png b/modules/ui/src/main/resources/sprites/board/board_bottom.png
deleted file mode 100644
index 884fb3c..0000000
Binary files a/modules/ui/src/main/resources/sprites/board/board_bottom.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/board/board_square_black.png b/modules/ui/src/main/resources/sprites/board/board_square_black.png
deleted file mode 100644
index 42c4b9a..0000000
Binary files a/modules/ui/src/main/resources/sprites/board/board_square_black.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/board/board_square_white.png b/modules/ui/src/main/resources/sprites/board/board_square_white.png
deleted file mode 100644
index ea97b12..0000000
Binary files a/modules/ui/src/main/resources/sprites/board/board_square_white.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/black_bishop.png b/modules/ui/src/main/resources/sprites/pieces/black_bishop.png
deleted file mode 100644
index fe2c260..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/black_bishop.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/black_king.png b/modules/ui/src/main/resources/sprites/pieces/black_king.png
deleted file mode 100644
index f1c96bb..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/black_king.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/black_knight.png b/modules/ui/src/main/resources/sprites/pieces/black_knight.png
deleted file mode 100644
index 579db13..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/black_knight.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/black_pawn.png b/modules/ui/src/main/resources/sprites/pieces/black_pawn.png
deleted file mode 100644
index 92597c9..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/black_pawn.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/black_queen.png b/modules/ui/src/main/resources/sprites/pieces/black_queen.png
deleted file mode 100644
index 6d94c24..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/black_queen.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/black_rook.png b/modules/ui/src/main/resources/sprites/pieces/black_rook.png
deleted file mode 100644
index 7ab7e04..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/black_rook.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/white_bishop.png b/modules/ui/src/main/resources/sprites/pieces/white_bishop.png
deleted file mode 100644
index ab456ed..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/white_bishop.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/white_king.png b/modules/ui/src/main/resources/sprites/pieces/white_king.png
deleted file mode 100644
index 435d27a..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/white_king.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/white_knight.png b/modules/ui/src/main/resources/sprites/pieces/white_knight.png
deleted file mode 100644
index 7cf6ed6..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/white_knight.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/white_pawn.png b/modules/ui/src/main/resources/sprites/pieces/white_pawn.png
deleted file mode 100644
index 47cb262..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/white_pawn.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/white_queen.png b/modules/ui/src/main/resources/sprites/pieces/white_queen.png
deleted file mode 100644
index cb53ef1..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/white_queen.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/sprites/pieces/white_rook.png b/modules/ui/src/main/resources/sprites/pieces/white_rook.png
deleted file mode 100644
index 10ba443..0000000
Binary files a/modules/ui/src/main/resources/sprites/pieces/white_rook.png and /dev/null differ
diff --git a/modules/ui/src/main/resources/styles.css b/modules/ui/src/main/resources/styles.css
deleted file mode 100644
index aae36d1..0000000
--- a/modules/ui/src/main/resources/styles.css
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Arabian Chess GUI Styles */
-
-.root {
- -fx-font-family: "Comic Sans MS", "Comic Sans", cursive;
- -fx-background-color: #F3C8A0;
-}
-
-.button {
- -fx-background-radius: 8;
- -fx-padding: 8 16 8 16;
- -fx-font-family: "Comic Sans MS", cursive;
- -fx-font-size: 12px;
- -fx-cursor: hand;
-}
-
-.button:hover {
- -fx-opacity: 0.8;
-}
-
-.label {
- -fx-font-family: "Comic Sans MS", cursive;
-}
-
-.dialog-pane {
- -fx-background-color: #F3C8A0;
-}
-
-.dialog-pane .content {
- -fx-font-family: "Comic Sans MS", cursive;
-}
diff --git a/modules/ui/src/main/scala/de/nowchess/ui/Main.scala b/modules/ui/src/main/scala/de/nowchess/ui/Main.scala
deleted file mode 100644
index f5a8efd..0000000
--- a/modules/ui/src/main/scala/de/nowchess/ui/Main.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-package de.nowchess.ui
-
-import de.nowchess.api.game.{BotParticipant, Human}
-import de.nowchess.api.player.{PlayerId, PlayerInfo}
-import de.nowchess.bot.util.PolyglotBook
-import de.nowchess.bot.BotDifficulty
-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.
- */
-object Main:
- def main(args: Array[String]): Unit =
- val book = PolyglotBook("../../modules/bot/codekiddy.bin")
-
- // Create the core game engine (single source of truth)
- val engine = new de.nowchess.chess.engine.GameEngine(
- participants = Map(
- de.nowchess.api.board.Color.White -> BotParticipant(
- de.nowchess.bot.bots.HybridBot(BotDifficulty.Easy, book = Some(book)),
- ),
- de.nowchess.api.board.Color.Black -> Human(PlayerInfo(PlayerId("p1"), "Player 1")),
- ),
- )
-
- engine.startGame()
-
- // 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()
diff --git a/modules/ui/src/main/scala/de/nowchess/ui/gui/ChessBoardView.scala b/modules/ui/src/main/scala/de/nowchess/ui/gui/ChessBoardView.scala
deleted file mode 100644
index 649b15d..0000000
--- a/modules/ui/src/main/scala/de/nowchess/ui/gui/ChessBoardView.scala
+++ /dev/null
@@ -1,392 +0,0 @@
-package de.nowchess.ui.gui
-
-import java.util.concurrent.atomic.AtomicReference
-import scalafx.Includes.*
-import scalafx.application.Platform
-import scalafx.geometry.{Insets, Pos}
-import scalafx.scene.control.{Button, ButtonType, ChoiceDialog, Label}
-import scalafx.scene.layout.{BorderPane, GridPane, HBox, StackPane, VBox}
-import scalafx.scene.paint.Color as FXColor
-import scalafx.scene.shape.Rectangle
-import scalafx.scene.text.{Font, Text}
-import scalafx.stage.Stage
-import de.nowchess.api.board.{Board, Color, File, Piece, PieceType, Rank, Square}
-import de.nowchess.api.move.MoveType
-import de.nowchess.chess.command.{MoveCommand, MoveResult}
-import de.nowchess.chess.engine.GameEngine
-import de.nowchess.io.fen.{FenExporter, FenParser}
-import de.nowchess.io.pgn.{PgnExporter, PgnParser}
-import de.nowchess.io.json.{JsonExporter, JsonParser}
-import de.nowchess.io.{FileSystemGameService, GameContextExport, GameContextImport, GameFileService}
-import java.nio.file.Paths
-import scalafx.stage.FileChooser
-import scalafx.stage.FileChooser.ExtensionFilter
-
-/** ScalaFX chess board view that displays the game state. Uses chess sprites and color palette. Handles user
- * interactions (clicks) and sends moves to GameEngine.
- */
-class ChessBoardView(val stage: Stage, private val engine: GameEngine) extends BorderPane:
-
- private val squareSize = 70.0
- private val comicSansFontFamily = "Comic Sans MS"
- private val boardGrid = new GridPane()
- private val messageLabel = new Label {
- text = "Welcome!"
- font = Font.font(comicSansFontFamily, 16)
- padding = Insets(10)
- }
-
- private val currentBoard = new AtomicReference[Board](engine.board)
- private val currentTurn = new AtomicReference[Color](engine.turn)
- private val selectedSquare = new AtomicReference[Option[Square]](None)
- private val squareViews = scala.collection.mutable.Map[(Int, Int), StackPane]()
-
- private val undoButton: Button = new Button("Undo") {
- font = Font.font(comicSansFontFamily, 12)
- onAction = _ => if engine.canUndo then engine.undo()
- style = "-fx-background-radius: 8; -fx-background-color: #B9DAD1;"
- disable = !engine.canUndo
- }
- private val redoButton: Button = new Button("Redo") {
- font = Font.font(comicSansFontFamily, 12)
- onAction = _ => if engine.canRedo then engine.redo()
- style = "-fx-background-radius: 8; -fx-background-color: #B9C2DA;"
- disable = !engine.canRedo
- }
-
- // Initialize UI
- initializeBoard()
-
- top = new VBox {
- padding = Insets(10)
- spacing = 5
- alignment = Pos.Center
- children = Seq(
- new Label {
- text = "Chess"
- font = Font.font(comicSansFontFamily, 24)
- style = "-fx-font-weight: bold;"
- },
- messageLabel,
- )
- }
-
- center = new VBox {
- padding = Insets(20)
- alignment = Pos.Center
- style = s"-fx-background-color: ${PieceSprites.SquareColors.Border};"
- children = boardGrid
- }
-
- bottom = new VBox {
- padding = Insets(10)
- spacing = 8
- alignment = Pos.Center
- children = Seq(
- new HBox {
- spacing = 10
- alignment = Pos.Center
- children = Seq(
- undoButton,
- redoButton,
- new Button("Reset") {
- font = Font.font(comicSansFontFamily, 12)
- onAction = _ => engine.reset()
- style = "-fx-background-radius: 8; -fx-background-color: #E1EAA9;"
- },
- )
- },
- new HBox {
- spacing = 10
- alignment = Pos.Center
- children = Seq(
- new Button("FEN Export") {
- font = Font.font(comicSansFontFamily, 12)
- onAction = _ => doFenExport()
- style = "-fx-background-radius: 8; -fx-background-color: #DAC4B9;"
- },
- new Button("FEN Import") {
- font = Font.font(comicSansFontFamily, 12)
- onAction = _ => doFenImport()
- style = "-fx-background-radius: 8; -fx-background-color: #DAD4B9;"
- },
- new Button("PGN Export") {
- font = Font.font(comicSansFontFamily, 12)
- onAction = _ => doPgnExport()
- style = "-fx-background-radius: 8; -fx-background-color: #C4DAB9;"
- },
- new Button("PGN Import") {
- font = Font.font(comicSansFontFamily, 12)
- onAction = _ => doPgnImport()
- style = "-fx-background-radius: 8; -fx-background-color: #B9DAC4;"
- },
- )
- },
- new HBox {
- spacing = 10
- alignment = Pos.Center
- children = Seq(
- new Button("JSON Export") {
- font = Font.font(comicSansFontFamily, 12)
- onAction = _ => doJsonExport()
- style = "-fx-background-radius: 8; -fx-background-color: #B9C4DA;"
- },
- new Button("JSON Import") {
- font = Font.font(comicSansFontFamily, 12)
- onAction = _ => doJsonImport()
- style = "-fx-background-radius: 8; -fx-background-color: #C4B9DA;"
- },
- )
- },
- )
- }
-
- private def initializeBoard(): Unit =
- boardGrid.padding = Insets(5)
- boardGrid.hgap = 0
- boardGrid.vgap = 0
-
- // Create 8x8 board with rank/file labels
- for
- rank <- 0 until 8
- file <- 0 until 8
- do
- val square = createSquare(rank, file)
- squareViews((rank, file)) = square
- boardGrid.add(square, file, 7 - rank) // Flip rank for proper display
-
- updateBoard(currentBoard.get(), currentTurn.get())
-
- private def createSquare(rank: Int, file: Int): StackPane =
- val isWhite = (rank + file) % 2 == 0
- val baseColor = if isWhite then PieceSprites.SquareColors.White else PieceSprites.SquareColors.Black
-
- val bgRect = new Rectangle {
- width = squareSize
- height = squareSize
- fill = FXColor.web(baseColor)
- arcWidth = 8
- arcHeight = 8
- }
-
- val square = new StackPane {
- children = Seq(bgRect)
- onMouseClicked = _ => handleSquareClick(rank, file)
- style = "-fx-cursor: hand;"
- }
-
- square
-
- private def handleSquareClick(rank: Int, file: Int): Unit =
- val clickedSquare = Square(File.values(file), Rank.values(rank))
-
- selectedSquare.get() match
- case None =>
- // First click - select piece if it belongs to current player
- currentBoard.get().pieceAt(clickedSquare).foreach { piece =>
- if piece.color == currentTurn.get() then
- selectedSquare.set(Some(clickedSquare))
- highlightSquare(rank, file, PieceSprites.SquareColors.Selected)
-
- val legalDests = engine.ruleSet
- .legalMoves(engine.context)(clickedSquare)
- .collect { case move if move.from == clickedSquare => move.to }
- legalDests.foreach { sq =>
- highlightSquare(sq.rank.ordinal, sq.file.ordinal, PieceSprites.SquareColors.ValidMove)
- }
- }
-
- case Some(fromSquare) =>
- // Second click - attempt move
- if clickedSquare == fromSquare then
- // Deselect
- selectedSquare.set(None)
- updateBoard(currentBoard.get(), currentTurn.get())
- else
- val isPromo = engine.ruleSet
- .legalMoves(engine.context)(fromSquare)
- .exists(m =>
- m.to == clickedSquare && (m.moveType match
- case MoveType.Promotion(_) => true
- case _ => false
- ),
- )
- if isPromo then showPromotionDialog(fromSquare, clickedSquare)
- else engine.processUserInput(s"${fromSquare}$clickedSquare")
- selectedSquare.set(None)
-
- def updateBoard(board: Board, turn: Color): Unit =
- currentBoard.set(board)
- currentTurn.set(turn)
- selectedSquare.set(None)
-
- // Update all squares
- for
- rank <- 0 until 8
- file <- 0 until 8
- do
- squareViews.get((rank, file)).foreach { stackPane =>
- val isWhite = (rank + file) % 2 == 0
- val baseColor = if isWhite then PieceSprites.SquareColors.White else PieceSprites.SquareColors.Black
-
- val bgRect = new Rectangle {
- width = squareSize
- height = squareSize
- fill = FXColor.web(baseColor)
- arcWidth = 8
- arcHeight = 8
- }
-
- val square = Square(File.values(file), Rank.values(rank))
- val pieceOption = board.pieceAt(square)
-
- val children: Seq[scalafx.scene.Node] = pieceOption match
- case Some(piece) =>
- Seq(bgRect) ++ PieceSprites.loadPieceImage(piece, squareSize * 0.8).toSeq
- case None =>
- Seq(bgRect)
-
- stackPane.children = children
- }
-
- updateUndoRedoButtons()
-
- def updateUndoRedoButtons(): Unit =
- undoButton.disable = !engine.canUndo
- redoButton.disable = !engine.canRedo
-
- private def highlightSquare(rank: Int, file: Int, color: String): Unit =
- squareViews.get((rank, file)).foreach { stackPane =>
- val bgRect = new Rectangle {
- width = squareSize
- height = squareSize
- fill = FXColor.web(color)
- arcWidth = 8
- arcHeight = 8
- }
-
- val square = Square(File.values(file), Rank.values(rank))
- val pieceOption = currentBoard.get().pieceAt(square)
-
- stackPane.children = (pieceOption match
- case Some(piece) =>
- Seq(bgRect) ++ PieceSprites.loadPieceImage(piece, squareSize * 0.8).toSeq
- case None =>
- Seq(bgRect)
- ): Seq[scalafx.scene.Node]
- }
-
- def showMessage(msg: String): Unit =
- messageLabel.text = msg
-
- def showPromotionDialog(from: Square, to: Square): Unit =
- val choices = Seq("Queen", "Rook", "Bishop", "Knight")
- val dialog = new ChoiceDialog(defaultChoice = "Queen", choices = choices) {
- initOwner(stage)
- title = "Pawn Promotion"
- headerText = "Choose promotion piece"
- contentText = "Promote to:"
- }
- val uciSuffix = dialog.showAndWait() match
- case Some("Rook") => "r"
- case Some("Bishop") => "b"
- case Some("Knight") => "n"
- case _ => "q"
- engine.processUserInput(s"${from}${to}$uciSuffix")
-
- private def doFenExport(): Unit =
- doExport(FenExporter, "FEN")
-
- private def doFenImport(): Unit =
- doImport(FenParser, "FEN")
-
- private def doPgnExport(): Unit =
- doExport(PgnExporter, "PGN")
-
- private def doPgnImport(): Unit =
- doImport(PgnParser, "PGN")
-
- private def doJsonExport(): Unit =
- val fileChooser = new FileChooser {
- title = "Export Game as JSON"
- initialFileName = "chess_game.json"
- extensionFilters.add(new ExtensionFilter("JSON files (*.json)", "*.json"))
- extensionFilters.add(new ExtensionFilter("All files", "*.*"))
- }
-
- Option(fileChooser.showSaveDialog(stage)).foreach { selectedFile =>
- val result = FileSystemGameService.saveGameToFile(
- engine.context,
- selectedFile.toPath,
- JsonExporter,
- )
- result match
- case Right(_) => showMessage(s"✓ Game saved to: ${selectedFile.getName}")
- case Left(err) => showMessage(s"⚠️ Error saving file: $err")
- }
-
- private def doJsonImport(): Unit =
- val fileChooser = new FileChooser {
- title = "Import Game from JSON"
- extensionFilters.add(new ExtensionFilter("JSON files (*.json)", "*.json"))
- extensionFilters.add(new ExtensionFilter("All files", "*.*"))
- }
-
- Option(fileChooser.showOpenDialog(stage)).foreach { selectedFile =>
- val result = FileSystemGameService.loadGameFromFile(
- selectedFile.toPath,
- JsonParser,
- )
- result match
- case Right(gameContext) =>
- engine.loadPosition(gameContext)
- showMessage(s"✓ Game loaded from: ${selectedFile.getName}")
- case Left(err) =>
- showMessage(s"⚠️ Error: $err")
- }
-
- private def doExport(exporter: GameContextExport, formatName: String): Unit = {
- val exported = exporter.exportGameContext(engine.context)
- showCopyDialog(s"$formatName Export", exported)
- }
-
- private def doImport(importer: GameContextImport, formatName: String): Unit =
- showInputDialog(s"$formatName Import", rows = 5).foreach { input =>
- importer.importGameContext(input) match
- case Right(gameContext) =>
- engine.loadPosition(gameContext)
- showMessage(s"✓ $formatName loaded successfully!")
- case Left(err) =>
- showMessage(s"⚠️ $formatName Error: $err")
- }
-
- private def showCopyDialog(title: String, content: String): Unit =
- val area = new javafx.scene.control.TextArea(content)
- area.setEditable(false)
- area.setWrapText(true)
- area.setPrefRowCount(4)
- val alert = new javafx.scene.control.Alert(javafx.scene.control.Alert.AlertType.INFORMATION)
- alert.setTitle(title)
- alert.setHeaderText("")
- alert.getDialogPane.setContent(area)
- alert.getDialogPane.setPrefWidth(500)
- alert.initOwner(stage.delegate)
- alert.showAndWait()
-
- private def showInputDialog(title: String, rows: Int = 2): Option[String] =
- val area = new javafx.scene.control.TextArea()
- area.setWrapText(true)
- area.setPrefRowCount(rows)
- val dialog = new javafx.scene.control.Dialog[String]()
- dialog.setTitle(title)
- dialog.getDialogPane.setContent(area)
- dialog.getDialogPane.getButtonTypes.addAll(
- javafx.scene.control.ButtonType.OK,
- javafx.scene.control.ButtonType.CANCEL,
- )
- dialog.setResultConverter { bt =>
- if bt == javafx.scene.control.ButtonType.OK then area.getText else ""
- }
- dialog.initOwner(stage.delegate)
- val result = dialog.showAndWait()
- if result.isPresent && result.get.nonEmpty then Some(result.get) else None
diff --git a/modules/ui/src/main/scala/de/nowchess/ui/gui/ChessGUI.scala b/modules/ui/src/main/scala/de/nowchess/ui/gui/ChessGUI.scala
deleted file mode 100644
index 04829df..0000000
--- a/modules/ui/src/main/scala/de/nowchess/ui/gui/ChessGUI.scala
+++ /dev/null
@@ -1,57 +0,0 @@
-package de.nowchess.ui.gui
-
-import javafx.application.{Application as JFXApplication, Platform as JFXPlatform}
-import javafx.stage.Stage as JFXStage
-import scalafx.application.Platform
-import scalafx.scene.Scene
-import scalafx.stage.Stage
-import de.nowchess.chess.engine.GameEngine
-
-/** ScalaFX GUI Application for Chess. This is launched from Main alongside the TUI. Both subscribe to the same
- * GameEngine via Observer pattern.
- */
-class ChessGUIApp extends JFXApplication:
-
- override def start(primaryStage: JFXStage): Unit =
- val engine = ChessGUILauncher.getEngine
- val stage = new Stage(primaryStage)
-
- stage.title = "Chess"
- stage.width = 700
- stage.height = 1000
- stage.resizable = false
-
- val boardView = new ChessBoardView(stage, engine)
- val guiObserver = new GUIObserver(boardView)
-
- // Subscribe GUI observer to engine
- engine.subscribe(guiObserver)
-
- stage.scene = new Scene {
- root = boardView
- // Load CSS if available
- try
- Option(getClass.getResource("/styles.css")).foreach(url => stylesheets.add(url.toExternalForm))
- catch {
- case _: Exception => // CSS is optional
- }
- }
-
- stage.onCloseRequest = _ =>
- // Unsubscribe when window closes
- engine.unsubscribe(guiObserver)
-
- stage.show()
-
-/** Launcher object that holds the engine reference and launches GUI in separate thread. */
-object ChessGUILauncher:
- private val engineRef = new java.util.concurrent.atomic.AtomicReference[GameEngine]()
-
- def getEngine: GameEngine = engineRef.get()
-
- def launch(eng: GameEngine): Unit =
- engineRef.set(eng)
- val guiThread = new Thread(() => JFXApplication.launch(classOf[ChessGUIApp]))
- guiThread.setDaemon(false)
- guiThread.setName("ScalaFX-GUI-Thread")
- guiThread.start()
diff --git a/modules/ui/src/main/scala/de/nowchess/ui/gui/GUIObserver.scala b/modules/ui/src/main/scala/de/nowchess/ui/gui/GUIObserver.scala
deleted file mode 100644
index 836263d..0000000
--- a/modules/ui/src/main/scala/de/nowchess/ui/gui/GUIObserver.scala
+++ /dev/null
@@ -1,80 +0,0 @@
-package de.nowchess.ui.gui
-
-import scalafx.application.Platform
-import scalafx.scene.control.Alert
-import scalafx.scene.control.Alert.AlertType
-import de.nowchess.chess.observer.{GameEvent, Observer, *}
-import de.nowchess.api.board.Board
-import de.nowchess.api.game.DrawReason
-
-/** GUI Observer that implements the Observer pattern. Receives game events from GameEngine and updates the ScalaFX UI.
- * All UI updates must be done on the JavaFX Application Thread.
- */
-class GUIObserver(private val boardView: ChessBoardView) extends Observer:
-
- override def onGameEvent(event: GameEvent): Unit =
- // Ensure UI updates happen on JavaFX thread
- Platform.runLater {
- event match
- case e: MoveExecutedEvent =>
- boardView.updateBoard(e.context.board, e.context.turn)
- e.capturedPiece.foreach { piece =>
- boardView.showMessage(s"Captured: $piece on ${e.toSquare}")
- }
-
- case e: CheckDetectedEvent =>
- boardView.updateBoard(e.context.board, e.context.turn)
- boardView.showMessage(s"${e.context.turn.label} is in check!")
-
- case e: CheckmateEvent =>
- boardView.updateBoard(e.context.board, e.context.turn)
- showAlert(AlertType.Information, "Game Over", s"Checkmate! ${e.winner.label} wins.")
-
- case e: DrawEvent =>
- boardView.updateBoard(e.context.board, e.context.turn)
- val msg = e.reason match
- case DrawReason.Stalemate => "Stalemate! The game is a draw."
- case DrawReason.InsufficientMaterial => "Draw by insufficient material."
- case DrawReason.FiftyMoveRule => "Draw claimed under the 50-move rule."
- case DrawReason.ThreefoldRepetition => "Draw by threefold repetition."
- case DrawReason.Agreement => "Draw by agreement."
- showAlert(AlertType.Information, "Game Over", msg)
-
- case e: InvalidMoveEvent =>
- boardView.showMessage(s"⚠️ ${e.reason}")
-
- case e: BoardResetEvent =>
- boardView.updateBoard(e.context.board, e.context.turn)
- boardView.showMessage("Board has been reset to initial position.")
-
- case e: FiftyMoveRuleAvailableEvent =>
- boardView.showMessage("50-move rule is now available — type 'draw' to claim.")
-
- case e: ThreefoldRepetitionAvailableEvent =>
- boardView.showMessage("Threefold repetition is now available — type 'draw' to claim.")
-
- case e: MoveUndoneEvent =>
- boardView.updateBoard(e.context.board, e.context.turn)
- boardView.showMessage(s"↶ Undo: ${e.pgnNotation}")
- boardView.updateUndoRedoButtons()
-
- case e: MoveRedoneEvent =>
- boardView.updateBoard(e.context.board, e.context.turn)
- if e.capturedPiece.isDefined then
- boardView.showMessage(s"↷ Redo: ${e.pgnNotation} — Captured: ${e.capturedPiece.get}")
- else boardView.showMessage(s"↷ Redo: ${e.pgnNotation}")
- boardView.updateUndoRedoButtons()
-
- case e: PgnLoadedEvent =>
- boardView.updateBoard(e.context.board, e.context.turn)
- boardView.showMessage("✓ PGN loaded successfully!")
- boardView.updateUndoRedoButtons()
- }
-
- private def showAlert(alertType: AlertType, titleText: String, content: String): Unit =
- new Alert(alertType) {
- initOwner(boardView.stage)
- title = titleText
- headerText = None
- contentText = content
- }.showAndWait()
diff --git a/modules/ui/src/main/scala/de/nowchess/ui/gui/PieceSprites.scala b/modules/ui/src/main/scala/de/nowchess/ui/gui/PieceSprites.scala
deleted file mode 100644
index f059250..0000000
--- a/modules/ui/src/main/scala/de/nowchess/ui/gui/PieceSprites.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-package de.nowchess.ui.gui
-
-import scalafx.scene.image.{Image, ImageView}
-import de.nowchess.api.board.{Color, Piece, PieceType}
-
-/** Utility object for loading chess piece sprites. */
-object PieceSprites:
-
- private val spriteCache = scala.collection.mutable.Map[String, Option[Image]]()
-
- /** Load a piece sprite image from resources. Sprites are cached for performance.
- */
- def loadPieceImage(piece: Piece, size: Double = 60.0): Option[ImageView] =
- val key = s"${piece.color.label.toLowerCase}_${piece.pieceType.label.toLowerCase}"
- spriteCache.getOrElseUpdate(key, loadImage(key)).map { image =>
- new ImageView(image) {
- fitWidth = size
- fitHeight = size
- preserveRatio = true
- smooth = true
- }
- }
-
- private def loadImage(key: String): Option[Image] =
- val path = s"/sprites/pieces/$key.png"
- Option(getClass.getResourceAsStream(path)).map(new Image(_))
-
- /** Get square colors for the board using theme. */
- object SquareColors:
- val White = "#F3C8A0" // Warm light beige
- val Black = "#BA6D4B" // Warm terracotta
- val Selected = "#C19EF5" // Purple highlight
- val ValidMove = "#E1EAA9" // Light yellow-green
- val Border = "#5A2C28" // Dark brown border
diff --git a/modules/ui/src/main/scala/de/nowchess/ui/terminal/TerminalUI.scala b/modules/ui/src/main/scala/de/nowchess/ui/terminal/TerminalUI.scala
deleted file mode 100644
index e8dc192..0000000
--- a/modules/ui/src/main/scala/de/nowchess/ui/terminal/TerminalUI.scala
+++ /dev/null
@@ -1,107 +0,0 @@
-package de.nowchess.ui.terminal
-
-import java.util.concurrent.atomic.AtomicBoolean
-import scala.io.StdIn
-import de.nowchess.api.game.DrawReason
-import de.nowchess.chess.engine.GameEngine
-import de.nowchess.chess.observer.*
-import de.nowchess.ui.utils.Renderer
-
-/** Terminal UI that implements Observer pattern. Subscribes to GameEngine and receives state change events. Handles all
- * I/O and user interaction in the terminal.
- */
-class TerminalUI(engine: GameEngine) extends Observer:
- private val running = new AtomicBoolean(true)
-
- /** Called by GameEngine whenever a game event occurs. */
- override def onGameEvent(event: GameEvent): Unit =
- event match
- case e: MoveExecutedEvent =>
- println()
- print(Renderer.render(e.context.board))
- e.capturedPiece.foreach: cap =>
- println(s"Captured: $cap on ${e.toSquare}")
- printPrompt(e.context.turn)
-
- case e: MoveUndoneEvent =>
- println(s"Undo: ${e.pgnNotation}")
- println()
- print(Renderer.render(e.context.board))
- printPrompt(e.context.turn)
-
- case e: MoveRedoneEvent =>
- println(s"Redo: ${e.pgnNotation}")
- println()
- print(Renderer.render(e.context.board))
- printPrompt(e.context.turn)
-
- case e: CheckDetectedEvent =>
- println(s"${e.context.turn.label} is in check!")
-
- case e: CheckmateEvent =>
- println(s"Checkmate! ${e.winner.label} wins.")
- println()
- print(Renderer.render(e.context.board))
-
- case e: DrawEvent =>
- val msg = e.reason match
- case DrawReason.Stalemate => "Stalemate! The game is a draw."
- case DrawReason.InsufficientMaterial => "Draw by insufficient material."
- case DrawReason.FiftyMoveRule => "Draw claimed under the 50-move rule."
- case DrawReason.ThreefoldRepetition => "Draw by threefold repetition."
- case DrawReason.Agreement => "Draw by agreement."
- println(msg)
- println()
- print(Renderer.render(e.context.board))
-
- case e: InvalidMoveEvent =>
- println(s"⚠️ ${e.reason}")
-
- case e: BoardResetEvent =>
- println("Board has been reset to initial position.")
- println()
- print(Renderer.render(e.context.board))
- printPrompt(e.context.turn)
-
- case _: FiftyMoveRuleAvailableEvent =>
- println("50-move rule is now available — type 'draw' to claim.")
-
- case _: ThreefoldRepetitionAvailableEvent =>
- println("Threefold repetition is now available — type 'draw' to claim.")
-
- case e: PgnLoadedEvent =>
- println("PGN loaded successfully.")
- println()
- print(Renderer.render(e.context.board))
- printPrompt(e.context.turn)
-
- /** Start the terminal UI game loop. */
- def start(): Unit =
- // Register as observer
- engine.subscribe(this)
-
- // Show initial board
- println()
- print(Renderer.render(engine.board))
- printPrompt(engine.turn)
-
- while running.get() do
- val input = Option(StdIn.readLine()).getOrElse("quit").trim
- synchronized {
- input.toLowerCase match
- case "quit" | "q" =>
- running.set(false)
- println("Game over. Goodbye!")
- case "" =>
- printPrompt(engine.turn)
- case _ =>
- engine.processUserInput(input)
- }
-
- // Unsubscribe when done
- engine.unsubscribe(this)
-
- private def printPrompt(turn: de.nowchess.api.board.Color): Unit =
- val undoHint = if engine.canUndo then " [undo]" else ""
- val redoHint = if engine.canRedo then " [redo]" else ""
- print(s"${turn.label}'s turn. Enter move (or 'quit'/'q' to exit)$undoHint$redoHint: ")
diff --git a/modules/ui/src/main/scala/de/nowchess/ui/utils/PieceUnicode.scala b/modules/ui/src/main/scala/de/nowchess/ui/utils/PieceUnicode.scala
deleted file mode 100644
index 96c9548..0000000
--- a/modules/ui/src/main/scala/de/nowchess/ui/utils/PieceUnicode.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-package de.nowchess.ui.utils
-
-import de.nowchess.api.board.{Color, Piece, PieceType}
-
-extension (p: Piece)
- def unicode: String = (p.color, p.pieceType) match
- case (Color.White, PieceType.King) => "\u2654"
- case (Color.White, PieceType.Queen) => "\u2655"
- case (Color.White, PieceType.Rook) => "\u2656"
- case (Color.White, PieceType.Bishop) => "\u2657"
- case (Color.White, PieceType.Knight) => "\u2658"
- case (Color.White, PieceType.Pawn) => "\u2659"
- case (Color.Black, PieceType.King) => "\u265A"
- case (Color.Black, PieceType.Queen) => "\u265B"
- case (Color.Black, PieceType.Rook) => "\u265C"
- case (Color.Black, PieceType.Bishop) => "\u265D"
- case (Color.Black, PieceType.Knight) => "\u265E"
- case (Color.Black, PieceType.Pawn) => "\u265F"
diff --git a/modules/ui/src/main/scala/de/nowchess/ui/utils/Renderer.scala b/modules/ui/src/main/scala/de/nowchess/ui/utils/Renderer.scala
deleted file mode 100644
index 27cc533..0000000
--- a/modules/ui/src/main/scala/de/nowchess/ui/utils/Renderer.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-package de.nowchess.ui.utils
-
-import de.nowchess.api.board.*
-
-object Renderer:
-
- private val AnsiReset = "\u001b[0m"
- private val AnsiLightSquare = "\u001b[48;5;223m" // warm beige
- private val AnsiDarkSquare = "\u001b[48;5;130m" // brown
- private val AnsiWhitePiece = "\u001b[97m" // bright white text
- private val AnsiBlackPiece = "\u001b[30m" // black text
-
- def render(board: Board): String =
- val rows = (0 until 8).reverse
- .map { rank =>
- val cells = (0 until 8).map { file =>
- val sq = Square(File.values(file), Rank.values(rank))
- val isLightSq = (file + rank) % 2 != 0
- val bgColor = if isLightSq then AnsiLightSquare else AnsiDarkSquare
- board.pieceAt(sq) match
- case Some(piece) =>
- val fgColor = if piece.color == Color.White then AnsiWhitePiece else AnsiBlackPiece
- s"$bgColor$fgColor ${piece.unicode} $AnsiReset"
- case None =>
- s"$bgColor $AnsiReset"
- }.mkString
- s"${rank + 1} $cells ${rank + 1}"
- }
- .mkString("\n")
- s" a b c d e f g h\n$rows\n a b c d e f g h\n"
diff --git a/modules/ui/src/test/scala/de/nowchess/ui/utils/RendererAndUnicodeTest.scala b/modules/ui/src/test/scala/de/nowchess/ui/utils/RendererAndUnicodeTest.scala
deleted file mode 100644
index 4a82afe..0000000
--- a/modules/ui/src/test/scala/de/nowchess/ui/utils/RendererAndUnicodeTest.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-package de.nowchess.ui.utils
-
-import de.nowchess.api.board.{Board, Color, File, Piece, PieceType, Rank, Square}
-import org.scalatest.funsuite.AnyFunSuite
-import org.scalatest.matchers.should.Matchers
-
-class RendererAndUnicodeTest extends AnyFunSuite with Matchers:
-
- test("unicode returns correct unicode character for all piece types"):
- val pieces = Seq(
- (Piece(Color.White, PieceType.King), "\u2654"),
- (Piece(Color.White, PieceType.Queen), "\u2655"),
- (Piece(Color.White, PieceType.Rook), "\u2656"),
- (Piece(Color.White, PieceType.Bishop), "\u2657"),
- (Piece(Color.White, PieceType.Knight), "\u2658"),
- (Piece(Color.White, PieceType.Pawn), "\u2659"),
- (Piece(Color.Black, PieceType.King), "\u265A"),
- (Piece(Color.Black, PieceType.Queen), "\u265B"),
- (Piece(Color.Black, PieceType.Rook), "\u265C"),
- (Piece(Color.Black, PieceType.Bishop), "\u265D"),
- (Piece(Color.Black, PieceType.Knight), "\u265E"),
- (Piece(Color.Black, PieceType.Pawn), "\u265F"),
- )
- pieces.foreach { (piece, expected) =>
- piece.unicode shouldBe expected
- }
-
- test("render outputs coordinates ranks ansi escapes and piece glyphs"):
- val board = Board(Map(Square(File.E, Rank.R4) -> Piece(Color.White, PieceType.Queen)))
- val rendered = Renderer.render(Board(Map.empty))
- val lines = rendered.trim.split("\\n").toList.map(_.trim)
-
- lines.head shouldBe "a b c d e f g h"
- lines.last shouldBe "a b c d e f g h"
- rendered should include("8")
- rendered should include("1")
- Renderer.render(board) should include("\u2655")
- Renderer.render(board) should include("\u001b[")
-
- test("render applies black piece color for black pieces"):
- val board = Board(Map(Square(File.A, Rank.R1) -> Piece(Color.Black, PieceType.King)))
- val rendered = Renderer.render(board)
- rendered should include("\u265A") // Black king unicode
- rendered should include("\u001b[30m") // ANSI black text color
diff --git a/modules/ui/versions.env b/modules/ui/versions.env
deleted file mode 100644
index 93254ff..0000000
--- a/modules/ui/versions.env
+++ /dev/null
@@ -1,3 +0,0 @@
-MAJOR=0
-MINOR=12
-PATCH=0
diff --git a/settings.gradle.kts b/settings.gradle.kts
index e5cab2b..9b36b4b 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -18,6 +18,5 @@ include(
"modules:api",
"modules:io",
"modules:rule",
- "modules:ui",
"modules:bot",
)
\ No newline at end of file