refactor(core): enhance GameEngine and GUI for undo/redo functionality and integrate FEN/PGN export/import
Build & Test (NowChessSystems) TeamCity build failed
Build & Test (NowChessSystems) TeamCity build failed
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user