mirror of
https://github.com/sigmasternchen/php-chess
synced 2025-03-15 07:58:54 +00:00
feat: Add castles notation
This commit is contained in:
parent
90077fdb37
commit
26c44a0ff4
1 changed files with 15 additions and 3 deletions
|
@ -37,9 +37,21 @@ class Move {
|
|||
);
|
||||
}
|
||||
|
||||
public function __toString(): string {
|
||||
public function getLong(): string {
|
||||
if ($this->castleWith) {
|
||||
if (abs($this->piece->getPosition()->file - $this->castleWith->getPosition()->file) > 3) {
|
||||
return "O-O-O";
|
||||
} else {
|
||||
return "O-O";
|
||||
}
|
||||
} else {
|
||||
return $this->piece . " " .
|
||||
$this->piece->getType()->getShort() . ($this->captures ? "x" : "") . $this->target .
|
||||
($this->promoteTo ? $this->promoteTo->getShort() : "");
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString(): string {
|
||||
return $this->getLong();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue