refactor: NCS-22 NCS-23 reworked modules and tests #17
@@ -22,7 +22,15 @@ object PgnExporter extends GameContextExport:
|
||||
var ctx = GameContext.initial
|
||||
for move <- context.moves do
|
||||
val color = ctx.turn
|
||||
val pieceType = ctx.board.pieceAt(move.from).map(_.pieceType).getOrElse(PieceType.Pawn)
|
||||
val pieceType = ctx.board.pieceAt(move.from)
|
||||
.map(_.pieceType)
|
||||
.getOrElse {
|
||||
val fromStr = move.from.toString
|
||||
val boardStr = ctx.board.pieces.keys.map(_.toString).mkString(",")
|
||||
throw new IllegalStateException(
|
||||
s"Invariant violation: no piece at $fromStr during PGN export replay. Board squares: $boardStr"
|
||||
)
|
||||
}
|
||||
val isCapture = ctx.board.pieceAt(move.to).isDefined || move.moveType == MoveType.EnPassant
|
||||
val castleSide = move.moveType match
|
||||
case MoveType.CastleKingside => Some("Kingside")
|
||||
|
||||
Reference in New Issue
Block a user