Skip to content

Commit

Permalink
Fixed the tab length
Browse files Browse the repository at this point in the history
  • Loading branch information
programarivm committed May 6, 2024
1 parent 954ef96 commit c14269b
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions src/Variant/Classical/Board.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,59 +719,59 @@ public function play(string $color, string $pgn): bool
*/
public function playLan(string $color, string $lan): bool
{
$sqs = $this->move->explodeSqs($lan);
if (isset($sqs[0]) && isset($sqs[1])) {
if ($color === $this->getTurn() && $piece = $this->getPieceBySq($sqs[0])) {
if ($piece->getId() === Piece::K) {
if (
$this->castlingRule[$color][Piece::K][Castle::SHORT]['sq']['next'] === $sqs[1] &&
$piece->sqCastleShort() &&
$this->play($color, Castle::SHORT)
) {
return $this->addSymbol();
} elseif (
$this->castlingRule[$color][Piece::K][Castle::LONG]['sq']['next'] === $sqs[1] &&
$piece->sqCastleLong() &&
$this->play($color, Castle::LONG)
) {
return $this->addSymbol();
} elseif ($this->play($color, Piece::K.'x'.$sqs[1])) {
return $this->addSymbol();
} elseif ($this->play($color, Piece::K.$sqs[1])) {
return $this->addSymbol();
}
} elseif ($piece->getId() === Piece::P) {
strlen($lan) === 5
? $promotion = '='.mb_strtoupper(substr($lan, -1))
: $promotion = '';
if ($this->play($color, $piece->getSqFile()."x$sqs[1]".$promotion)) {
return $this->addSymbol();
} elseif ($this->play($color, $sqs[1].$promotion)) {
return $this->addSymbol();
}
} else {
if ($this->play($color, "{$piece->getId()}x$sqs[1]")) {
return $this->addSymbol();
} elseif ($this->play($color, "{$piece->getId()}{$piece->getSqFile()}x$sqs[1]")) {
return $this->addSymbol();
} elseif ($this->play($color, "{$piece->getId()}{$piece->getSqRank()}x$sqs[1]")) {
return $this->addSymbol();
} elseif ($this->play($color, $piece->getId().$sqs[1])) {
return $this->addSymbol();
} elseif ($this->play($color, $piece->getId().$piece->getSqFile().$sqs[1])) {
return $this->addSymbol();
} elseif ($this->play($color, $piece->getId().$piece->getSqRank().$sqs[1])) {
return $this->addSymbol();
} elseif ($this->play($color, "{$piece->getId()}{$piece->getSq()}x$sqs[1]")) {
return $this->addSymbol();
} elseif ($this->play($color, $piece->getId().$piece->getSq().$sqs[1])) {
return $this->addSymbol();
}
}
}
}

return false;
$sqs = $this->move->explodeSqs($lan);
if (isset($sqs[0]) && isset($sqs[1])) {
if ($color === $this->getTurn() && $piece = $this->getPieceBySq($sqs[0])) {
if ($piece->getId() === Piece::K) {
if (
$this->castlingRule[$color][Piece::K][Castle::SHORT]['sq']['next'] === $sqs[1] &&
$piece->sqCastleShort() &&
$this->play($color, Castle::SHORT)
) {
return $this->addSymbol();
} elseif (
$this->castlingRule[$color][Piece::K][Castle::LONG]['sq']['next'] === $sqs[1] &&
$piece->sqCastleLong() &&
$this->play($color, Castle::LONG)
) {
return $this->addSymbol();
} elseif ($this->play($color, Piece::K.'x'.$sqs[1])) {
return $this->addSymbol();
} elseif ($this->play($color, Piece::K.$sqs[1])) {
return $this->addSymbol();
}
} elseif ($piece->getId() === Piece::P) {
strlen($lan) === 5
? $promotion = '='.mb_strtoupper(substr($lan, -1))
: $promotion = '';
if ($this->play($color, $piece->getSqFile()."x$sqs[1]".$promotion)) {
return $this->addSymbol();
} elseif ($this->play($color, $sqs[1].$promotion)) {
return $this->addSymbol();
}
} else {
if ($this->play($color, "{$piece->getId()}x$sqs[1]")) {
return $this->addSymbol();
} elseif ($this->play($color, "{$piece->getId()}{$piece->getSqFile()}x$sqs[1]")) {
return $this->addSymbol();
} elseif ($this->play($color, "{$piece->getId()}{$piece->getSqRank()}x$sqs[1]")) {
return $this->addSymbol();
} elseif ($this->play($color, $piece->getId().$sqs[1])) {
return $this->addSymbol();
} elseif ($this->play($color, $piece->getId().$piece->getSqFile().$sqs[1])) {
return $this->addSymbol();
} elseif ($this->play($color, $piece->getId().$piece->getSqRank().$sqs[1])) {
return $this->addSymbol();
} elseif ($this->play($color, "{$piece->getId()}{$piece->getSq()}x$sqs[1]")) {
return $this->addSymbol();
} elseif ($this->play($color, $piece->getId().$piece->getSq().$sqs[1])) {
return $this->addSymbol();
}
}
}
}

return false;
}

/**
Expand Down

0 comments on commit c14269b

Please sign in to comment.