fix: Apply move doesn't create correct kings reference

This commit is contained in:
overflowerror 2024-01-05 15:15:58 +01:00
parent 1d1877f79e
commit 2f3d5a3340

View file

@ -203,7 +203,10 @@ class Game {
}
public function apply(Move $move): Game {
$game = clone $this;
$game = new Game(
array_map(fn($p) => clone $p, $this->pieces),
$this->current,
);
if ($move->captures) {
$game->removePiece($move->captures);
@ -240,10 +243,6 @@ class Game {
return GameState::DEFAULT;
}
public function __clone(): void {
$this->pieces = array_map(fn($p) => clone $p, $this->pieces);
}
public function visualize(): string {
$result = " ";