feat: NCS-16 Core Separation via Patterns #10

Merged
Janis merged 20 commits from feat/GUI-UI-Core-Separation into main 2026-03-31 10:31:03 +02:00
Owner
No description provided.
Janis requested changes 2026-03-30 20:57:00 +02:00
Dismissed
.gitignore Outdated
@@ -44,2 +44,4 @@
/jacoco-reporter/.venv/
/.claude/settings.local.json
.metals/
.metals/
Member

What is that

What is that
shosho996 marked this conversation as resolved
CODE_NOTICE.md Outdated
@@ -0,0 +1,41 @@
# 🔒 CODE FREEZE NOTICE
Member

Not required as file, just increases tokens

Not required as file, just increases tokens
shosho996 marked this conversation as resolved
@@ -0,0 +218,4 @@
"Illegal move."
))
end GameEngine
Member

Not required

Not required
Janis marked this conversation as resolved
@@ -0,0 +214,4 @@
invoker.execute(cmd3) // While loop condition should be false, no iterations
invoker.history.size shouldBe 3
end CommandInvokerBranchTest
Member

Not required

Not required
Janis marked this conversation as resolved
@@ -0,0 +121,4 @@
invoker.history(1) shouldBe cmd3
invoker.getCurrentIndex shouldBe 1
end CommandInvokerTest
Member

Not required

Not required
Janis marked this conversation as resolved
@@ -0,0 +50,4 @@
val cmd = ResetCommand()
cmd.description shouldBe "Reset board"
end CommandTest
Member

Not required

Not required
Janis marked this conversation as resolved
@@ -0,0 +275,4 @@
override def onGameEvent(event: GameEvent): Unit =
events += event
end GameEngineTest
Member

Not required

Not required
Janis marked this conversation as resolved
@@ -0,0 +13,4 @@
val tui = new TerminalUI(engine)
tui.start()
end Main
Member

Not required

Not required
Janis marked this conversation as resolved
@@ -0,0 +74,4 @@
val redoHint = if engine.canRedo then " [redo]" else ""
print(s"${turn.label}'s turn. Enter move (or 'quit'/'q' to exit)$undoHint$redoHint: ")
end TerminalUI
Member

Not required

Not required
Janis marked this conversation as resolved
test_dummy.scala Outdated
@@ -0,0 +1 @@
@main def test() = println("hi")
Member

Nope

Nope
Janis marked this conversation as resolved
Janis added 20 commits 2026-03-31 10:10:10 +02:00
Implements FenParser.parseBoard() to parse FEN piece-placement strings
into a Board, with proper None propagation on invalid input.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements FenExporter.boardToFen() converting Board to FEN piece-placement string,
and adds three round-trip tests (initial position, empty board, partial position).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements parseFen() in FenParser and gameStateToFen() in FenExporter,
covering all 6 FEN fields (piece placement, active color, castling,
en passant, half-move clock, full-move number).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements PgnParser with parsePgn(), parseAlgebraicMove(), and move
resolution using geometric piece reachability with disambiguation support
for piece type, file, and rank hints.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Test-driven fixes for code review blockers NCS-16:

**Observable (CRITICAL):** Added synchronized blocks to subscribe, unsubscribe,
notifyObservers, and observerCount to prevent race conditions when concurrent
threads register observers while notifications are dispatched.

**CommandInvoker (IMPORTANT):** Added synchronized blocks to all methods
(execute, undo, redo, history, getCurrentIndex, canUndo, canRedo, clear) to
ensure atomic access to mutable state (executedCommands, currentIndex).

Tests:
- Added ObservableThreadSafetyTest: 3 tests for concurrent subscribe/unsubscribe/notify
- Added CommandInvokerThreadSafetyTest: 2 tests for concurrent execute/undo/redo
- All 54 existing tests remain green
- Full build passes with 100% core coverage

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
**TerminalUI Coverage Fix:**
- Added explicit test for empty input case (lines 64-65 previously uncovered)
- Test "TerminalUI should explicitly handle empty input by re-prompting" validates
  that multiple empty inputs are properly handled by re-prompting
- UI module coverage improved to near-100%

**MoveCommand Immutability (Anti-pattern Fix):**
- Changed MoveCommand fields from var to val: moveResult, previousBoard,
  previousHistory, previousTurn
- Changed ResetCommand fields from var to val: previousBoard, previousHistory,
  previousTurn
- Updated GameEngine to use .copy() instead of direct mutation when updating
  command state (lines 88, 95, 103, 112)
- Removed 3 edge-case tests that relied on command mutation (now impossible with
  immutable fields)

**MoveCommand Immutability Tests:**
- Added MoveCommandImmutabilityTest to verify:
  - Fields cannot be mutated after creation
  - equals/hashCode respect immutability invariant
  - .copy() creates new instances with updated values

All tests pass; 100% core coverage maintained.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
test: add tests for undo and redo notifications in GameEngine
Build & Test (NowChessSystems) TeamCity build finished
9f0e2b0a14
Janis force-pushed feat/GUI-UI-Core-Separation from c75a3a28af to 9f0e2b0a14 2026-03-31 10:10:10 +02:00 Compare
Janis approved these changes 2026-03-31 10:30:32 +02:00
Janis merged commit 1361dfc895 into main 2026-03-31 10:31:03 +02:00
Janis deleted branch feat/GUI-UI-Core-Separation 2026-03-31 10:31:03 +02:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NowChess/NowChessSystems#10