refactor(core): enhance GameEngine and GUI for undo/redo functionality and integrate FEN/PGN export/import
Build & Test (NowChessSystems) TeamCity build failed

This commit is contained in:
2026-04-04 21:02:39 +02:00
parent 9b3bbfbcb7
commit fa5cdf4e9c
5 changed files with 135 additions and 26 deletions
@@ -15,8 +15,8 @@ import de.nowchess.rules.sets.DefaultRules
* All user interactions go through Commands; state changes are broadcast via GameEvents.
*/
class GameEngine(
initialContext: GameContext = GameContext.initial,
ruleSet: RuleSet = DefaultRules
val initialContext: GameContext = GameContext.initial,
val ruleSet: RuleSet = DefaultRules
) extends Observable:
private var currentContext: GameContext = initialContext
private val invoker = new CommandInvoker()
@@ -59,7 +59,6 @@ class GameEngine(
case "draw" =>
if currentContext.halfMoveClock >= 100 then
currentContext = GameContext.initial
invoker.clear()
notifyObservers(DrawClaimedEvent(currentContext))
else
@@ -202,10 +201,8 @@ class GameEngine(
if ruleSet.isCheckmate(currentContext) then
val winner = currentContext.turn.opposite
currentContext = GameContext.initial
notifyObservers(CheckmateEvent(currentContext, winner))
else if ruleSet.isStalemate(currentContext) then
currentContext = GameContext.initial
notifyObservers(StalemateEvent(currentContext))
else if ruleSet.isCheck(currentContext) then
notifyObservers(CheckDetectedEvent(currentContext))