Code cleanup
This commit is contained in:
@@ -48,13 +48,11 @@ class FenParser0x88
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return long notation for a move
|
* @param array $move
|
||||||
* @method getLongNotationForAMove
|
* @param bool $shortNotation
|
||||||
* @param {Object} move
|
* @return string
|
||||||
* @param {String} shortNotation
|
*/
|
||||||
* @return {String} long notation
|
public function getLongNotationForAMove($move, $shortNotation) {
|
||||||
*/
|
|
||||||
public function getLongNotationForAMove($move, $shortNotation) {
|
|
||||||
if (strstr($shortNotation, 'O-')) {
|
if (strstr($shortNotation, 'O-')) {
|
||||||
return $shortNotation;
|
return $shortNotation;
|
||||||
}
|
}
|
||||||
@@ -127,7 +125,6 @@ class FenParser0x88
|
|||||||
$pos += intval($token);
|
$pos += intval($token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPieceOnSquare($square) {
|
public function getPieceOnSquare($square) {
|
||||||
@@ -176,11 +173,7 @@ class FenParser0x88
|
|||||||
|
|
||||||
function getEnPassantSquare()
|
function getEnPassantSquare()
|
||||||
{
|
{
|
||||||
$enPassant = $this->fenParts['enPassant'];
|
return ($this->fenParts['enPassant'] != '-') ? $this->fenParts['enPassant'] : null;
|
||||||
if ($enPassant != '-') {
|
|
||||||
return $enPassant;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setEnPassantSquare($square)
|
private function setEnPassantSquare($square)
|
||||||
@@ -570,11 +563,9 @@ class FenParser0x88
|
|||||||
$pinning = '';
|
$pinning = '';
|
||||||
while ($square !== $king['s'] && $countOpposite < 2) {
|
while ($square !== $king['s'] && $countOpposite < 2) {
|
||||||
$squares[] = $square;
|
$squares[] = $square;
|
||||||
|
|
||||||
if ($this->cache['board'][$square]) {
|
if ($this->cache['board'][$square]) {
|
||||||
$countOpposite++;
|
$countOpposite++;
|
||||||
if ((!$WHITE && $this->cache['board'][$square] & 0x8) || ($WHITE && !($this->cache['board'][$square] & 0x8))) {
|
if ((!$WHITE && $this->cache['board'][$square] & 0x8) || ($WHITE && !($this->cache['board'][$square] & 0x8))) {
|
||||||
|
|
||||||
$pinning = $square;
|
$pinning = $square;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@@ -1294,9 +1285,7 @@ class FenParser0x88
|
|||||||
if ($this->isEnPassantMove($move) || $this->cache['board'][$move['to']]) {
|
if ($this->isEnPassantMove($move) || $this->cache['board'][$move['to']]) {
|
||||||
$ret += Board0x88Config::$fileMapping[$move['from'] & 15] + 'x';
|
$ret += Board0x88Config::$fileMapping[$move['from'] & 15] + 'x';
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret += Board0x88Config::$fileMapping[$move['to'] & 15] + '' + Board0x88Config::$rankMapping[$move['to'] & 240];
|
$ret += Board0x88Config::$fileMapping[$move['to'] & 15] + '' + Board0x88Config::$rankMapping[$move['to'] & 240];
|
||||||
|
|
||||||
if (isset($move['promoteTo']) && $move['promoteTo']) {
|
if (isset($move['promoteTo']) && $move['promoteTo']) {
|
||||||
$numType = Board0x88Config::$typeToNumberMapping[$move['promoteTo']];
|
$numType = Board0x88Config::$typeToNumberMapping[$move['promoteTo']];
|
||||||
$ret .= '=' . Board0x88Config::$notationMapping[$numType];
|
$ret .= '=' . Board0x88Config::$notationMapping[$numType];
|
||||||
|
@@ -64,7 +64,6 @@ class PgnGameParser{
|
|||||||
if($i==0){
|
if($i==0){
|
||||||
$this->moveBuilder->addCommentBeforeFirstMove($parts[$i+1]);
|
$this->moveBuilder->addCommentBeforeFirstMove($parts[$i+1]);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$this->moveBuilder->addComment($parts[$i+1]);
|
$this->moveBuilder->addComment($parts[$i+1]);
|
||||||
}
|
}
|
||||||
$i+=2;
|
$i+=2;
|
||||||
|
@@ -25,7 +25,7 @@ class ParserTest extends PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
public function shouldCreatParser()
|
public function shouldCreateParser()
|
||||||
{
|
{
|
||||||
// given
|
// given
|
||||||
$parser = $this->getParser();
|
$parser = $this->getParser();
|
||||||
@@ -1796,6 +1796,11 @@ class ParserTest extends PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param null $fen
|
||||||
|
* @return FenParser0x88
|
||||||
|
*/
|
||||||
private function getParser($fen = null)
|
private function getParser($fen = null)
|
||||||
{
|
{
|
||||||
if (!isset($fen)) {
|
if (!isset($fen)) {
|
||||||
|
Reference in New Issue
Block a user