updates
This commit is contained in:
@@ -150,6 +150,20 @@ class PgnParser
|
|||||||
return $this->getGameByIndex(0);
|
return $this->getGameByIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getGameByIndexShort($index)
|
||||||
|
{
|
||||||
|
$games = $this->getUnparsedGames();
|
||||||
|
if (count($games) && count($games) > $index) {
|
||||||
|
$game = $this->getParsedGame($games[$index]);
|
||||||
|
$game["moves"] = $this->toShortVersion($game["moves"]);
|
||||||
|
return $game;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getGameByIndex($index)
|
public function getGameByIndex($index)
|
||||||
{
|
{
|
||||||
$games = $this->getUnparsedGames();
|
$games = $this->getUnparsedGames();
|
||||||
@@ -185,23 +199,14 @@ class PgnParser
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getParsedGameShort($unParsedGame)
|
|
||||||
|
private function toShortVersion($branch)
|
||||||
{
|
{
|
||||||
$this->pgnGameParser->setPgn($unParsedGame);
|
|
||||||
$ret = $this->pgnGameParser->getParsedData();
|
|
||||||
if ($this->fullParsing()) {
|
|
||||||
$ret = $this->gameParser->getParsedGame($ret, true);
|
|
||||||
$moves = &$ret["moves"];
|
|
||||||
$moves = $this->toShortVersion($moves);
|
|
||||||
}
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private function toShortVersion($branch){
|
|
||||||
foreach ($branch as &$move) {
|
foreach ($branch as &$move) {
|
||||||
$move["n"] = $move["from"] . $move["to"];
|
$move["n"] = $move["from"] . $move["to"];
|
||||||
unset($move["m"]);
|
|
||||||
|
#$move["n"] = $move["from"] . $move["to"];
|
||||||
|
#unset($move["m"]);
|
||||||
unset($move["fen"]);
|
unset($move["fen"]);
|
||||||
unset($move["from"]);
|
unset($move["from"]);
|
||||||
unset($move["to"]);
|
unset($move["to"]);
|
||||||
@@ -216,7 +221,9 @@ class PgnParser
|
|||||||
return $branch;
|
return $branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getParsedGame($unParsedGame)
|
|
||||||
|
private
|
||||||
|
function getParsedGame($unParsedGame)
|
||||||
{
|
{
|
||||||
$this->pgnGameParser->setPgn($unParsedGame);
|
$this->pgnGameParser->setPgn($unParsedGame);
|
||||||
$ret = $this->pgnGameParser->getParsedData();
|
$ret = $this->pgnGameParser->getParsedData();
|
||||||
|
Reference in New Issue
Block a user