定制 chesszebra/portable-game-notation 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

chesszebra/portable-game-notation

Composer 安装命令:

composer require chesszebra/portable-game-notation

包简介

A PHP library to parse and write chess games in the portable game notation (PGN) format.

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

A PHP library to parse and write chess games in the portable game notation (PGN) format.

Installation

Via composer

composer require chesszebra/portable-game-notation

Usage

Reading

From a string

Reading a single PGN game from a string:

use ChessZebra\PortableGameNotation\Reader\StringReader;

$reader = new StringReader('1. e4 e5');

$tokenIterator = $reader->read();

From a stream

Reading a single PGN game from a stream:

use ChessZebra\PortableGameNotation\Reader\StringReader;

$reader = new StreamReader(fopen('games.pgn', 'r'));

$tokenIterator = $reader->read();

Writing

To a string

Wriring a PGN game to a string:

use ChessZebra\PortableGameNotation\TokenIterator;
use ChessZebra\PortableGameNotation\Token\StandardAlgebraicNotation;
use ChessZebra\PortableGameNotation\Writer\StringWriter;
use ChessZebra\StandardAlgebraicNotation\Notation;

$tokenIterator = new TokenIterator([
    new MoveNumber(1),
    new StandardAlgebraicNotation(new Notation('e4')),
]);

$writer = new StringWriter();
$writer->write($tokenIterator);

$pgn = $writer->getPgn();

To a stream

Wriring a PGN game to a stream:

use ChessZebra\PortableGameNotation\TokenIterator;
use ChessZebra\PortableGameNotation\Token\StandardAlgebraicNotation;
use ChessZebra\PortableGameNotation\Writer\Stream;
use ChessZebra\StandardAlgebraicNotation\Notation;

$tokenIterator = new TokenIterator([
    new MoveNumber(1),
    new StandardAlgebraicNotation(new Notation('e4')),
]);

$writer = new Stream(fopen('game.pgn', 'w'));
$writer->write($tokenIterator);

Tokenizing games

From a string

use ChessZebra\PortableGameNotation\Lexer\StringLexer;

$lexer = new StringLexer('1. e4');

$token = $lexer->getNextToken();

From a resource

use ChessZebra\PortableGameNotation\Lexer\StreamLexer;

$lexer = new StreamLexer(fopen('my-games.pgn', 'r'));

$token = $lexer->getNextToken();

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please report them via HackerOne.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 919
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固