Fixes Chess's need for clone functions that are not available on iOS

This commit is contained in:
Vitor Pamplona
2026-02-18 10:46:06 -05:00
parent 2c3ca7f906
commit ab6560d47d
@@ -68,7 +68,7 @@ data class ChessPosition(
val (fromFile, fromRank) = parseSquare(from) val (fromFile, fromRank) = parseSquare(from)
val (toFile, toRank) = parseSquare(to) val (toFile, toRank) = parseSquare(to)
val newBoard = board.map { it.clone() }.toTypedArray() val newBoard = board.map { it.copyOf() }.toTypedArray()
val piece = newBoard[fromRank][fromFile] ?: throw IllegalArgumentException("No piece at $from") val piece = newBoard[fromRank][fromFile] ?: throw IllegalArgumentException("No piece at $from")
// Handle promotion // Handle promotion
@@ -94,7 +94,7 @@ data class ChessPosition(
*/ */
fun makeCastlingMove(kingSide: Boolean): ChessPosition { fun makeCastlingMove(kingSide: Boolean): ChessPosition {
val rank = if (activeColor == Color.WHITE) 0 else 7 val rank = if (activeColor == Color.WHITE) 0 else 7
val newBoard = board.map { it.clone() }.toTypedArray() val newBoard = board.map { it.copyOf() }.toTypedArray()
if (kingSide) { if (kingSide) {
// King-side castling (O-O) // King-side castling (O-O)