refactor(core): NCS-22 update GameEngine to use GameContext and integrate Rule module
Build & Test (NowChessSystems) TeamCity build failed
Build & Test (NowChessSystems) TeamCity build failed
This commit is contained in:
@@ -150,16 +150,20 @@ class GameEngine(
|
||||
game.moves.foreach { histMove =>
|
||||
handleParsedMove(histMove.from, histMove.to)
|
||||
histMove.promotionPiece.foreach(completePromotion)
|
||||
if pendingPromotion.isDefined && histMove.promotionPiece.isEmpty then
|
||||
// $COVERAGE-OFF$ unreachable: PgnParser.validatePgn ensures promotion annotation is present
|
||||
if pendingPromotion.isDefined && histMove.promotionPiece.isEmpty then
|
||||
error = Some(s"Promotion required for move ${histMove.from}${histMove.to}")
|
||||
break()
|
||||
// $COVERAGE-ON$
|
||||
}
|
||||
}
|
||||
|
||||
error match
|
||||
// $COVERAGE-OFF$ unreachable: error is only set in the unreachable block above
|
||||
case Some(err) =>
|
||||
currentContext = savedContext
|
||||
Left(err)
|
||||
// $COVERAGE-ON$
|
||||
case None =>
|
||||
notifyObservers(PgnLoadedEvent(currentContext))
|
||||
Right(())
|
||||
@@ -245,7 +249,9 @@ class GameEngine(
|
||||
case PieceType.King => "K"
|
||||
case _ => ""
|
||||
if isCapture then s"${letter}x${move.to}" else s"$letter${move.to}"
|
||||
// $COVERAGE-OFF$ unreachable: executeMove is only called after a piece existence check
|
||||
case None => move.to.toString
|
||||
// $COVERAGE-ON$
|
||||
|
||||
private def computeCaptured(context: GameContext, move: Move): Option[Piece] =
|
||||
move.moveType match
|
||||
|
||||
@@ -2,9 +2,10 @@ package de.nowchess.chess.engine
|
||||
|
||||
import de.nowchess.api.board.{Board, Color, File, Piece, PieceType, Rank, Square}
|
||||
import de.nowchess.api.game.GameContext
|
||||
import de.nowchess.api.move.{MoveType, PromotionPiece}
|
||||
import de.nowchess.api.move.{Move, MoveType, PromotionPiece}
|
||||
import de.nowchess.chess.notation.FenParser
|
||||
import de.nowchess.chess.observer.*
|
||||
import de.nowchess.rules.{RuleSet, StandardRules}
|
||||
import org.scalatest.funsuite.AnyFunSuite
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user