From 2cfe4818b44163389a1956b92467f8844a05175b Mon Sep 17 00:00:00 2001 From: DHTMLGoodies Date: Mon, 28 Dec 2015 16:14:45 +0100 Subject: [PATCH] Readme updates --- README.md | 25 ++++++++++++++++++------- test/ParserTest.php | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f1d3471..3fc046b 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ This is the chess parser used in DHTML Chess at dhtml-chess.com ####License: LGPL (Lesser General Public License). -Example of use: +#####Example of use: -1) Import games from PGN file: +######1) Import games from PGN file: ```PHP setPgnContent($pgn); - $game = $parser->getFirstGame(); - echo json_encode($game); +$parser = new PgnParser(); +$parser->setPgnContent($pgn); +$game = $parser->getFirstGame(); +echo json_encode($game); ``` + +######3) Create a game programatically. +This uses the FenParser0x88 class: + +```PHP +$parser = new FenParser0x88(); +$parser->newGame(); +$parser->move("g1f3"); +$notation = $parser->getNotation(); // returns Nf3 +$fen = $parser->getFen(); +// returns fen: rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R b KQkq - 1 1 diff --git a/test/ParserTest.php b/test/ParserTest.php index 670dd8a..ccd2abd 100644 --- a/test/ParserTest.php +++ b/test/ParserTest.php @@ -109,6 +109,7 @@ Qe7 28. e4 Nh7 29. h5 Nf8 30. Qb8 g5 31. Qc8 Ne6 32. Bxe6 Qxe6 33. Qxe6 fxe6 $parser->newGame(); $parser->move("Nf3"); $notation = $parser->getNotation(); + echo $parser->getFen(); $this->assertEquals("Nf3", $notation);