Files
NowChessSystems/.claude/memory/project_structure_core.md
T
Janis 2df2fdeeb9
Build & Test (NowChessSystems) TeamCity build finished
feat: add memory structure documentation and update index (#5)
Reviewed-on: #5
2026-03-28 13:35:49 +01:00

2.9 KiB

name, description, type
name description type
module-core-structure File and type overview for the modules/core module (TUI chess engine) project

Module: modules/core

Purpose: Standalone TUI chess application. All game logic, move validation, rendering. Depends on modules/api.

Gradle: id("scala") + application plugin. Main class: de.nowchess.chess.Main. Uses scoverage plugin.

Package root: de.nowchess.chess

Source files (src/main/scala/de/nowchess/chess/)

Root

File Contents
Main.scala Entry point — prints welcome, starts GameController.gameLoop(GameContext.initial, Color.White)

controller/

File Contents
GameController.scala sealed trait MoveResult ADT: Quit, InvalidFormat, NoPiece, WrongColor, IllegalMove, Moved, MovedInCheck, Checkmate, Stalemate; object GameControllerprocessMove(ctx, turn, raw): MoveResult (pure), gameLoop(ctx, turn) (I/O loop), applyRightsRevocation(...) (castling rights bookkeeping)
Parser.scala object ParserparseMove(input): Option[(Square, Square)] parses coordinate notation e.g. "e2e4"

logic/

File Contents
GameContext.scala enum CastleSide { Kingside, Queenside }; case class GameContext(board, whiteCastling, blackCastling).castlingFor(color), .withUpdatedRights(color, rights); GameContext.initial; extension (Board).withCastle(color, side) moves king+rook atomically
GameRules.scala enum PositionStatus { Normal, InCheck, Mated, Drawn }; object GameRulesisInCheck(board, color), legalMoves(ctx, color): Set[(Square,Square)], gameStatus(ctx, color): PositionStatus
MoveValidator.scala object MoveValidatorisLegal(board, from, to), legalTargets(board, from): Set[Square] (board-only, no castling), legalTargets(ctx, from) (context-aware, includes castling), isCastle, castleSide, castlingTargets(ctx, color) — full castling legality (empty squares, no check through transit)

view/

File Contents
Renderer.scala object Rendererrender(board): String outputs ANSI-colored board with file/rank labels
PieceUnicode.scala extension (Piece).unicode: String maps each piece to its Unicode chess symbol

Test files (src/test/scala/de/nowchess/chess/)

Mirror of main structure — one *Test.scala per source file using AnyFunSuite with Matchers.

Key design notes

  • MoveValidator has two overloaded legalTargets: one takes Board (geometry only), one takes GameContext (adds castling)
  • GameRules.legalMoves filters by check — it calls MoveValidator.legalTargets(ctx, from) then simulates each move
  • Castling rights revocation is in GameController.applyRightsRevocation, triggered after every move
  • No @QuarkusTest — this module is a plain Scala application, not a Quarkus service