mirror of
https://github.com/sigmasternchen/php-chess
synced 2025-03-14 23:58:53 +00:00
refactor: Move square color logic to position class
This commit is contained in:
parent
51d01b0953
commit
64b29a881b
1 changed files with 3 additions and 3 deletions
|
@ -401,10 +401,10 @@ class Game {
|
|||
$result .= ($rank + 1) . " ";
|
||||
|
||||
for ($file = 0; $file < 8; $file++) {
|
||||
$color = ($rank % 2) ^ ($file % 2);
|
||||
$result .= "\033[" . ($color ? 47 : 100) . "m";
|
||||
$position = new Position($file, $rank);
|
||||
$result .= "\033[" . ($position->getSquareColor() == Side::WHITE ? 47 : 100) . "m";
|
||||
|
||||
$piece = current(array_filter($this->pieces, fn($p) => $p->getPosition()->equals(new Position($file, $rank))));
|
||||
$piece = current(array_filter($this->pieces, fn($p) => $p->getPosition()->equals($position)));
|
||||
if ($piece) {
|
||||
if ($piece->getSide() == Side::WHITE) {
|
||||
$result .= "\033[97m";
|
||||
|
|
Loading…
Reference in a new issue