Code cleanup

This commit is contained in:
DHTMLGoodies
2013-01-18 14:38:50 +01:00
parent be3a529058
commit 8708b00cf7
3 changed files with 12 additions and 19 deletions

View File

@@ -48,13 +48,11 @@ class FenParser0x88
}
/**
* Return long notation for a move
* @method getLongNotationForAMove
* @param {Object} move
* @param {String} shortNotation
* @return {String} long notation
*/
public function getLongNotationForAMove($move, $shortNotation) {
* @param array $move
* @param bool $shortNotation
* @return string
*/
public function getLongNotationForAMove($move, $shortNotation) {
if (strstr($shortNotation, 'O-')) {
return $shortNotation;
}
@@ -127,7 +125,6 @@ class FenParser0x88
$pos += intval($token);
}
}
}
public function getPieceOnSquare($square) {
@@ -176,11 +173,7 @@ class FenParser0x88
function getEnPassantSquare()
{
$enPassant = $this->fenParts['enPassant'];
if ($enPassant != '-') {
return $enPassant;
}
return null;
return ($this->fenParts['enPassant'] != '-') ? $this->fenParts['enPassant'] : null;
}
private function setEnPassantSquare($square)
@@ -570,11 +563,9 @@ class FenParser0x88
$pinning = '';
while ($square !== $king['s'] && $countOpposite < 2) {
$squares[] = $square;
if ($this->cache['board'][$square]) {
$countOpposite++;
if ((!$WHITE && $this->cache['board'][$square] & 0x8) || ($WHITE && !($this->cache['board'][$square] & 0x8))) {
$pinning = $square;
} else {
break;
@@ -1294,9 +1285,7 @@ class FenParser0x88
if ($this->isEnPassantMove($move) || $this->cache['board'][$move['to']]) {
$ret += Board0x88Config::$fileMapping[$move['from'] & 15] + 'x';
}
$ret += Board0x88Config::$fileMapping[$move['to'] & 15] + '' + Board0x88Config::$rankMapping[$move['to'] & 240];
if (isset($move['promoteTo']) && $move['promoteTo']) {
$numType = Board0x88Config::$typeToNumberMapping[$move['promoteTo']];
$ret .= '=' . Board0x88Config::$notationMapping[$numType];

View File

@@ -64,7 +64,6 @@ class PgnGameParser{
if($i==0){
$this->moveBuilder->addCommentBeforeFirstMove($parts[$i+1]);
}else{
$this->moveBuilder->addComment($parts[$i+1]);
}
$i+=2;

View File

@@ -25,7 +25,7 @@ class ParserTest extends PHPUnit_Framework_TestCase
/**
* @test
*/
public function shouldCreatParser()
public function shouldCreateParser()
{
// given
$parser = $this->getParser();
@@ -1796,6 +1796,11 @@ class ParserTest extends PHPUnit_Framework_TestCase
}
return $ret;
}
/**
* @param null $fen
* @return FenParser0x88
*/
private function getParser($fen = null)
{
if (!isset($fen)) {