mirror of
https://github.com/sigmasternchen/php-chess
synced 2025-03-15 07:58:54 +00:00
fix: Apply move doesn't create correct kings reference
This commit is contained in:
parent
1d1877f79e
commit
2f3d5a3340
1 changed files with 4 additions and 5 deletions
|
@ -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 = " ";
|
||||
|
||||
|
|
Loading…
Reference in a new issue