jeroened / libpairtwo Goto Github PK
View Code? Open in Web Editor NEWExport chess tournaments directly on the web
Home Page: https://www.jeroened.be/libpairtwo
License: GNU Affero General Public License v3.0
Export chess tournaments directly on the web
Home Page: https://www.jeroened.be/libpairtwo
License: GNU Affero General Public License v3.0
Create implementation for categories
Tiebreaks are currently not implemented. Fixing this requires quite some work where the generalization is part of. This issue is to keep track of this work.
Pairtwo-6
) implement calculation of tiebreaksWhen requesting the the id of a player the elo of the player is being returned
$ php getId.php
{'id': 14948}
{'id': 1150}
<?php
use JeroenED\Libpairtwo\IOFactory;
require_once 'vendor/autoload.php';
$sws = IOFactory::createReader('Pairtwo-6');
$sws->read('res/testsws.sws');
echo "Fide id P1: " . $sws->getTournament()->getPlayerById(0)->getId('Fide') . PHP_EOL;
PHP 7.3.9-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Sep 2 2019 12:54:24) ( NTS )
All of them. Libpairtwo issue. See https://github.com/JeroenED/libpairtwo/blob/master/src/Player.php#L138
When some data contains only 0x00 characters it is returned as length * 0x00 data.
When data is not filled it returns nothing
When data is not filled in it returns length * 0x00
use JeroenED\Libpairtwo\Sws;
require_once 'vendor/autoload.php';
$sws = Sws::readSws('upload/issue.sws');
echo "Empty value: " . $sws->getTournament()->getFirstPeriod() . PHP_EOL;
PHP 7.3.2-3+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 8 2019 15:43:57) ( NTS )
Creation of units test for testing the code
Removing getter and setter methods
See roadmap
Names and other data containing extended ASCII characterers (eg. é) fail to be transmitted properly
Getting a name with extended ascii character gets the name as it was written in the sws-file
Getting a name with extended ascii character gets the name as it was written in the sws-file but extended ascii characters are replaced with question marks
require_once 'vendor/autoload.php';
$sws = Sws::readSws('uploads/issue1.sws');
echo "Chloé: " . $sws->getTournament()->getPlayerById(0)->getName() . PHP_EOL;
echo "Noëlla: " . $sws->getTournament()->getPlayerById(1)->getName() . PHP_EOL;
echo "André: " . $sws->getTournament()->getPlayerById(2)->getName() . PHP_EOL;
PHP 7.3.2-3+ubuntu18.04.1+deb.sury.org+1
When saving a adjourned result (eg. 1-1Adj) the result is different when using libpairtwo
$ php disaster.php
Ronde: 1
Player 1 1-1A Player 2
$ php disaster.php
Ronde: 1
Player 1 1-0A Player 2
Player 1 0-1A Player 2
<?php
require_once("vendor/autoload.php");
$sws = JeroenED\Libpairtwo\Sws::ReadSws("Adjourned results not reliable_R04.sws");
$calendar = $sws->getTournament()->getRounds();
$roundNo = 1;
foreach ($calendar as $round) {
echo "Ronde: " . $roundNo . PHP_EOL; $roundNo++;
foreach($round->getGames() as $game) {
if (!is_null($game->getResult())) {
echo (is_null($game->getWhite())) ? "bye" : htmlentities($game->getWhite()->getName());
echo " " . $game->getResult()->getValue() . " ";
echo (is_null($game->getBlack())) ? "bye" : htmlentities($game->getBlack()->getName());
echo PHP_EOL;
}
}
echo PHP_EOL;
}
$ php -v
PHP 7.3.2-3+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 8 2019 15:43:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.2, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.2-3+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
When calculating the performance rating, the returned value is not correct
Perf P1: 1810
Perf P2: 2602
Perf P3: 1331
Perf P1: 1803
Perf P2: 2203
Perf P3: 1401
$sws = IOFactory::createReader('Pairtwo-6');
$sws->read('../res/testsws.sws');
echo "Perf P1: " . $sws->getTournament()->getPlayerById(0)->getPerformance($sws->getTournament()->getPriorityElo(), $sws->getTournament()->getNonRatedElo()) . PHP_EOL;
echo "Perf P2: " . $sws->getTournament()->getPlayerById(1)->getPerformance($sws->getTournament()->getPriorityElo(), $sws->getTournament()->getNonRatedElo()) . PHP_EOL;
echo "Perf P3: " . $sws->getTournament()->getPlayerById(2)->getPerformance($sws->getTournament()->getPriorityElo(), $sws->getTournament()->getNonRatedElo()) . PHP_EOL;
$ php -v
PHP 7.3.6-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 31 2019 11:06:48) ( NTS )
https://github.com/JeroenED/libpairtwo/blob/ae832bb02525e4907a1d3b706c2f21ad3e1f5b15/res/testsws.sws
When using the mutual result tiebreak where not all players played each other, the tiebreak is still calculated if 1 player did play all others.
Player C
Opponents: Player K (Result: 0.5), Player M (Result: 0.5), Player O (Result: 1), Player F (Result: 1), Player D (Result: 1), Player E (Result: 0), Player G (Result: 0.5),
Points: 4.5
Mutual Result: 0
Player E
Opponents: Player M (Result: 0.5), Player O (Result: 0.5), Player K (Result: 1), Player B (Result: 0.5), Player L (Result: 1), Player C (Result: 1), Player D (Result: 0),
Points: 4.5
Mutual Result: 0
Player G
Opponents: Player O (Result: 0.5), Player D (Result: 0), Player M (Result: 0.5), Player H (Result: 1), Player F (Result: 1), Player L (Result: 1), Player C (Result: 0.5),
Points: 4.5
Mutual Result: 0
Player C
Opponents: Player K (Result: 0.5), Player M (Result: 0.5), Player O (Result: 1), Player F (Result: 1), Player D (Result: 1), Player E (Result: 0), Player G (Result: 0.5),
Points: 4.5
Mutual Result: 0.5
Player E
Opponents: Player M (Result: 0.5), Player O (Result: 0.5), Player K (Result: 1), Player B (Result: 0.5), Player L (Result: 1), Player C (Result: 1), Player D (Result: 0),
Points: 4.5
Mutual Result: 0
Player G
Opponents: Player O (Result: 0.5), Player D (Result: 0), Player M (Result: 0.5), Player H (Result: 1), Player F (Result: 1), Player L (Result: 1), Player C (Result: 0.5),
Points: 4.5
Mutual Result: 0
<?php
require_once("vendor/autoload.php");
$reader = JeroenED\Libpairtwo\IOFactory::createReader("Swar-4");
$reader->read('Libpairtwo test tournament.swar');
$tournamenttiebreaks = $reader->Tournament->Tiebreaks;
foreach ($reader->Tournament->Ranking as $key => $standing) {
$rankarray = array();
echo $standing->Name . PHP_EOL;
echo "Opponents: ";
foreach ($standing->Pairings as $pairing) {
echo $pairing->Opponent->Name . ' (Result: ' . $pairing->Result . '), ';
}
echo PHP_EOL;
foreach ($standing->Tiebreaks as $key=>$tiebreak) {
if($tournamenttiebreaks[$key] != '') echo $tournamenttiebreaks[$key] . ': ' . $tiebreak . PHP_EOL;
}
echo PHP_EOL;
}
$ php -v
PHP 7.4.1 (cli) (built: Dec 18 2019 14:44:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.1, Copyright (c), by Zend Technologies
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.