Merge branch 'task/dist-readme' into develop

This commit is contained in:
Jeroen De Meerleer 2019-06-19 10:43:01 +02:00
commit 4eedc9255c
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
3 changed files with 77 additions and 55 deletions

10
.gitignore vendored
View File

@ -6,10 +6,10 @@ composer.lock
/nbproject/ /nbproject/
/res/protected/ /res/protected/
/.idea /.idea
doc/api/* /doc/api/*
libpairtwo-dist.zip /libpairtwo-dist.zip
dist/* /dist/vendor/
!dist/boilerplate.php /dist/composer.json
!dist/composer-*.json /dist/doc/

100
dist/boilerplate.php vendored
View File

@ -22,56 +22,56 @@ $reader->read($pairingfile);
// Below is an example of what can be used. Feel free to modify this. // Below is an example of what can be used. Feel free to modify this.
echo "<pre>"; echo "<pre>";
echo "Name: " . $sws->getTournament()->getName() . PHP_EOL; echo "Name: " . $reader->getTournament()->getName() . PHP_EOL;
echo "Organiser: " . $sws->getTournament()->getOrganiser(). PHP_EOL; echo "Organiser: " . $reader->getTournament()->getOrganiser(). PHP_EOL;
echo "Tempo: " . $sws->getTournament()->getTempo() . PHP_EOL; echo "Tempo: " . $reader->getTournament()->getTempo() . PHP_EOL;
echo "Country: " . $sws->getTournament()->getOrganiserCountry() . PHP_EOL; echo "Country: " . $reader->getTournament()->getOrganiserCountry() . PHP_EOL;
echo "Arbiter: " . $sws->getTournament()->getArbiter() . PHP_EOL; echo "Arbiter: " . $reader->getTournament()->getArbiter() . PHP_EOL;
echo "Rounds: " . $sws->getTournament()->getNoOfRounds() . PHP_EOL; echo "Rounds: " . $reader->getTournament()->getNoOfRounds() . PHP_EOL;
echo "Participants: " . $sws->getTournament()->getNoOfRounds() . PHP_EOL; echo "Participants: " . $reader->getTournament()->getParticipants() . PHP_EOL;
echo "Fidehomol: " . $sws->getTournament()->getFideHomol() . PHP_EOL; echo "Fidehomol: " . $reader->getTournament()->getFideHomol() . PHP_EOL;
echo "Start-Date: " . $sws->getTournament()->getStartDate()->format('d/m/Y') . PHP_EOL; echo "Start-Date: " . $reader->getTournament()->getStartDate()->format('d/m/Y') . PHP_EOL;
echo "End-Date: " . $sws->getTournament()->getEndDate()->format('d/m/Y') . PHP_EOL; echo "End-Date: " . $reader->getTournament()->getEndDate()->format('d/m/Y') . PHP_EOL;
echo "System: " . $sws->getTournament()->getSystem()->getKey() . PHP_EOL; echo "System: " . $reader->getTournament()->getSystem()->getKey() . PHP_EOL;
echo "Place: " . $sws->getTournament()->getOrganiserPlace() . PHP_EOL; echo "Place: " . $reader->getTournament()->getOrganiserPlace() . PHP_EOL;
echo "Unrated-Elo: " . $sws->getTournament()->getNonRatedElo() . PHP_EOL; echo "Unrated-Elo: " . $reader->getTournament()->getNonRatedElo() . PHP_EOL;
echo "Federation: " . $sws->getTournament()->getFederation() . PHP_EOL; echo "Federation: " . $reader->getTournament()->getFederation() . PHP_EOL;
echo "Organiser: " . $sws->getTournament()->getOrganiserClubNo() . PHP_EOL; echo "Organiser: " . $reader->getTournament()->getOrganiserClubNo() . PHP_EOL;
echo "Fide Elo P1: " . $sws->getTournament()->getPlayerById(0)->getElo('Fide') . PHP_EOL; echo "Fide Elo P1: " . $reader->getTournament()->getPlayerById(0)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P2: " . $sws->getTournament()->getPlayerById(1)->getElo('Fide') . PHP_EOL; echo "Fide Elo P2: " . $reader->getTournament()->getPlayerById(1)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P3: " . $sws->getTournament()->getPlayerById(2)->getElo('Fide') . PHP_EOL; echo "Fide Elo P3: " . $reader->getTournament()->getPlayerById(2)->getElo('Fide') . PHP_EOL;
echo "KBSB Elo P1: " . $sws->getTournament()->getPlayerById(0)->getElo('Nation') . PHP_EOL; echo "KBSB Elo P1: " . $reader->getTournament()->getPlayerById(0)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P2: " . $sws->getTournament()->getPlayerById(1)->getElo('Nation') . PHP_EOL; echo "KBSB Elo P2: " . $reader->getTournament()->getPlayerById(1)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P3: " . $sws->getTournament()->getPlayerById(2)->getElo('Nation') . PHP_EOL; echo "KBSB Elo P3: " . $reader->getTournament()->getPlayerById(2)->getElo('Nation') . PHP_EOL;
echo "Name P1: " . $sws->getTournament()->getPlayerById(0)->getName() . PHP_EOL; echo "Name P1: " . $reader->getTournament()->getPlayerById(0)->getName() . PHP_EOL;
echo "Name P2: " . $sws->getTournament()->getPlayerById(1)->getName() . PHP_EOL; echo "Name P2: " . $reader->getTournament()->getPlayerById(1)->getName() . PHP_EOL;
echo "Name P3: " . $sws->getTournament()->getPlayerById(2)->getName() . PHP_EOL; echo "Name P3: " . $reader->getTournament()->getPlayerById(2)->getName() . PHP_EOL;
echo "Gender P1: " . $sws->getTournament()->getPlayerById(0)->getGender()->getKey() . PHP_EOL; echo "Gender P1: " . $reader->getTournament()->getPlayerById(0)->getGender()->getKey() . PHP_EOL;
echo "Gender P2: " . $sws->getTournament()->getPlayerById(1)->getGender()->getKey() . PHP_EOL; echo "Gender P2: " . $reader->getTournament()->getPlayerById(1)->getGender()->getKey() . PHP_EOL;
echo "Gender P3: " . $sws->getTournament()->getPlayerById(2)->getGender()->getKey() . PHP_EOL; echo "Gender P3: " . $reader->getTournament()->getPlayerById(2)->getGender()->getKey() . PHP_EOL;
echo "Absent P1: " . $sws->getTournament()->getPlayerById(0)->getBinaryData("Absent") . PHP_EOL; echo "Absent P1: " . $reader->getTournament()->getPlayerById(0)->getBinaryData("Absent") . PHP_EOL;
echo "Absent P2: " . $sws->getTournament()->getPlayerById(1)->getBinaryData("Absent") . PHP_EOL; echo "Absent P2: " . $reader->getTournament()->getPlayerById(1)->getBinaryData("Absent") . PHP_EOL;
echo "Absent P3: " . $sws->getTournament()->getPlayerById(2)->getBinaryData("Absent") . PHP_EOL; echo "Absent P3: " . $reader->getTournament()->getPlayerById(2)->getBinaryData("Absent") . PHP_EOL;
echo "Date Round 1: " . $sws->getTournament()->getRoundByNo(0)->getDate()->format('d/m/Y') . PHP_EOL; echo "Date Round 1: " . $reader->getTournament()->getRoundByNo(0)->getDate()->format('d/m/Y') . PHP_EOL;
echo "Date Round 2: " . $sws->getTournament()->getRoundByNo(1)->getDate()->format('d/m/Y') . PHP_EOL; echo "Date Round 2: " . $reader->getTournament()->getRoundByNo(1)->getDate()->format('d/m/Y') . PHP_EOL;
echo "Date Round 3: " . $sws->getTournament()->getRoundByNo(2)->getDate()->format('d/m/Y') . PHP_EOL; echo "Date Round 3: " . $reader->getTournament()->getRoundByNo(2)->getDate()->format('d/m/Y') . PHP_EOL;
echo "Color Pairing 1: " . $sws->getTournament()->getPairings()[1]->getColor()->getKey() . PHP_EOL; echo "Color Pairing 1: " . $reader->getTournament()->getPairings()[1]->getColor()->getKey() . PHP_EOL;
echo "Color Pairing 2: " . $sws->getTournament()->getPairings()[2]->getColor()->getKey() . PHP_EOL; echo "Color Pairing 2: " . $reader->getTournament()->getPairings()[2]->getColor()->getKey() . PHP_EOL;
echo "Color Pairing 3: " . $sws->getTournament()->getPairings()[3]->getColor()->getKey() . PHP_EOL; echo "Color Pairing 3: " . $reader->getTournament()->getPairings()[3]->getColor()->getKey() . PHP_EOL;
echo "Player Pairing 1: " . $sws->getTournament()->getPairings()[0]->getPlayer()->getName() . PHP_EOL; echo "Player Pairing 1: " . $reader->getTournament()->getPairings()[0]->getPlayer()->getName() . PHP_EOL;
echo "Player Pairing 2: " . $sws->getTournament()->getPairings()[1]->getPlayer()->getName() . PHP_EOL; echo "Player Pairing 2: " . $reader->getTournament()->getPairings()[1]->getPlayer()->getName() . PHP_EOL;
echo "Player Pairing 3: " . $sws->getTournament()->getPairings()[2]->getPlayer()->getName() . PHP_EOL; echo "Player Pairing 3: " . $reader->getTournament()->getPairings()[2]->getPlayer()->getName() . PHP_EOL;
echo "Bye Round 1: " . $sws->getTournament()->getRoundByNo(2)->getBye()[0]->getPlayer()->getName() . PHP_EOL; echo "Bye Round 1: " . $reader->getTournament()->getRoundByNo(2)->getBye()[0]->getPlayer()->getName() . PHP_EOL;
echo "Absent Round 1: " . $sws->getTournament()->getRoundByNo(2)->getAbsent()[0]->getPlayer()->getName() . PHP_EOL; echo "Absent Round 1: " . $reader->getTournament()->getRoundByNo(2)->getAbsent()[0]->getPlayer()->getName() . PHP_EOL;
echo "Tiebreak 1: " . $sws->getTournament()->getTiebreaks()[0]->getValue() . PHP_EOL; echo "Tiebreak 1: " . $reader->getTournament()->getTiebreaks()[0]->getValue() . PHP_EOL;
echo "Tiebreak 2: " . $sws->getTournament()->getTiebreaks()[1]->getValue() . PHP_EOL; echo "Tiebreak 2: " . $reader->getTournament()->getTiebreaks()[1]->getValue() . PHP_EOL;
echo "Tiebreak 3: " . $sws->getTournament()->getTiebreaks()[2]->getValue() . PHP_EOL; echo "Tiebreak 3: " . $reader->getTournament()->getTiebreaks()[2]->getValue() . PHP_EOL;
echo "Tiebreak 4: " . $sws->getTournament()->getTiebreaks()[3]->getValue() . PHP_EOL; echo "Tiebreak 4: " . $reader->getTournament()->getTiebreaks()[3]->getValue() . PHP_EOL;
echo "Tiebreak 5: " . $sws->getTournament()->getTiebreaks()[4]->getValue() . PHP_EOL; echo "Tiebreak 5: " . $reader->getTournament()->getTiebreaks()[4]->getValue() . PHP_EOL;
echo "Tiebreak 6: " . $sws->getTournament()->getTiebreaks()[5]->getValue() . PHP_EOL; echo "Tiebreak 6: " . $reader->getTournament()->getTiebreaks()[5]->getValue() . PHP_EOL;
echo "Average Elo: " . $sws->getTournament()->getAverageElo() . PHP_EOL; echo "Average Elo: " . $reader->getTournament()->getAverageElo() . PHP_EOL;
foreach ($sws->getTournament()->getRanking() as $player) { foreach ($reader->getTournament()->getRanking() as $player) {
echo str_pad($player->getName() . '(' . $player->getElo($sws->getTournament()->getPriorityElo()) . ') ', 35) . implode_pad(' ', $player->getTiebreaks(), 5, ' ') . PHP_EOL; echo str_pad($player->getName() . '(' . $player->getElo($reader->getTournament()->getPriorityElo()) . ') ', 35) . implode_pad(' ', $player->getTiebreaks(), 5, ' ') . PHP_EOL;
} }

22
dist/readme.md vendored Normal file
View File

@ -0,0 +1,22 @@
libpairtwo
==========
This distribution is a good start to use libpairtwo if you don't have knowledge of composer or dependency management.
How to use this distribution?
-----------------------------
The file `boilerplate.php` is the one you'll probably want to work with. You'll want to point your browser to file file. It contains some initializations where the most important one is the variable `$pairingfile`. You'll want to set this to existing pairing file.
The other variable (`$pairingfileformat`) is a variable that defines the format of the above pairing file. For now only `Pairtwo-6` and `Pairtwo-5` are available. In the future more formats will become available.
Below the comments you'll find some example code. This code is only a aggregation of several fields that are read out. If you need any modifications like putting the rankings in a table or you want to just write it to a file, go ahead it's all yours.
What if I need other dependencies?
----------------------------------
If you started to ask yourself this question, you'll probably know what composer and dependency management is? Therefore this section will become a little more advanced than the ones above.
It's actually very simple, just add them like you normally would do.
$ composer require phpoffice/phpspreadsheet
If you already have a project with other dependencies you'll only want to copy the `boilerplate.php` file and run.
$ composer require jeroened/libpairtwo