Merge branch 'develop'

This commit is contained in:
Jeroen De Meerleer 2020-11-22 17:20:25 +01:00
commit c35180271e
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
38 changed files with 2715 additions and 2188 deletions

7
.gitattributes vendored
View File

@ -1,7 +0,0 @@
# *.php diff=php
#/.gitattributes export-ignore
#/.gitignore export-ignore
#/.php_cs export-ignore
#/.travis.ini export-ignore
#/.travis.yml export-ignore

7
.gitignore vendored
View File

@ -1,3 +1,5 @@
/bin/
!/bin/.gitkeep
/build/ /build/
/vendor/ /vendor/
composer.lock composer.lock
@ -5,7 +7,8 @@ composer.lock
/.php_cs.cache /.php_cs.cache
/nbproject/ /nbproject/
/res/protected/ /res/protected/
/.idea /.idea/*.*
!/.idea/codeStyles/*
/doc/api/* /doc/api/*
/libpairtwo-*-dist.zip /libpairtwo-*-dist.zip
@ -13,3 +16,5 @@ composer.lock
/dist/vendor/ /dist/vendor/
/dist/composer.json /dist/composer.json
/dist/doc/ /dist/doc/
/.phpdoc

View File

@ -0,0 +1,134 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<PHPCodeStyleSettings>
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
<option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
<option name="ALIGN_PHPDOC_COMMENTS" value="true" />
<option name="ALIGN_INLINE_COMMENTS" value="true" />
<option name="PHPDOC_BLANK_LINE_BEFORE_TAGS" value="true" />
<option name="PHPDOC_BLANK_LINES_AROUND_PARAMETERS" value="true" />
<option name="PHPDOC_WRAP_LONG_LINES" value="true" />
<option name="BLANK_LINES_BETWEEN_IMPORTS" value="1" />
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
<option name="LOWER_CASE_NULL_CONST" value="true" />
<option name="ELSE_IF_STYLE" value="COMBINE" />
<option name="VARIABLE_NAMING_STYLE" value="CAMEL_CASE" />
<option name="BLANK_LINES_BEFORE_RETURN_STATEMENT" value="1" />
<option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
<option name="BLANK_LINES_AROUND_CONSTANTS" value="1" />
<option name="BLANK_LINES_AFTER_OPENING_TAG" value="1" />
<option name="KEEP_BLANK_LINES_AFTER_LBRACE" value="0" />
<option name="SPACE_BETWEEN_TERNARY_QUEST_AND_COLON" value="true" />
<option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" value="true" />
<option name="NEW_LINE_AFTER_PHP_OPENING_TAG" value="true" />
<option name="PLACE_PARENS_FOR_CONSTRUCTOR" value="1" />
</PHPCodeStyleSettings>
<codeStyleSettings language="PHP">
<option name="RIGHT_MARGIN" value="120" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="BLANK_LINES_AFTER_PACKAGE" value="1" />
<option name="BLANK_LINES_AROUND_FIELD" value="1" />
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<option name="SPACE_WITHIN_BRACKETS" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="5" />
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="EXTENDS_LIST_WRAP" value="5" />
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
<option name="PARENTHESES_EXPRESSION_LPAREN_WRAP" value="true" />
<option name="PARENTHESES_EXPRESSION_RPAREN_WRAP" value="true" />
<option name="BINARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="MODIFIER_LIST_WRAP" value="true" />
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="5" />
<option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
<option name="ASSIGNMENT_WRAP" value="5" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
<arrangement>
<groups>
<group>
<type>GETTERS_AND_SETTERS</type>
<order>KEEP</order>
</group>
</groups>
<rules>
<section>
<rule>
<match>
<CONST>true</CONST>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<FIELD>true</FIELD>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<CONSTRUCTOR>true</CONSTRUCTOR>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<METHOD>true</METHOD>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<TRAIT>true</TRAIT>
</match>
</rule>
</section>
<section>
<rule>
<match>
<INTERFACE>true</INTERFACE>
</match>
</rule>
</section>
<section>
<rule>
<match>
<CLASS>true</CLASS>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View File

@ -0,0 +1,17 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PhpCSValidationInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="CODING_STANDARD" value="PSR12" />
<option name="EXTENSIONS" value="php,js,css,inc" />
</inspection_tool>
<inspection_tool class="PhpCompoundNamespaceDepthInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpLongTypeFormInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpMissingVisibilityInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpModifierOrderInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpNewClassMissingParameterListInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpSeparateElseIfInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpTraitsUseListInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PhpVarUsageInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
</profile>
</component>

12
.php_cs
View File

@ -1,12 +0,0 @@
<?php
$finder = PhpCsFixer\Finder::create()
->exclude(['build', 'vendor'])
->in(__DIR__);
return PhpCsFixer\Config::create()
->setFinder($finder)
->setUsingCache(true)
->setRules([
'@PSR2' => true,
]);

View File

@ -1,18 +0,0 @@
language: php
matrix:
fast_finish: true
include:
- php: 7.2
- php: 7.2
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
cache:
directories:
- $HOME/.composer/cache
install:
- composer update ${COMPOSER_FLAGS} --no-interaction
script:
- make tests

View File

@ -6,14 +6,54 @@ VERSION := $(if $(TAG),$(TAG),dev-$(BRANCH))
help: help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-12s\033[0m %s\n", $$1, $$2}' @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-12s\033[0m %s\n", $$1, $$2}'
tests: ## Executes the test suite install-dev: ## Installs the required common devtools
vendor/bin/phpunit @echo "Downloading phpdoc"
@wget https://phpdoc.org/phpDocumentor.phar -O bin/phpdoc 2> /dev/null
@echo "Downloading phpcs"
@wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar -O bin/phpcs 2> /dev/null
@wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar -O bin/phpcbf 2> /dev/null
@echo "Adding execution rights on the binaries"
@chmod +x bin/phpcs bin/phpcbf bin/phpdoc
@echo "Installation of devtools finished"
@echo "Please add $(shell echo $(PWD))/bin to your PATH"
coverage: ## Executes the test suite and creates code coverage reports docs: ## Generates api-docs
vendor/bin/phpunit --coverage-html build/coverage phpdoc -d ./src -t ./doc/api
view-coverage: ## Shows the code coverage report dist: ## Generates distribution
open build/coverage/index.html cp dist/composer* res/
mv dist/composer-dist.json dist/composer.json
sed -i -e "s%//VERSION//%$(VERSION)%g" dist/composer.json
cd dist && composer install
rm dist/composer.json
rm dist/composer.lock
mv dist/composer-dist-installed.json dist/composer.json
make api
mkdir -p dist/doc
cp -r doc/api dist/doc
cd dist && zip -r ../libpairtwo-$(VERSION)-dist.zip *
git reset --hard HEAD
mv res/composer* dist/
clean: clean-dist clean-dev clean-repo ## Cleans all assets
clean-dev: ## Cleans dev assets
rm -rf doc/api
rm -rf .idea
rm -rf .libpairtwo-distro
rm -rf vendor
rm -rf composer.lock
clean-dist: ## Cleans distribution assets
rm -rf dist/doc
rm -rf dist/vendor
rm -rf dist/composer.json
rm -rf libpairtwo-*-dist.zip
clean-repo: ## Cleans the git repository
git fsck
git prune
git gc
api: ## Generates api-docs api: ## Generates api-docs
phpdoc -d ./src -t ./doc/api phpdoc -d ./src -t ./doc/api
@ -54,7 +94,7 @@ clean-repo: ## Cleans the git repository
git gc git gc
cs: ## Fixes coding standard problems cs: ## Fixes coding standard problems
vendor/bin/php-cs-fixer fix || true php bin/phpcs || true
tag: ## Creates a new signed git tag tag: ## Creates a new signed git tag
$(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=X.X.X")) $(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=X.X.X"))

View File

@ -1,6 +1,6 @@
# libpairtwo # libpairtwo
![logo](https://raw.githubusercontent.com/JeroenED/libpairtwo/master/res/logo-lightback-250px.png "Logo libpairtwo") ![logo](https://raw.githubusercontent.com/JeroenED/libpairtwo/develop/res/logo-lightback-250px.png "Logo libpairtwo")
Copyright 2018- (c) Jeroen De Meerleer <schaak@jeroened.be> Copyright 2018- (c) Jeroen De Meerleer <schaak@jeroened.be>

0
bin/.gitkeep Normal file
View File

View File

@ -2,7 +2,10 @@
"name": "jeroened/libpairtwo", "name": "jeroened/libpairtwo",
"type": "library", "type": "library",
"description": "Export chess tournaments directly on the web", "description": "Export chess tournaments directly on the web",
"keywords": ["chess", "pairing"], "keywords": [
"chess",
"pairing"
],
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"authors": [ "authors": [
{ {
@ -18,7 +21,6 @@
"ext-iconv": "*" "ext-iconv": "*"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^2.16"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -5,8 +5,8 @@
"url": "../" "url": "../"
} }
], ],
"require": { "require": {
"jeroened/libpairtwo": "//VERSION//" "jeroened/libpairtwo": "//VERSION//"
}, },
"minimum-stability": "dev" "minimum-stability": "dev"
} }

59
dist/template.php vendored
View File

@ -27,7 +27,10 @@ use JeroenED\Libpairtwo\IOFactory;
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
if (!file_exists($pairingfile)) { if (!file_exists($pairingfile)) {
trigger_error('Your file is not set or doesn\'t exist! Edit the file: ' . __FILE__ . ' and try again', E_USER_ERROR); trigger_error(
'Your file is not set or doesn\'t exist! Edit the file: ' . __FILE__ . ' and try again',
E_USER_ERROR
);
} }
$reader = IOFactory::createReader($fileformat); $reader = IOFactory::createReader($fileformat);
@ -49,8 +52,18 @@ foreach ($reader->Tournament->Rounds as $round) {
foreach ($round->GamesByBoard as $game) { foreach ($round->GamesByBoard as $game) {
echo '<tr>' . PHP_EOL; echo '<tr>' . PHP_EOL;
echo '<td>' . ($game->Board + 1) . '</td>' . PHP_EOL; echo '<td>' . ($game->Board + 1) . '</td>' . PHP_EOL;
echo '<td>' . $game->White->Player->Name . '</td>' . PHP_EOL; echo '<td>' .
echo '<td>' . $game->Black->Player->Name . '</td>' . PHP_EOL; $game->White->Player->Name .
' (' .
$game->White->Player->getElo($reader->Tournament->PriorityElo) .
')</td>' .
PHP_EOL;
echo '<td>' .
$game->Black->Player->Name .
' (' .
$game->Black->Player->getElo($reader->Tournament->PriorityElo) .
')</td>' .
PHP_EOL;
echo '<td>' . $game->Result->getValue() . '</td>' . PHP_EOL; echo '<td>' . $game->Result->getValue() . '</td>' . PHP_EOL;
echo '</tr>' . PHP_EOL; echo '</tr>' . PHP_EOL;
} }
@ -73,11 +86,11 @@ foreach ($reader->Tournament->Rounds as $round) {
echo '</p>' . PHP_EOL; echo '</p>' . PHP_EOL;
} }
echo '<h2>Rankings</h2>' . PHP_EOL; echo '<h2>Global Rankings</h2>' . PHP_EOL;
echo '<table>' . PHP_EOL; echo '<table>' . PHP_EOL;
echo '<thead>' . PHP_EOL; echo '<thead>' . PHP_EOL;
echo '<tr><th> </th><th>Name (elo)</th>' . PHP_EOL; echo '<tr><th> </th><th>Name (elo)</th><th>Category</th>' . PHP_EOL;
foreach ($reader->Tournament->TieBreaks as $tiebreak) { foreach ($reader->Tournament->Tiebreaks as $tiebreak) {
echo '<th>' . $tiebreak->getValue() . '</th>' . PHP_EOL; echo '<th>' . $tiebreak->getValue() . '</th>' . PHP_EOL;
} }
echo '</tr>' . PHP_EOL; echo '</tr>' . PHP_EOL;
@ -88,7 +101,8 @@ $rank = 1;
foreach ($reader->Tournament->Ranking as $player) { foreach ($reader->Tournament->Ranking as $player) {
echo '<tr>' . PHP_EOL; echo '<tr>' . PHP_EOL;
echo '<td>' . $rank . '</td>' . PHP_EOL; echo '<td>' . $rank . '</td>' . PHP_EOL;
echo '<td>' . $player->Name . '(' . $player->getElo($reader->Tournament->PriorityElo) . ')</td>' . PHP_EOL; echo '<td>' . $player->Name . ' (' . $player->getElo($reader->Tournament->PriorityElo) . ')</td>' . PHP_EOL;
echo '<td>' . $player->Category . '</td>' . PHP_EOL;
echo '<td>' . implode('</td><td>', $player->Tiebreaks) . '</td>' . PHP_EOL; echo '<td>' . implode('</td><td>', $player->Tiebreaks) . '</td>' . PHP_EOL;
echo '</tr>' . PHP_EOL; echo '</tr>' . PHP_EOL;
$rank++; $rank++;
@ -96,6 +110,35 @@ foreach ($reader->Tournament->Ranking as $player) {
echo '</tbody>' . PHP_EOL; echo '</tbody>' . PHP_EOL;
echo '</table>' . PHP_EOL; echo '</table>' . PHP_EOL;
?> ?>
<script src="js/scripts.js"></script>
<?php
echo '<h2>Rankings per Category</h2>' . PHP_EOL;
foreach ($reader->Tournament->Categories as $category) {
echo '<table>' . PHP_EOL;
echo '<caption>' . $category . '</caption>';
echo '<thead>' . PHP_EOL;
echo '<tr><th> </th><th>Name (elo)</th>' . PHP_EOL;
foreach ($reader->Tournament->Tiebreaks as $tiebreak) {
echo '<th>' . $tiebreak->getValue() . '</th>' . PHP_EOL;
}
echo '</tr>' . PHP_EOL;
echo '</thead>' . PHP_EOL;
echo '<tbody>' . PHP_EOL;
$rank = 1;
foreach ($reader->Tournament->RankingForCategory($category) as $player) {
echo '<tr>' . PHP_EOL;
echo '<td>' . $rank . '</td>' . PHP_EOL;
echo '<td>' . $player->Name . ' (' . $player->getElo($reader->Tournament->PriorityElo) . ')</td>' . PHP_EOL;
echo '<td>' . implode('</td><td>', $player->Tiebreaks) . '</td>' . PHP_EOL;
echo '</tr>' . PHP_EOL;
$rank++;
}
echo '</tbody>' . PHP_EOL;
echo '</table>' . PHP_EOL;
}
?>
<script src="js/scripts.js"></script>
</body> </body>
</html> </html>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.0/phpunit.xsd"
colors="true">
<testsuites>
<testsuite name="Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

BIN
res/categories_test.sws Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -1,215 +1,340 @@
<HTML> <HTML>
<HEAD> <HEAD>
<style type="text/css"> <style type="text/css">
body { font-size: 10pt; font-family: verdana;} body {
h1 {background-color: navy;color: #FDE0AA;font-size: 24pt;font-weight:bold;font-family:Arial;text-align:center;} font-size: 10pt;
th {background-color: #408080; font-size: 20pt; text-align: center;} font-family: verdana;
.rh {background-color: #408080; font-size: 16pt; text-align: center;} }
.vh {font-size: 10pt; text-align: center;}
.thr {font-size: 10pt; text-align: right} h1 {
.thl {font-size: 10pt; text-align: left} background-color: navy;
.thc {font-size: 10pt; text-align: center} color: #FDE0AA;
.tdr {font-size: 8pt; text-align: right} font-size: 24pt;
.tdl {font-size: 8pt; text-align: left} font-weight: bold;
.tdc {font-size: 8pt; text-align: center;} font-family: Arial;
.tdp {font-size: 10pt; font-weight:bold;text-align: center; background-color='yellow'} text-align: center;
.tde {font-size: 8pt; font-style:italic;text-align: right; background-color='#ceceff'} }
table {font-size: 10pt; font-family: Arial}
a { text-decoration: none; color: blue;} th {
a:visited { text-decoration: none; color: blue;} background-color: #408080;
a:hover { text-decoration:none ; color: red;} font-size: 20pt;
</style> text-align: center;
}
<TITLE>Libpairtwo Tournament</TITLE>
<META name='DESCRIPTION' content='Classement, Résultats, Appariement, Grille Américaine'> .rh {
<META name='AUTHOR' content='Georges Marchal'> background-color: #408080;
<META name='KEYWORDS' content='échecs,echecs,chess,jeux,game,belgique,belgium,forum'> font-size: 16pt;
<META name='KEYWORDS' content='liège,liege,666,elo,classement,tournoi,interclub'> text-align: center;
<META name='KEYWORDS' content='pairtwo, kbsb,frbe,fefb,666'> }
<META name='ROBOTS' content='INDEX,FOLLOW'>
</HEAD> .vh {
<BODY> font-size: 10pt;
<A name=Top></A> text-align: center;
}
<!-- TITRE GENERAL EN BLEU -->
<!-- ===================== --> .thr {
<TABLE width='90%' align='center' bgColor='#000080' border='0'> font-size: 10pt;
<TR><TD><H1>Libpairtwo Tournament</H1></TD></TR></TABLE> text-align: right
}
<!-- =============== -->
<!-- INFO DU TOURNOI --> .thl {
<!-- =============== --><br> font-size: 10pt;
<table align='center' border='1''> text-align: left
<tr><td align='center' valign='middle'><font size='+2'><b>313</b></font></td> }
<td><TABLE border='1' align='center' style='font-size: 8pt; font-family: verdana;'>
<tr><td align='center' bgColor='#000090'><font color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></td> .thc {
<td align='center' bgColor='#000090'><font color='white' size='-1'><b>PairTwo 6.13 (2015/08/10)</b></font></td></tr> font-size: 10pt;
<tr><td><i> Org. : </i></td><td>Libpairtwo Organiser ,Libpairtwo Place ,2019</td></tr> text-align: center
<tr><td><i>Arbit. : </i></td><td>Libpairtwo Organiser</td></tr> }
<tr><td><i> Tempo : </i></td><td>40c/2h + 1h QPF</td></tr>
<tr><td><i>Tie Break</i></td><td>Pts,&nbsp;Mutual Result,&nbsp;Number of Victories,&nbsp;Number of game Black played,&nbsp;Bucholtz Cut 1,&nbsp;SonneBorn-Berger</td></tr> .tdr {
</TABLE> font-size: 8pt;
</td> text-align: right
<td align='center' valign='middle'><font size='+2'><b>F.R.B.E.</b></font></td> }
</tr>
</table> .tdl {
<!-- ================== --> font-size: 8pt;
<!-- === REFERENCES === --> text-align: left
<!-- ================== --> }
<br><TABLE align='center' border='3' bgcolor='#ffffdd'>
<TR> .tdc {
<TD class='vh'><A HREF='#Round1'>R1</A></TD> font-size: 8pt;
<TD class='vh'><A HREF='#Round2'>R2</A></TD> text-align: center;
<TD class='vh'><A HREF='#Round3'>R3</A></TD> }
</TR>
<TR><TD class='vh' colspan='3'><A HREF='#Americaine'>American Ranking</A></TD></TR> .tdp {
</TABLE> font-size: 10pt;
<br> font-weight: bold;
<DIV ALIGN='CENTER'> text-align: center;
<TABLE align='center' bgcolor='#ffffdd' border='1'> background-color = 'yellow'
<!-- =========================== --> }
<!-- === DEBUT DU CLASSEMENT === -->
<!-- =========================== --> .tde {
<TR><TH>Ranking after round 3</TH></TR> font-size: 8pt;
<TR><TD><PRE> font-style: italic;
<b><u>Tit Name Rati F/M Club Cou Pts Res Vic #Bla BC1 S B </u></b> text-align: right;
1<b> FM</b> <b>Libpairtwo Player 2 </b> (1802) M Liga Vlaams-Brabant (VSF) BEL <b> 3.0</b>/<i>3 </i> 0.0 0 0 0.0 0.00 background-color = '#ceceff'
2<b> *</b> <b>Libpairtwo Player 1 </b> (1801) M Liga Antwerpen (VSF) BEL <b> 1.5</b>/<i>3 </i> 0.0 0 0 0.0 0.00 }
3<b> IM</b> <b>Libpairtwo Player 3 </b> (1803) F Liga West Vlaanderen (VSF) BEL <b> 1.0</b>/<i>2 </i> 0.0 0 0 0.0 0.00
4<b> GM</b> <b>Libpairtwo Player 4 </b> (1804) F Liga Oost Vlaanderen (VSF) BEL <b> 0.5</b>/<i>2 </i> 0.0 0 0 0.0 0.00 table {
<A href='#Top'>Top of Page</A> font-size: 10pt;
</PRE></TD></TR> font-family: Arial
<TR><TH class='rh'><A NAME='Round1' style='color: black'>Round 1 (01-01-2019)</A></TH></TR> }
<TR><TD><PRE>
1 Libpairtwo Player 2 ( 3) <b>1-0 </b>Libpairtwo Player 4 ( 1) a {
2 Libpairtwo Player 3 ( 2) <b>0-1 </b>Libpairtwo Player 1 ( 4) text-decoration: none;
</pre> color: blue;
}
<A HREF="#Top">(Go to Top)</A>
</TD> a:visited {
<TR><TH class='rh'><A NAME='Round2' style='color: black'>Round 2 (06-01-2019)</A></TH></TR> text-decoration: none;
<TR><TD><PRE> color: blue;
1 Libpairtwo Player 1 ( 4) <b>0-1 </b>Libpairtwo Player 2 ( 3) }
2 Libpairtwo Player 3 ( 2) <font color='red'> Bye</font>
Libpairtwo Player 4 ( 1)<font color='red'> Absent </font> a:hover {
</pre> text-decoration: none;
color: red;
<A HREF="#Top">(Go to Top)</A> }
</TD> </style>
<TR><TH class='rh'><A NAME='Round3' style='color: black'>Round 3 (11-01-2019)</A></TH></TR>
<TR><TD><PRE> <TITLE>Libpairtwo Tournament</TITLE>
1 Libpairtwo Player 4 ( 1) <b>½-½ </b>Libpairtwo Player 1 ( 4) <META content='Classement, R<>sultats, Appariement, Grille Am<41>ricaine' name='DESCRIPTION'>
2 Libpairtwo Player 2 ( 3) <font color='red'> Bye</font> <META content='Georges Marchal' name='AUTHOR'>
Libpairtwo Player 3 ( 2)<font color='red'> Absent </font> <META content='<27>checs,echecs,chess,jeux,game,belgique,belgium,forum' name='KEYWORDS'>
</pre> <META content='li<6C>ge,liege,666,elo,classement,tournoi,interclub' name='KEYWORDS'>
<META content='pairtwo, kbsb,frbe,fefb,666' name='KEYWORDS'>
<A HREF="#Top">(Go to Top)</A> <META content='INDEX,FOLLOW' name='ROBOTS'>
</TD> </HEAD>
</table></div> <BODY>
<!-- ================= --> <A name=Top></A>
<!-- GRILLE AMERICAINE -->
<!-- ================= --> <!-- TITRE GENERAL EN BLEU -->
<DIV ALIGN='CENTER'> <!-- ===================== -->
<TABLE align='center' bgcolor='#ffffdd' border='1'> <TABLE align='center' bgColor='#000080' border='0' width='90%'>
<TR> <TR>
<TH colspan='14'> <TD><H1>Libpairtwo Tournament</H1></TD>
<FONT size='+2'>American Ranking</FONT> </TR>
<A name=Americaine></A></TH></TR> </TABLE>
<TR bgcolor='#cccccc'> <!-- =============== -->
<TD class='thr'>&nbsp;</TD> <!-- INFO DU TOURNOI -->
<TD class='thl'><B>Name</B></TD> <!-- =============== --><br>
<TD class='thr'><B>Rating</B></TD> <table align='center' border='1'
<TD class='thr'><B> Pts</B></TD> '>
<TD class='thr'><B>Perf </B></TD> <tr>
<TD class='thc'><B>R1</B></TD> <td align='center' valign='middle'><font size='+2'><b>313</b></font></td>
<TD class='thc'><B>R2</B></TD> <td>
<TD class='thc'><B>R3</B></TD> <TABLE align='center' border='1' style='font-size: 8pt; font-family: verdana;'>
<TD class='thr'><b><i>Res </i></b></TD> <tr>
<TD class='thr'><b><i>Vic </i></b></TD> <td align='center' bgColor='#000090'><font color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></td>
<TD class='thr'><b><i>#Bla</i></b></TD> <td align='center' bgColor='#000090'><font color='white' size='-1'><b>PairTwo 6.13
<TD class='thr'><b><i>BC1 </i></b></TD> (2015/08/10)</b></font></td>
<TD class='thr'><b><i>S B </i></b></TD> </tr>
</tr> <tr>
<td><i> Org. : </i></td>
<tr> <td>Libpairtwo Organiser ,Libpairtwo Place ,2019</td>
<td class='tdr' bgcolor='#eeeeee'> 1</td> </tr>
<td class='tdl' bgcolor='#eeeeee'><B>Libpairtwo Player 2 (FM)</B></td> <tr>
<td class='tdr' bgcolor='#eeeeee'>1802</td> <td><i>Arbit. : </i></td>
<td class='tdr' bgcolor='#eeeeee'><B>3.0</B></td> <td>Libpairtwo Organiser</td>
<td class='tdr' bgcolor='#eeeeee'><i>2602</i></td> </tr>
<td class='tdc' bgcolor='#eeeeee'> 4W +</td> <tr>
<td class='tdc' bgcolor='#eeeeee'> 2B +</td> <td><i> Tempo : </i></td>
<td class='tdc' bgcolor='#eeeeee'>bye</td> <td>40c/2h + 1h QPF</td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td> </tr>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td> <tr>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td> <td><i>Tie Break</i></td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td> <td>Pts,&nbsp;Mutual Result,&nbsp;Number of Victories,&nbsp;Number of game Black played,&nbsp;Bucholtz
<td class='tdc' bgcolor='#eeeeee'><i> 0.00</i></td> Cut 1,&nbsp;SonneBorn-Berger
</tr> </td>
</tr>
</TABLE>
<tr> </td>
<td class='tdr' bgcolor='#cccccc'> 2</td> <td align='center' valign='middle'><font size='+2'><b>F.R.B.E.</b></font></td>
<td class='tdl' bgcolor='#cccccc'><B>Libpairtwo Player 1 (*)</B></td> </tr>
<td class='tdr' bgcolor='#cccccc'>1801</td> </table>
<td class='tdr' bgcolor='#cccccc'><B>1.5</B></td> <!-- ================== -->
<td class='tdr' bgcolor='#cccccc'><i>1810</i></td> <!-- === REFERENCES === -->
<td class='tdc' bgcolor='#cccccc'> 3B +</td> <!-- ================== -->
<td class='tdc' bgcolor='#cccccc'> 1W -</td> <br>
<td class='tdc' bgcolor='#cccccc'> 4B =</td> <TABLE align='center' bgcolor='#ffffdd' border='3'>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td> <TR>
<td class='tdc' bgcolor='#cccccc'><i>0</i></td> <TD class='vh'><A HREF='#Round1'>R1</A></TD>
<td class='tdc' bgcolor='#cccccc'><i>0</i></td> <TD class='vh'><A HREF='#Round2'>R2</A></TD>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td> <TD class='vh'><A HREF='#Round3'>R3</A></TD>
<td class='tdc' bgcolor='#cccccc'><i> 0.00</i></td> </TR>
</tr> <TR>
<TD class='vh' colspan='3'><A HREF='#Americaine'>American Ranking</A></TD>
</TR>
<tr> </TABLE>
<td class='tdr' bgcolor='#eeeeee'> 3</td> <br>
<td class='tdl' bgcolor='#eeeeee'><B>Libpairtwo Player 3 (IM)</B></td> <DIV ALIGN='CENTER'>
<td class='tdr' bgcolor='#eeeeee'>1803</td> <TABLE align='center' bgcolor='#ffffdd' border='1'>
<td class='tdr' bgcolor='#eeeeee'><B>1.0</B></td> <!-- =========================== -->
<td class='tdr' bgcolor='#eeeeee'><i>1331</i></td> <!-- === DEBUT DU CLASSEMENT === -->
<td class='tdc' bgcolor='#eeeeee'> 2W -</td> <!-- =========================== -->
<td class='tdc' bgcolor='#eeeeee'>bye</td> <TR>
<td class='tdc' bgcolor='#eeeeee'>...</td> <TH>Ranking after round 3</TH>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td> </TR>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td> <TR>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td> <TD><PRE>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td> <b><u>Tit Name Rati F/M Club Cou Pts Res Vic #Bla BC1 S B </u></b>
<td class='tdc' bgcolor='#eeeeee'><i> 0.00</i></td> 1<b> FM</b> <b>Libpairtwo Player 2 </b> (1802) M Liga Vlaams-Brabant (VSF) BEL <b> 3.0</b>/<i>3 </i> 0.0 0 0 0.0 0.00
</tr> 2<b> *</b> <b>Libpairtwo Player 1 </b> (1801) M Liga Antwerpen (VSF) BEL <b> 1.5</b>/<i>3 </i> 0.0 0 0 0.0 0.00
3<b> IM</b> <b>Libpairtwo Player 3 </b> (1803) F Liga West Vlaanderen (VSF) BEL <b> 1.0</b>/<i>2 </i> 0.0 0 0 0.0 0.00
4<b> GM</b> <b>Libpairtwo Player 4 </b> (1804) F Liga Oost Vlaanderen (VSF) BEL <b> 0.5</b>/<i>2 </i> 0.0 0 0 0.0 0.00
<tr> <A href='#Top'>Top of Page</A>
<td class='tdr' bgcolor='#cccccc'> 4</td> </PRE>
<td class='tdl' bgcolor='#cccccc'><B>Libpairtwo Player 4 (GM)</B></td> </TD>
<td class='tdr' bgcolor='#cccccc'>1804</td> </TR>
<td class='tdr' bgcolor='#cccccc'><B>0.5</B></td> <TR>
<td class='tdr' bgcolor='#cccccc'><i>1626</i></td> <TH class='rh'><A NAME='Round1' style='color: black'>Round 1 (01-01-2019)</A></TH>
<td class='tdc' bgcolor='#cccccc'> 1B -</td> </TR>
<td class='tdc' bgcolor='#cccccc'>...</td> <TR>
<td class='tdc' bgcolor='#cccccc'> 2W =</td> <TD><PRE>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td> 1 Libpairtwo Player 2 ( 3) <b>1-0 </b>Libpairtwo Player 4 ( 1)
<td class='tdc' bgcolor='#cccccc'><i>0</i></td> 2 Libpairtwo Player 3 ( 2) <b>0-1 </b>Libpairtwo Player 1 ( 4)
<td class='tdc' bgcolor='#cccccc'><i>0</i></td> </pre>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#cccccc'><i> 0.00</i></td> <A HREF="#Top">(Go to Top)</A>
</tr> </TD>
<TR>
</TABLE></DIV> <TH class='rh'><A NAME='Round2' style='color: black'>Round 2 (06-01-2019)</A></TH>
</TR>
<P align='center'><A href='#Top'><FONT size='-1'>Top of Page</FONT></A> <TR>
</TABLE> <TD><PRE>
<!-- ========= --> 1 Libpairtwo Player 1 ( 4) <b>0-1 </b>Libpairtwo Player 2 ( 3)
<!-- COPYRIGHT --> 2 Libpairtwo Player 3 ( 2) <font color='red'> Bye</font>
<!-- ========= --> Libpairtwo Player 4 ( 1)<font color='red'> Absent </font>
<p><TABLE border='0'> </pre>
<TR><TD align='center' bgColor='#000090'>
<FONT color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></TD> <A HREF="#Top">(Go to Top)</A>
<TD align='center' bgColor='#000090'> </TD>
<FONT color='white' size='-1'><b>PairTwo 6.13 (2015/08/10)</b></font></td></tr> <TR>
</TD></TR></TABLE></p> <TH class='rh'><A NAME='Round3' style='color: black'>Round 3 (11-01-2019)</A></TH>
</body></html> </TR>
<TR>
<TD><PRE>
1 Libpairtwo Player 4 ( 1) <b><EFBFBD>-<2D> </b>Libpairtwo Player 1 ( 4)
2 Libpairtwo Player 2 ( 3) <font color='red'> Bye</font>
Libpairtwo Player 3 ( 2)<font color='red'> Absent </font>
</pre>
<A HREF="#Top">(Go to Top)</A>
</TD>
</table>
</div>
<!-- ================= -->
<!-- GRILLE AMERICAINE -->
<!-- ================= -->
<DIV ALIGN='CENTER'>
<TABLE align='center' bgcolor='#ffffdd' border='1'>
<TR>
<TH colspan='14'>
<FONT size='+2'>American Ranking</FONT>
<A name=Americaine></A></TH>
</TR>
<TR bgcolor='#cccccc'>
<TD class='thr'>&nbsp;</TD>
<TD class='thl'><B>Name</B></TD>
<TD class='thr'><B>Rating</B></TD>
<TD class='thr'><B> Pts</B></TD>
<TD class='thr'><B>Perf </B></TD>
<TD class='thc'><B>R1</B></TD>
<TD class='thc'><B>R2</B></TD>
<TD class='thc'><B>R3</B></TD>
<TD class='thr'><b><i>Res </i></b></TD>
<TD class='thr'><b><i>Vic </i></b></TD>
<TD class='thr'><b><i>#Bla</i></b></TD>
<TD class='thr'><b><i>BC1 </i></b></TD>
<TD class='thr'><b><i>S B </i></b></TD>
</tr>
<tr>
<td bgcolor='#eeeeee' class='tdr'> 1</td>
<td bgcolor='#eeeeee' class='tdl'><B>Libpairtwo Player 2 (FM)</B></td>
<td bgcolor='#eeeeee' class='tdr'>1802</td>
<td bgcolor='#eeeeee' class='tdr'><B>3.0</B></td>
<td bgcolor='#eeeeee' class='tdr'><i>2602</i></td>
<td bgcolor='#eeeeee' class='tdc'> 4W +</td>
<td bgcolor='#eeeeee' class='tdc'> 2B +</td>
<td bgcolor='#eeeeee' class='tdc'>bye</td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.00</i></td>
</tr>
<tr>
<td bgcolor='#cccccc' class='tdr'> 2</td>
<td bgcolor='#cccccc' class='tdl'><B>Libpairtwo Player 1 (*)</B></td>
<td bgcolor='#cccccc' class='tdr'>1801</td>
<td bgcolor='#cccccc' class='tdr'><B>1.5</B></td>
<td bgcolor='#cccccc' class='tdr'><i>1810</i></td>
<td bgcolor='#cccccc' class='tdc'> 3B +</td>
<td bgcolor='#cccccc' class='tdc'> 1W -</td>
<td bgcolor='#cccccc' class='tdc'> 4B =</td>
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td bgcolor='#cccccc' class='tdc'><i> 0.00</i></td>
</tr>
<tr>
<td bgcolor='#eeeeee' class='tdr'> 3</td>
<td bgcolor='#eeeeee' class='tdl'><B>Libpairtwo Player 3 (IM)</B></td>
<td bgcolor='#eeeeee' class='tdr'>1803</td>
<td bgcolor='#eeeeee' class='tdr'><B>1.0</B></td>
<td bgcolor='#eeeeee' class='tdr'><i>1331</i></td>
<td bgcolor='#eeeeee' class='tdc'> 2W -</td>
<td bgcolor='#eeeeee' class='tdc'>bye</td>
<td bgcolor='#eeeeee' class='tdc'>...</td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.00</i></td>
</tr>
<tr>
<td bgcolor='#cccccc' class='tdr'> 4</td>
<td bgcolor='#cccccc' class='tdl'><B>Libpairtwo Player 4 (GM)</B></td>
<td bgcolor='#cccccc' class='tdr'>1804</td>
<td bgcolor='#cccccc' class='tdr'><B>0.5</B></td>
<td bgcolor='#cccccc' class='tdr'><i>1626</i></td>
<td bgcolor='#cccccc' class='tdc'> 1B -</td>
<td bgcolor='#cccccc' class='tdc'>...</td>
<td bgcolor='#cccccc' class='tdc'> 2W =</td>
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td bgcolor='#cccccc' class='tdc'><i> 0.00</i></td>
</tr>
</TABLE>
</DIV>
<P align='center'><A href='#Top'><FONT size='-1'>Top of Page</FONT></A>
</TABLE>
<!-- ========= -->
<!-- COPYRIGHT -->
<!-- ========= -->
<p>
<TABLE border='0'>
<TR>
<TD align='center' bgColor='#000090'>
<FONT color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></TD>
<TD align='center' bgColor='#000090'>
<FONT color='white' size='-1'><b>PairTwo 6.13 (2015/08/10)</b></font></td>
</tr>
</TD></TR></TABLE>
</p>
</body>
</html>

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Class Constants * Class Constants
* *
* Static class for constants * Static class for constants
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo; namespace JeroenED\Libpairtwo;
@ -20,18 +21,35 @@ use JeroenED\Libpairtwo\Enums\Result;
* *
* Static class for constants * Static class for constants
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Constants class Constants
{ {
const Won = [ Result::Won, Result::WonForfait, Result::WonBye, Result::WonAdjourned ]; public const BLACK = [Color::BLACK];
const Draw = [ Result::Draw, Result::DrawAdjourned ];
const Lost = [ Result::Absent, Result::Bye, Result::Lost, Result::Adjourned ]; public const DRAW = [Result::DRAW, Result::DRAW_ADJOURNED];
const NotPlayed = [ Result::Bye, Result::WonBye, Result::Absent ];
const Played = [ Result::Won, Result::WonForfait, Result::WonBye, Result::WonAdjourned, Result::Draw, Result::DrawAdjourned, Result::Absent, Result::Bye, Result::Lost, Result::Adjourned ]; public const LOST = [Result::ABSENT, Result::BYE, Result::LOST, Result::ADJOURNED];
const Black = [ Color::Black ];
const White = [ Color::White ]; public const NOTPLAYED = [Result::BYE, Result::WON_BYE, Result::ABSENT];
public const PLAYED = [
Result::WON,
Result::WON_FORFAIT,
Result::WON_BYE,
Result::WON_ADJOURNED,
Result::DRAW,
Result::DRAW_ADJOURNED,
Result::ABSENT,
Result::BYE,
Result::LOST,
Result::ADJOURNED
];
public const WHITE = [Color::WHITE];
public const WON = [Result::WON, Result::WON_FORFAIT, Result::WON_BYE, Result::WON_ADJOURNED];
} }

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Enum Color * Enum Color
* *
* List of all compatible colors * List of all compatible colors
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Enums; namespace JeroenED\Libpairtwo\Enums;
@ -19,14 +20,16 @@ use MyCLabs\Enum\Enum;
* *
* List of all compatible colors * List of all compatible colors
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Color extends Enum class Color extends Enum
{ {
const Black = 'B'; public const BLACK = 'B';
const White = 'W';
const None = '*'; public const NONE = '*';
public const WHITE = 'W';
} }

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Enum Gameresult * Enum Gameresult
* *
* List of all compatible gameresults * List of all compatible gameresults
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Enums; namespace JeroenED\Libpairtwo\Enums;
@ -19,24 +20,36 @@ use MyCLabs\Enum\Enum;
* *
* List of all compatible gameresults * List of all compatible gameresults
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Gameresult extends Enum class Gameresult extends Enum
{ {
const None = '-'; public const BLACK_WINS = '0-1';
const WhiteWins = '1-0';
const Draw = '0.5-0.5'; public const BLACK_WINS_FORFAIT = '0-1 FF';
const BlackWins = '0-1';
const WhiteWinsForfait = '1-0 FF'; public const BOTH_LOSE_FORFAIT = '0-0 FF';
const BlackWinsForfait = '0-1 FF';
const BothLoseForfait = '0-0 FF'; public const BOTH_WIN_ADJOURNED = '1-1 A';
const BothWinAdjourned = '1-1 A';
const WhiteWinsBlackDrawsAdjourned = '1-0.5 A'; public const DRAW = '0.5-0.5';
const WhiteDrawsBlackWinsAdjourned = '0.5-1 A';
const DrawAdjourned = '0.5-0.5 A'; public const DRAW_ADJOURNED = '0.5-0.5 A';
const WhiteLoseBlackDrawsAdjourned = '0-0.5';
const WhiteDrawsBlackLoseAdjourned = '0.5-0'; public const NONE = '-';
public const WHITE_DRAWS_BLACK_LOSE_ADJOURNED = '0.5-0';
public const WHITE_DRAWS_BLACK_WINS_ADJOURNED = '0.5-1 A';
public const WHITE_LOST_BLACK_DRAWS_ADJOURNED = '0-0.5';
public const WHITE_WINS = '1-0';
public const WHITE_WINS_BLACK_DRAWS_ADJOURNED = '1-0.5 A';
public const WHITE_WINS_FORFAIT = '1-0 FF';
} }

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Enum Gender * Enum Gender
* *
* List of all compatible genders * List of all compatible genders
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Enums; namespace JeroenED\Libpairtwo\Enums;
@ -19,14 +20,16 @@ use MyCLabs\Enum\Enum;
* *
* List of all compatible genders * List of all compatible genders
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Gender extends Enum class Gender extends Enum
{ {
const Neutral = 'X'; // Unforturnately, Incompatible with Pairtwo (Dinos) public const FEMALE = 'F';
const Male = 'M';
const Female = 'F'; public const MALE = 'M';
public const NEUTRAL = 'X'; // Unfortunately, Incompatible with Pairtwo (Dinos)
} }

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Enum Result * Enum Result
* *
* List of all compatible results * List of all compatible results
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Enums; namespace JeroenED\Libpairtwo\Enums;
@ -19,22 +20,32 @@ use MyCLabs\Enum\Enum;
* *
* List of all compatible results * List of all compatible results
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Result extends Enum class Result extends Enum
{ {
const None = '*'; public const ABSENT = '0 FF';
const Lost = '0';
const Draw = '0.5'; public const ADJOURNED = '0 A';
const Won = '1';
const Absent = '0 FF'; public const BYE = '0 Bye';
const WonForfait = '1 FF';
const Adjourned = '0 A'; public const DRAW = '0.5';
const DrawAdjourned = '0.5 A';
const WonAdjourned = '1 A'; public const DRAW_ADJOURNED = '0.5 A';
const Bye = '0 Bye';
const WonBye = '1 Bye'; public const LOST = '0';
public const NONE = '*';
public const WON = '1';
public const WON_ADJOURNED = '1 A';
public const WON_BYE = '1 Bye';
public const WON_FORFAIT = '1 FF';
} }

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Enum Tiebreak * Enum Tiebreak
* *
* List of all compatible tiebreaks * List of all compatible tiebreaks
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Enums; namespace JeroenED\Libpairtwo\Enums;
@ -19,34 +20,56 @@ use MyCLabs\Enum\Enum;
* *
* List of all compatible tiebreaks * List of all compatible tiebreaks
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Tiebreak extends Enum class Tiebreak extends Enum
{ {
const None = ""; public const ARO = "Average Rating";
const Keizer = "Keizer";
const Points = "Points"; public const AROCUT = "Average Rating Cut";
const Buchholz = "Buchholz";
const BuchholzMed = "Buchholz Median"; public const AVERAGE_PERFORMANCE = "Average performance";
const BuchholzCut = "Buchholz Cut";
const BuchholzMed2 = "Buchholz Median 2"; public const BAUMBACH = "Most wins"; // Ref: https://en.wikipedia.org/wiki/Tie-breaking_in_Swiss-system_tournaments#Most_wins_(Baumbach) Please tell me why?
const BuchholzCut2 = "Buchholz Cut 2";
const Sonneborn = "Sonneborn-Berger"; public const BETWEEN = "Mutual Result";
const Kashdan = "Kashdan";
const SoccerKashdan = "Soccer Kashdan"; public const BLACK_PLAYED = "Black played";
const Cumulative = "Cumulative";
const Between = "Mutual Result"; public const BLACK_WIN = "Black Winned";
const Koya = "Koya";
const Baumbach = "Most wins"; // Ref: https://en.wikipedia.org/wiki/Tie-breaking_in_Swiss-system_tournaments#Most_wins_(Baumbach) Please tell me why? public const BUCHHOLZ = "Buchholz";
const AveragePerformance = "Average performance";
const Performance = "Performance"; public const BUCHHOLZ_CUT = "Buchholz Cut";
const Aro = "Average Rating";
const AroCut = "Average Rating Cut"; public const BUCHHOLZ_CUT_2 = "Buchholz Cut 2";
const BlackPlayed = "Black played";
const BlackWin = "Black Winned"; public const BUCHHOLZ_MED = "Buchholz Median";
const Testmatch = "Testmatch";
const Drawing = "Drawing of lot"; public const BUCHHOLZ_MED_2 = "Buchholz Median 2";
public const CUMULATIVE = "Cumulative";
public const DRAWING_OF_LOT = "Drawing of lot";
public const KASHDAN = "Kashdan";
public const KEIZER = "Keizer";
public const KOYA = "Koya";
public const NONE = "";
public const PERFORMANCE = "Performance";
public const POINTS = "Points";
public const SOCCER_KASHDAN = "Soccer Kashdan";
public const SONNEBORN = "Sonneborn-Berger";
public const TESTMATCH = "Testmatch";
} }

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Enum Title * Enum Title
* *
* List of all compatible titles * List of all compatible titles
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Enums; namespace JeroenED\Libpairtwo\Enums;
@ -19,24 +20,36 @@ use MyCLabs\Enum\Enum;
* *
* List of all compatible titles * List of all compatible titles
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Title extends Enum class Title extends Enum
{ {
const NONE = '*'; public const CM = 'Candidate Master';
const ELO = 'Elo';
const NM = 'National Master'; public const ELO = 'Elo';
const WCM = 'Woman Candidate Master';
const WFM = 'Woman Fide Master'; public const FM = 'Fide Master';
const CM = 'Candidate Master';
const WIM = 'Woman International Master'; public const GM = 'Grand Master';
const FM = 'Fide Master';
const WGM = 'Woman Grand Master'; public const HG = 'Honorary Grand Master';
const HM = 'Honorary International Master';
const IM = 'International Master'; public const HM = 'Honorary International Master';
const HG = 'Honorary Grand Master';
const GM = 'Grand Master'; public const IM = 'International Master';
public const NM = 'National Master';
public const NONE = '*';
public const WCM = 'Woman Candidate Master';
public const WFM = 'Woman Fide Master';
public const WGM = 'Woman Grand Master';
public const WIM = 'Woman International Master';
} }

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Enum TournamentSystem * Enum TournamentSystem
* *
* List of all compatible tournament systems * List of all compatible tournament systems
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Enums; namespace JeroenED\Libpairtwo\Enums;
@ -19,15 +20,18 @@ use MyCLabs\Enum\Enum;
* *
* List of all compatible tournament systems * List of all compatible tournament systems
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class TournamentSystem extends Enum class TournamentSystem extends Enum
{ {
const Swiss = 'Swiss'; public const AMERICAN = 'American';
const Closed = 'Closed';
const American = 'American'; public const CLOSED = 'Closed';
const Keizer = 'Keizer';
public const KEIZER = 'Keizer';
public const SWISS = 'Swiss';
} }

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Exception IncompatibleReaderException * Exception IncompatibleReaderException
* *
* Exception to be raised when a reader is used that is incompatible * Exception to be raised when a reader is used that is incompatible
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Exceptions; namespace JeroenED\Libpairtwo\Exceptions;
@ -17,10 +18,10 @@ namespace JeroenED\Libpairtwo\Exceptions;
* *
* Exception to be raised when a reader is used that is incompatible * Exception to be raised when a reader is used that is incompatible
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class IncompatibleReaderException extends LibpairtwoException class IncompatibleReaderException extends LibpairtwoException
{ {

View File

@ -1,27 +1,30 @@
<?php <?php
/** /**
* Exception LibpairtwoException * Exception LibpairtwoException
* *
* General exception when something goes wrong with libpairtwo * General exception when something goes wrong with libpairtwo
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Exceptions; namespace JeroenED\Libpairtwo\Exceptions;
use Exception;
/** /**
* Exception LibpairtwoException * Exception LibpairtwoException
* *
* General exception when something goes wrong with libpairtwo * General exception when something goes wrong with libpairtwo
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class LibpairtwoException extends \Exception class LibpairtwoException extends Exception
{ {
} }

View File

@ -1,54 +1,39 @@
<?php <?php
/** /**
* Class Games * Class Games
* *
* Class for a game of the tournament * Class for a game of the tournament
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo; namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Enums\Gameresult; use JeroenED\Libpairtwo\Enums\Gameresult;
use JeroenED\Libpairtwo\Pairing;
use DateTime;
/** /**
* Class Games * Class Games
* *
* Class for a game of the tournament * Class for a game of the tournament
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Game class Game
{ {
/** /**
* The pairing for this games as seen from white's side * The pairing for this games as seen from black's side
*
* @var Pairing | null
*/
public $White;
/**
* The pairing for this games as seen from blacks's side
* *
* @var Pairing | null * @var Pairing | null
*/ */
public $Black; public $Black;
/**
* The calculated game result
*
* @var GameResult | null
*/
private $CalculatedResult;
/** /**
* The board where this game is held * The board where this game is held
* *
@ -56,10 +41,26 @@ class Game
*/ */
public $Board; public $Board;
/**
* The calculated game result
*
* @var GameResult | null
*/
private $CalculatedResult;
/**
* The pairing for this games as seen from white's side
*
* @var Pairing | null
*/
public $White;
/** /**
* Returns fields that were not directly assigned. * Returns fields that were not directly assigned.
* Class Game contains the special field Result containing the result of the game * Class Game contains the special field Result containing the result of the game
*
* @param string $key * @param string $key
*
* @return Gameresult * @return Gameresult
*/ */
public function __get(string $key) public function __get(string $key)
@ -67,6 +68,7 @@ class Game
if ($key == 'Result') { if ($key == 'Result') {
return $this->calculateResult(); return $this->calculateResult();
} }
return null; return null;
} }
@ -88,20 +90,20 @@ class Game
$whitesplit = explode(" ", $whiteResult); $whitesplit = explode(" ", $whiteResult);
$blacksplit = explode(" ", $blackResult); $blacksplit = explode(" ", $blackResult);
$special=''; $special = '';
if (isset($whitesplit[1]) && $whitesplit[1] != 'Bye') { if (isset($whitesplit[ 1 ]) && $whitesplit[ 1 ] != 'Bye') {
$special = ' ' . $whitesplit[1]; $special = ' ' . $whitesplit[ 1 ];
} }
if (isset($blacksplit[1]) && $blacksplit[1] != 'Bye') { if (isset($blacksplit[ 1 ]) && $blacksplit[ 1 ] != 'Bye') {
$special = ' ' . $blacksplit[1]; $special = ' ' . $blacksplit[ 1 ];
} }
if ($whitesplit[0] == '*') { if ($whitesplit[ 0 ] == '*') {
$whitesplit[0] = ''; $whitesplit[ 0 ] = '';
} }
if ($blacksplit[0] == '*') { if ($blacksplit[ 0 ] == '*') {
$blacksplit[0] = ''; $blacksplit[ 0 ] = '';
} }
$result = new Gameresult($whitesplit[0] . '-' . $blacksplit[0] . $special); $result = new Gameresult($whitesplit[ 0 ] . '-' . $blacksplit[ 0 ] . $special);
$this->CalculatedResult = $result; $this->CalculatedResult = $result;
return $result; return $result;
@ -111,6 +113,7 @@ class Game
* Checks if 2 games are equal * Checks if 2 games are equal
* *
* @param Game $game * @param Game $game
*
* @return bool * @return bool
*/ */
public function equals(Game $game): bool public function equals(Game $game): bool
@ -118,6 +121,6 @@ class Game
return ( return (
$this->White->Player === $game->White->Player && $this->White->Player === $game->White->Player &&
$this->Black->Player === $game->Black->Player && $this->Black->Player === $game->Black->Player &&
$this->Result == $game->Result); $this->Result->getKey() == $game->Result->getKey());
} }
} }

View File

@ -1,30 +1,30 @@
<?php <?php
/** /**
* Class IOFactory * Class IOFactory
* *
* Class for creating readers for pairing files * Class for creating readers for pairing files
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo; namespace JeroenED\Libpairtwo;
use JeroenED\LibPairtwo\Exceptions\LibpairtwoException; use JeroenED\LibPairtwo\Exceptions\LibpairtwoException;
use JeroenED\Libpairtwo\Interfaces\ReaderInterface; use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
use JeroenED\Libpairtwo\Readers\Pairtwo6;
/** /**
* Class IOFactory * Class IOFactory
* *
* Class for creating readers for pairing files * Class for creating readers for pairing files
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
abstract class IOFactory abstract class IOFactory
{ {
@ -34,31 +34,30 @@ abstract class IOFactory
* @var array * @var array
*/ */
private static $Readers = [ private static $Readers = [
'Swar-4' => Readers\Swar4::class, 'Swar-4' => Readers\Swar4::class,
'Pairtwo-6' => Readers\Pairtwo6::class, 'Pairtwo-6' => Readers\Pairtwo6::class,
'Pairtwo-5' => Readers\Pairtwo6::class // File structure identical 'Pairtwo-5' => Readers\Pairtwo6::class // File structure identical
]; ];
/** /**
* Creates a reader for $type * Creates a reader for $type
* *
* Compatible types are Swar-4, Pairtwo-5, Pairtwo-6 * Compatible types are Swar-4, Pairtwo-5, Pairtwo-6
* *
* @param string $type * @param string $type
*
* @return ReaderInterface * @return ReaderInterface
* @throws LibpairtwoException * @throws LibpairtwoException
*/ */
public static function createReader(string $type): ReaderInterface public static function createReader(string $type): ReaderInterface
{ {
if (!isset(self::$Readers[$type])) { if (!isset(self::$Readers[ $type ])) {
throw new LibpairtwoException("Cannot read type $type"); throw new LibpairtwoException("Cannot read type $type");
} }
// create reader class // create reader class
$readerClass = self::$Readers[$type]; $readerClass = self::$Readers[ $type ];
$reader = new $readerClass;
return $reader; return new $readerClass();
} }
} }

View File

@ -1,36 +1,36 @@
<?php <?php
/** /**
* Interface ReaderInterface * Interface ReaderInterface
* *
* Sets the methods a reader needs to implement * Sets the methods a reader needs to implement
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Interfaces; namespace JeroenED\Libpairtwo\Interfaces;
use JeroenED\Libpairtwo\Tournament;
/** /**
* Interface ReaderInterface * Interface ReaderInterface
* *
* Sets the methods a reader needs to implement * Sets the methods a reader needs to implement
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
interface ReaderInterface interface ReaderInterface
{ {
/** /**
* Reads out $filename * Reads out $filename
* *
* @param $filename * @param $filename
* @return ReaderInterface *
* @return void
*/ */
public function read(string $filename): void; public function read(string $filename): void;
} }

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Class Pairing * Class Pairing
* *
* Class for a pairing of the tournament * Class for a pairing of the tournament
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo; namespace JeroenED\Libpairtwo;
@ -20,26 +21,19 @@ use JeroenED\Libpairtwo\Enums\Result;
* *
* Class for a pairing of the tournament * Class for a pairing of the tournament
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Pairing class Pairing
{ {
/** /**
* The player of the pairing. Please note this means the pairing was seen from the point of view of this player * The number of the board where the game was held
* *
* @var Player | null * @var int
*/ */
public $Player; public $Board;
/**
* The opponent of player
*
* @var Player | null
*/
public $Opponent;
/** /**
* The color of the player. * The color of the player.
@ -49,8 +43,23 @@ class Pairing
*/ */
public $Color; public $Color;
/**
* The opponent of player
*
* @var Player | null
*/
public $Opponent;
/**
* The player of the pairing. Please note this means the pairing was seen from the point of view of this player
*
* @var Player | null
*/
public $Player;
/** /**
* The result of the Game. Possible values contain Won, Lost, Draw, Forfait, Bye, etc. * The result of the Game. Possible values contain Won, Lost, Draw, Forfait, Bye, etc.
*
* @var Result * @var Result
*/ */
public $Result; public $Result;
@ -61,11 +70,4 @@ class Pairing
* @var int * @var int
*/ */
public $Round; public $Round;
/**
* The number of the board where the game was held
*
* @var int
*/
public $Board;
} }

View File

@ -1,53 +1,48 @@
<?php <?php
/** /**
* Class Player * Class Player
* *
* Class for a player of the tournament * Class for a player of the tournament
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo; namespace JeroenED\Libpairtwo;
use DateTime;
use JeroenED\Libpairtwo\Enums\Gender; use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Title; use JeroenED\Libpairtwo\Enums\Title;
use DateTime;
/** /**
* Class Player * Class Player
* *
* Class for a player of the tournament * Class for a player of the tournament
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Player class Player
{ {
/** /**
* Name of the player * Binary data that was read out of the pairing file
*
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
/**
* The category the player belongs to
* *
* @var string * @var string
*/ */
public $Name; public $Category;
/**
* The player ids for the player. Possible keys are, but not limited to nation and fide
*
* @var int[]
*/
public $Ids;
/**
* The Elos for the player. Possible keys are, but not limited to nation and fide
*
* @var int[]
*/
public $Elos;
/** /**
* Birthday of the player * Birthday of the player
@ -57,33 +52,11 @@ class Player
public $DateOfBirth; public $DateOfBirth;
/** /**
* Tiebreak points of the player. These values are calculated when Tournament->Ranking is called * The Elos for the player. Possible keys are, but not limited to nation and fide
* *
* @var float[] * @var int[]
*/ */
public $Tiebreaks = []; public $Elos;
/**
* The nation the player belongs to. Be noted this does not actually mean this is his main nationality. A player can be signed USCF but may be Italian
*
* @var string
*/
public $Nation;
// TODO: Implement categories
/**
* The category the player belongs to
*
* @var string
*/
public $Category;
/**
* The title of the player. Possible values can be GM, IM, IA, etc.
*
* @var Title
*/
public $Title;
/** /**
* The gender of the player. Possible values contain Male, Female and Neutral * The gender of the player. Possible values contain Male, Female and Neutral
@ -92,6 +65,30 @@ class Player
*/ */
public $Gender; public $Gender;
/**
* The player ids for the player. Possible keys are, but not limited to nation and fide
*
* @var int[]
*/
public $Ids;
// TODO: Implement categories
/**
* Name of the player
*
* @var string
*/
public $Name;
/**
* The nation the player belongs to. Be noted this does not actually mean this is his main nationality. A player
* can be signed USCF but may be Italian
*
* @var string
*/
public $Nation;
/** /**
* The pairings of the player * The pairings of the player
* *
@ -100,12 +97,112 @@ class Player
public $Pairings = []; public $Pairings = [];
/** /**
* Binary data that was read out of the pairing file * Tiebreak points of the player. These values are calculated when Tournament->Ranking is called
* *
* @var bool|DateTime|int|string[] * @var float[]
*/ */
public $Tiebreaks = [];
private $BinaryData; /**
* The title of the player. Possible values can be GM, IM, IA, etc.
*
* @var Title
*/
public $Title;
/**
* Returns the performance rating of the player
*
* WARNING: Calculation currently incorrect. Uses the rule of 400 as temporary solution
*
* @param $type
* @param $unratedElo
*
* @return float
*/
public function Performance(string $type, int $unratedElo): float
{
$total = 0;
$opponents = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::NOTPLAYED) === false) {
$opponentElo = $pairing->Opponent->getElo($type);
$opponentElo = $opponentElo != 0 ? $opponentElo : $unratedElo;
if (array_search($pairing->Result, Constants::WON) !== false) {
$total += $opponentElo + 400;
} elseif (array_search($pairing->Result, Constants::LOST) !== false) {
$total += $opponentElo - 400;
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$total += $opponentElo;
}
$opponents++;
}
}
return round($total / $opponents);
}
/**
* Returns an array of Player objects where name matches $search
*
* @param string $search
* @param Tournament $tournament
*
* @return Player[]
*/
public static function PlayersByName(string $search, Tournament $tournament): array
{
/**
* @var Player[]
*/
$players = $tournament->Players;
/**
* @var Player[]
*/
$return = [];
foreach ($players as $player) {
if (fnmatch($search, $player->Name)) {
$return[] = $player;
}
}
return $return;
}
/**
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
*
* @param string $key
*
* @return bool|DateTime|int|string|null
*/
public function __get(string $key)
{
if ($key == 'PlayedGames') {
return $this->playedGames();
} elseif ($key == 'NoOfWins') {
return $this->noOfWins();
} elseif ($key == 'Opponents') {
return $this->opponents();
} elseif (isset($this->BinaryData[ $key ])) {
return $this->BinaryData[ $key ];
}
return null;
}
/**
* Sets binary data that is read out the pairing file but is not needed immediately
*
* @param string $key
* @param bool|int|DateTime|string $value
*/
public function __set(string $key, $value): void
{
$this->BinaryData[ $key ] = $value;
}
/** /**
* Adds a pairing to the tournament * Adds a pairing to the tournament
@ -119,97 +216,6 @@ class Player
$this->Pairings = $newArray; $this->Pairings = $newArray;
} }
/**
* Returns an array of Player objects where name matches $search
*
* @param string $search
* @param Tournament $tournament
* @return Player[]
*/
public static function PlayersByName(string $search, Tournament $tournament): array
{
/** @var Player[] */
$players = $tournament->Players;
/** @var Player[] */
$return = [];
foreach ($players as $player) {
if (fnmatch($search, $player->Name)) {
$return[] = $player;
}
}
return $return;
}
/**
* Returns the elo of elotype for the player
* @param string $type
* @return int
*/
public function getElo(string $type): int
{
return $this->Elos[$type];
}
/**
* Sets the elo of elotype for the player
*
* @param string $type
* @param int $value
*/
public function setElo(string $type, int $value): void
{
$currentElos = $this->Elos;
$currentElos[$type] = $value;
$this->Elos = $currentElos;
}
/**
* Returns the identifier of type for the player
*
* Common possible values are Fide or National
*
* @param string $type
* @return string
*/
public function getId(string $type): string
{
return $this->Ids[$type];
}
/**
* Sets the identifier of type for the player
*
* Common possible values are Fide or National
*
* @param string $type
* @param string $value
*/
public function setId(string $type, string $value): void
{
$currentIds = $this->Ids;
$currentIds[$type] = $value;
$this->Ids = $currentIds;
}
/**
* Returns the number of won matches for the player
*
* @return int
*/
private function noOfWins(): int
{
$wins = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::Won) !== false) {
$wins++;
}
}
return $wins;
}
/** /**
* Returns the points of the player after round $round * Returns the points of the player after round $round
* *
@ -218,39 +224,25 @@ class Player
* 0 points are awarded for loss * 0 points are awarded for loss
* *
* @param int $round * @param int $round
*
* @return float * @return float
*/ */
public function calculatePoints(int $round = -1): float public function calculatePoints(int $round = -1): float
{ {
$points = 0; $points = 0;
foreach ($this->Pairings as $key=>$pairing) { foreach ($this->Pairings as $key => $pairing) {
if ($key < $round || $round == -1) { if ($key < $round || $round == -1) {
if (array_search($pairing->Result, Constants::Won) !== false) { if (array_search($pairing->Result, Constants::WON) !== false) {
$points = $points + 1; $points = $points + 1;
} elseif (array_search($pairing->Result, Constants::Draw) !== false) { } elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$points = $points + 0.5; $points = $points + 0.5;
} }
} }
} }
return $points; return $points;
} }
/**
* Returns the points of a virtual player as described in the Fide Handbook C.02 chapter 13.15.2.
*
* Return the same score for all rounds until $byeround and added with a half point for each subsequent round
*
* @param int $byeround
* @return float
*/
public function calculatePointsForVirtualPlayer(int $byeround): float
{
$points = $this->calculatePoints($byeround);
foreach (array_slice($this->Pairings, $byeround +1) as $key=>$pairing) {
$points += 0.5;
}
return $points;
}
/** /**
* Returns the points of the player that should be used for tiebreaking systems. * Returns the points of the player that should be used for tiebreaking systems.
* *
@ -264,74 +256,75 @@ class Player
{ {
$points = 0; $points = 0;
foreach ($this->Pairings as $pairing) { foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::NotPlayed) !== false) { if (array_search($pairing->Result, Constants::NOTPLAYED) !== false) {
$points = $points + 0.5; $points = $points + 0.5;
} elseif (array_search($pairing->Result, Constants::Won) !== false) { } elseif (array_search($pairing->Result, Constants::WON) !== false) {
$points = $points + 1; $points = $points + 1;
} elseif (array_search($pairing->Result, Constants::Draw) !== false) { } elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$points = $points + 0.5; $points = $points + 0.5;
} }
} }
return $points; return $points;
} }
/** /**
* Returns the performance rating of the player * Returns the points of a virtual player as described in the Fide Handbook C.02 chapter 13.15.2.
* *
* WARNING: Calculation currently incorrect. Uses the rule of 400 as temporary solution * Return the same score for all rounds until $byeround and added with a half point for each subsequent round
* *
* @param $type * @param int $byeround
* @param $unratedElo *
* @return int * @return float
*/ */
public function Performance(string $type, int $unratedElo): float public function calculatePointsForVirtualPlayer(int $byeround): float
{ {
$total = 0; $points = $this->calculatePoints($byeround);
$opponents = 0; foreach (array_slice($this->Pairings, $byeround + 1) as $key => $pairing) {
foreach ($this->Pairings as $pairing) { $points += 0.5;
if (array_search($pairing->Result, Constants::NotPlayed) === false) {
$opponentElo = $pairing->Opponent->getElo($type);
$opponentElo = $opponentElo != 0 ? $opponentElo : $unratedElo;
if (array_search($pairing->Result, Constants::Won) !== false) {
$total += $opponentElo + 400;
} elseif (array_search($pairing->Result, Constants::Lost) !== false) {
$total += $opponentElo - 400;
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
$total += $opponentElo;
}
$opponents++;
}
} }
return round($total / $opponents);
return $points;
} }
/** /**
* Returns the number of played games of the player * Returns the elo of elotype for the player
*
* @param string $type
* *
* @return int * @return int
*/ */
private function playedGames(): int public function getElo(string $type): int
{ {
$total = 0; return $this->Elos[ $type ];
foreach ($this->Pairings as $pairing) { }
if (array_search($pairing->Result, Constants::Played) !== false) {
$total++; /**
} * Returns the identifier of type for the player
} *
return $total; * Common possible values are Fide or National
*
* @param string $type
*
* @return string
*/
public function getId(string $type): string
{
return $this->Ids[ $type ];
} }
/** /**
* Returns if player has played against all players of the array * Returns if player has played against all players of the array
* *
* @param Player[] $players * @param Player[] $players
*
* @return bool * @return bool
*/ */
public function hasPlayedAllPlayersOfArray(array $players): bool public function hasPlayedAllPlayersOfArray(array $players): bool
{ {
$ownkey = array_search($this, $players); $ownkey = array_search($this, $players);
if ($ownkey !== false) { if ($ownkey !== false) {
unset($players[$ownkey]); unset($players[ $ownkey ]);
} }
$total = 0; $total = 0;
foreach ($players as $player) { foreach ($players as $player) {
@ -343,6 +336,23 @@ class Player
return $total == count($players); return $total == count($players);
} }
/**
* Returns the number of won matches for the player
*
* @return int
*/
private function noOfWins(): int
{
$wins = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::WON) !== false) {
$wins++;
}
}
return $wins;
}
/** /**
* Returns all opponents of $this * Returns all opponents of $this
* *
@ -350,43 +360,58 @@ class Player
*/ */
private function opponents() private function opponents()
{ {
$return = array(); $return = [];
foreach ($this->Pairings as $pairing) { foreach ($this->Pairings as $pairing) {
if (!empty($pairing->Opponent)) { if (!empty($pairing->Opponent)) {
$return[] = $pairing->Opponent; $return[] = $pairing->Opponent;
} }
} }
return $return; return $return;
} }
/** /**
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields * Returns the number of played games of the player
* *
* @param string $key * @return int
* @return bool|DateTime|int|string|null
*/ */
public function __get(string $key) private function playedGames(): int
{ {
if ($key == 'PlayedGames') { $total = 0;
return $this->playedGames(); foreach ($this->Pairings as $pairing) {
} elseif ($key == 'NoOfWins') { if (array_search($pairing->Result, Constants::PLAYED) !== false) {
return $this->noOfWins(); $total++;
} elseif ($key == 'Opponents') { }
return $this->opponents();
} elseif (isset($this->BinaryData[$key])) {
return $this->BinaryData[$key];
} }
return null;
return $total;
} }
/** /**
* Sets binary data that is read out the pairing file but is not needed immediately * Sets the elo of elotype for the player
* *
* @param string $key * @param string $type
* @param bool|int|DateTime|string $value * @param int $value
*/ */
public function __set(string $key, $value): void public function setElo(string $type, int $value): void
{ {
$this->BinaryData[$key] = $value; $currentElos = $this->Elos;
$currentElos[ $type ] = $value;
$this->Elos = $currentElos;
}
/**
* Sets the identifier of type for the player
*
* Common possible values are Fide or National
*
* @param string $type
* @param string $value
*/
public function setId(string $type, string $value): void
{
$currentIds = $this->Ids;
$currentIds[ $type ] = $value;
$this->Ids = $currentIds;
} }
} }

View File

@ -1,18 +1,20 @@
<?php <?php
/** /**
* Reader Pairtwo6 * Reader Pairtwo6
* *
* Reads out Pairtwo-6 and Pairtwo-5 files * Reads out Pairtwo-6 and Pairtwo-5 files
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Readers; namespace JeroenED\Libpairtwo\Readers;
use DateTime;
use InvalidArgumentException;
use JeroenED\Libpairtwo\Enums\Color; use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Gender; use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Result; use JeroenED\Libpairtwo\Enums\Result;
@ -25,25 +27,35 @@ use JeroenED\Libpairtwo\Pairing;
use JeroenED\Libpairtwo\Player; use JeroenED\Libpairtwo\Player;
use JeroenED\Libpairtwo\Round; use JeroenED\Libpairtwo\Round;
use JeroenED\Libpairtwo\Tournament; use JeroenED\Libpairtwo\Tournament;
use DateTime;
/** /**
* Reader Pairtwo6 * Reader Pairtwo6
* *
* Reads out Pairtwo-6 files * Reads out Pairtwo-6 files
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Pairtwo6 implements ReaderInterface class Pairtwo6 implements ReaderInterface
{ {
const PT_DAYFACTOR = 32; public const COMPATIBLE_VERSIONS = ['6.', '5.'];
const PT_MONTHFACTOR = 16;
const PT_YEARFACTOR = 512; public const PT_DAYFACTOR = 32;
const PT_PASTOFFSET = 117;
const CompatibleVersions = ['6.', '5.']; public const PT_MONTHFACTOR = 16;
public const PT_PASTOFFSET = 117;
public const PT_YEARFACTOR = 512;
/**
* Binary data that was read out of the pairing file
*
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
/** /**
* Version of Pairtwo this file was created with * Version of Pairtwo this file was created with
@ -59,41 +71,91 @@ class Pairtwo6 implements ReaderInterface
*/ */
public $Tournament; public $Tournament;
/**
* Binary data that was read out of the pairing file
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
/** /**
* Returns binary data that was read out the pairtwo file but was not needed immediately * Returns binary data that was read out the pairtwo file but was not needed immediately
* *
* @param string $key * @param string $key
*
* @return bool|DateTime|int|string|null * @return bool|DateTime|int|string|null
*/ */
public function __get(string $key) public function __get(string $key)
{ {
if (isset($this->BinaryData[$key])) { if (isset($this->BinaryData[ $key ])) {
return $this->BinaryData[$key]; return $this->BinaryData[ $key ];
} }
return null; return null;
} }
/** /**
* Sets binary data that is read out the pairtwo file but is not needed immediately * Sets binary data that is read out the pairtwo file but is not needed immediately
* *
* @param string $key * @param string $key
* @param bool|int|DateTime|string $value * @param bool|int|DateTime|string $value
*/ */
public function __set(string $key, $value): void public function __set(string $key, $value): void
{ {
$this->BinaryData[$key] = $value; $this->BinaryData[ $key ] = $value;
}
/**
* Adds the first tiebreak to the tournament
*/
private function addTiebreaks(): void
{
switch ($this->Tournament->System) {
case TournamentSystem::KEIZER:
$firstElement = new Tiebreak(Tiebreak::KEIZER);
break;
case TournamentSystem::AMERICAN:
case TournamentSystem::CLOSED:
case TournamentSystem::SWISS:
$firstElement = new Tiebreak(Tiebreak::POINTS);
break;
}
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->Tournament->Tiebreaks = $tiebreaks;
}
/**
* Converts integer value to a date representation
*
* @param int $date
*
* @return bool|DateTime
*/
private function convertUIntToTimestamp(int $date)
{
$curyear = date('Y');
$yearoffset = $curyear - self::PT_PASTOFFSET;
// Day
$day = $date % self::PT_DAYFACTOR;
if ($day < 1) {
$day = 1;
}
// Month
$month = ($date / self::PT_DAYFACTOR) % self::PT_MONTHFACTOR;
if ($month < 1) {
$month = 1;
}
// Year
$year = ($date / self::PT_YEARFACTOR) + $yearoffset;
$concat = $month . '/' . $day . '/' . intval($year);
$format = 'm/d/Y';
return DateTime::createFromFormat($format, $concat);
} }
/** /**
* Actually reads the Swar-File * Actually reads the Swar-File
* *
* @param string $filename * @param string $filename
*
* @throws IncompatibleReaderException * @throws IncompatibleReaderException
*/ */
public function read(string $filename): void public function read(string $filename): void
@ -104,12 +166,11 @@ class Pairtwo6 implements ReaderInterface
$offset = 0; $offset = 0;
$length = 4; $length = 4;
$this->Release = $this->readData('String', substr($swscontents, $offset, $length)); $this->Release = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length; $offset += $length;
if (array_search(substr($this->Release, 0, 2), self::CompatibleVersions) === false) { if (array_search(substr($this->Release, 0, 2), self::COMPATIBLE_VERSIONS) === false) {
throw new IncompatibleReaderException("This file was not created with Pairtwo 5 or higher"); throw new IncompatibleReaderException("This file was not created with Pairtwo 5 or higher");
} }
@ -261,53 +322,53 @@ class Pairtwo6 implements ReaderInterface
$length = 4; $length = 4;
switch ($this->readData('Int', substr($swscontents, $offset, $length))) { switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
case 1: case 1:
$tiebreak = Tiebreak::Buchholz; $tiebreak = Tiebreak::BUCHHOLZ;
break; break;
case 2: case 2:
$tiebreak = Tiebreak::BuchholzMed; $tiebreak = Tiebreak::BUCHHOLZ_MED;
break; break;
case 3: case 3:
$tiebreak = Tiebreak::BuchholzCut; $tiebreak = Tiebreak::BUCHHOLZ_CUT;
break; break;
case 4: case 4:
$tiebreak = Tiebreak::Sonneborn; $tiebreak = Tiebreak::SONNEBORN;
break; break;
case 5: case 5:
$tiebreak = Tiebreak::Kashdan; $tiebreak = Tiebreak::KASHDAN;
break; break;
case 6: case 6:
$tiebreak = Tiebreak::Cumulative; $tiebreak = Tiebreak::CUMULATIVE;
break; break;
case 7: case 7:
$tiebreak = Tiebreak::Between; $tiebreak = Tiebreak::BETWEEN;
break; break;
case 8: case 8:
$tiebreak = Tiebreak::Koya; $tiebreak = Tiebreak::KOYA;
break; break;
case 9: case 9:
$tiebreak = Tiebreak::Baumbach; $tiebreak = Tiebreak::BAUMBACH;
break; break;
case 10: case 10:
$tiebreak = Tiebreak::Performance; $tiebreak = Tiebreak::PERFORMANCE;
break; break;
case 11: case 11:
$tiebreak = Tiebreak::Aro; $tiebreak = Tiebreak::ARO;
break; break;
case 12: case 12:
$tiebreak = Tiebreak::AroCut; $tiebreak = Tiebreak::AROCUT;
break; break;
case 13: case 13:
$tiebreak = Tiebreak::BlackPlayed; $tiebreak = Tiebreak::BLACK_PLAYED;
break; break;
case 14: case 14:
$tiebreak = Tiebreak::Testmatch; $tiebreak = Tiebreak::TESTMATCH;
break; break;
case 15: case 15:
$tiebreak = Tiebreak::Drawing; $tiebreak = Tiebreak::DRAWING_OF_LOT;
break; break;
case 0: case 0:
default: default:
$tiebreak = Tiebreak::None; $tiebreak = Tiebreak::NONE;
break; break;
} }
$this->Tournament->addTieBreak(new Tiebreak($tiebreak)); $this->Tournament->addTieBreak(new Tiebreak($tiebreak));
@ -315,9 +376,14 @@ class Pairtwo6 implements ReaderInterface
} }
// Categorie // Categorie
$length = 4 * 10; for ($i = 0; $i < 10; $i++) {
$this->Categorie = $this->readData('Int', substr($swscontents, $offset, $length)); $length = 4;
$offset += $length; $category = $this->readData('Int', substr($swscontents, $offset, $length));
if ($category != 0) {
$this->Tournament->addCategory('+' . $category);
}
$offset += $length;
}
// ExtraPoints // ExtraPoints
$length = 4 * 20; $length = 4 * 20;
@ -395,7 +461,8 @@ class Pairtwo6 implements ReaderInterface
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$player->Category = $this->readData('String', substr($swscontents, $offset, $length)); $player->Category =
$this->Tournament->Categories[ $this->readData('Int', substr($swscontents, $offset, $length)) - 1 ];
$offset += $length; $offset += $length;
$length = 1; $length = 1;
@ -447,13 +514,13 @@ class Pairtwo6 implements ReaderInterface
$length = 1; $length = 1;
switch ($this->readData('Int', substr($swscontents, $offset, $length))) { switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
case 1: case 1:
$gender = Gender::Male; $gender = Gender::MALE;
break; break;
case 2: case 2:
$gender = Gender::Female; $gender = Gender::FEMALE;
break; break;
default: default:
$gender = Gender::Neutral; $gender = Gender::NEUTRAL;
break; break;
} }
$player->Gender = new Gender($gender); $player->Gender = new Gender($gender);
@ -498,12 +565,12 @@ class Pairtwo6 implements ReaderInterface
$this->Tournament->addPlayer($player); $this->Tournament->addPlayer($player);
} }
// PlayerNames // PlayerNames
$length = (Integer)$this->NewNamePos + 0; $length = (int)$this->NewNamePos + 0;
$this->PlayerNames = substr($swscontents, $offset, $length); $this->PlayerNames = substr($swscontents, $offset, $length);
$offset += $length; $offset += $length;
for ($i = 0; $i < $this->NewPlayer; $i++) { for ($i = 0; $i < $this->NewPlayer; $i++) {
$player = $this->Tournament->PlayerById($i); $player = $this->Tournament->playerById($i);
$namelength = $player->NameLength; $namelength = $player->NameLength;
$nameoffset = $player->NamePos; $nameoffset = $player->NamePos;
$player->Name = $this->readData("String", substr($this->PlayerNames, $nameoffset, $namelength)); $player->Name = $this->readData("String", substr($this->PlayerNames, $nameoffset, $namelength));
@ -585,17 +652,17 @@ class Pairtwo6 implements ReaderInterface
$length = 4; $length = 4;
switch ($this->readData('Int', substr($swscontents, $offset, $length))) { switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
case 2: case 2:
$system = TournamentSystem::Closed; $system = TournamentSystem::CLOSED;
break; break;
case 4: case 4:
$system = TournamentSystem::American; $system = TournamentSystem::AMERICAN;
break; break;
case 6: case 6:
$system = TournamentSystem::Keizer; $system = TournamentSystem::KEIZER;
break; break;
case 0: case 0:
default: default:
$system = TournamentSystem::Swiss; $system = TournamentSystem::SWISS;
break; break;
} }
$this->Tournament->System = new TournamentSystem($system); $this->Tournament->System = new TournamentSystem($system);
@ -651,12 +718,12 @@ class Pairtwo6 implements ReaderInterface
for ($x = 0; $x < $this->CreatedRounds; $x++) { for ($x = 0; $x < $this->CreatedRounds; $x++) {
$pairing = new Pairing(); $pairing = new Pairing();
$pairing->Player = $this->Tournament->PlayerById($i); $pairing->Player = $this->Tournament->playerById($i);
$length = 4; $length = 4;
$opponent = $this->readData('Int', substr($swscontents, $offset, $length)); $opponent = $this->readData('Int', substr($swscontents, $offset, $length));
if ($opponent != 4294967295) { if ($opponent != 4294967295) {
$pairing->Opponent = $this->Tournament->PlayerById($opponent); $pairing->Opponent = $this->Tournament->playerById($opponent);
} }
$offset += $length; $offset += $length;
@ -665,15 +732,15 @@ class Pairtwo6 implements ReaderInterface
switch ($this->readData('Int', substr($swscontents, $offset, $length))) { switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
case 255: case 255:
case 253: case 253:
$color = Color::Black; $color = Color::BLACK;
break; break;
case 1: case 1:
case 3: case 3:
$color = Color::White; $color = Color::WHITE;
break; break;
case 0: case 0:
default: default:
$color = Color::None; $color = Color::NONE;
break; break;
} }
$pairing->Color = new Color($color); $pairing->Color = new Color($color);
@ -682,38 +749,38 @@ class Pairtwo6 implements ReaderInterface
$length = 1; $length = 1;
switch ($this->readData('Int', substr($swscontents, $offset, $length))) { switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
case 1: case 1:
$result = Result::Lost; $result = Result::LOST;
break; break;
case 2: case 2:
$result = Result::Absent; $result = Result::ABSENT;
break; break;
case 3: case 3:
$result = Result::Adjourned; $result = Result::ADJOURNED;
break; break;
case 4: case 4:
$result = Result::Bye; $result = Result::BYE;
break; break;
case 6: case 6:
$result = Result::Draw; $result = Result::DRAW;
break; break;
case 8: case 8:
$result = Result::DrawAdjourned; $result = Result::DRAW_ADJOURNED;
break; break;
case 11: case 11:
$result = Result::Won; $result = Result::WON;
break; break;
case 12: case 12:
$result = Result::WonForfait; $result = Result::WON_FORFAIT;
break; break;
case 13: case 13:
$result = Result::WonAdjourned; $result = Result::WON_ADJOURNED;
break; break;
case 14: case 14:
$result = Result::WonBye; $result = Result::WON_BYE;
break; break;
case 0: case 0:
default: default:
$result = Result::None; $result = Result::NONE;
break; break;
} }
$pairing->Result = new Result($result); $pairing->Result = new Result($result);
@ -747,7 +814,8 @@ class Pairtwo6 implements ReaderInterface
* *
* @param string $type * @param string $type
* @param string $data * @param string $data
* @param mixed $default * @param mixed $default
*
* @return bool|DateTime|int|string * @return bool|DateTime|int|string
*/ */
private function readData(string $type, string $data, $default = null) private function readData(string $type, string $data, $default = null)
@ -758,8 +826,8 @@ class Pairtwo6 implements ReaderInterface
if ($data == '') { if ($data == '') {
return (is_null($default)) ? '' : $default; return (is_null($default)) ? '' : $default;
} }
return iconv('windows-1252', 'utf-8', $data); return iconv('windows-1252', 'utf-8', $data);
break;
case 'Hex': case 'Hex':
case 'Int': case 'Int':
case 'Bool': case 'Bool':
@ -769,7 +837,7 @@ class Pairtwo6 implements ReaderInterface
foreach ($hex as $key => $item) { foreach ($hex as $key => $item) {
if ($item == "00") { if ($item == "00") {
$hex[$key] = ""; $hex[ $key ] = "";
} else { } else {
break; break;
} }
@ -781,80 +849,28 @@ class Pairtwo6 implements ReaderInterface
if ($hex == '00') { if ($hex == '00') {
return (is_null($default)) ? '00' : $default; return (is_null($default)) ? '00' : $default;
} }
return $hex; return $hex;
} elseif ($type == 'Int') { } elseif ($type == 'Int') {
if ($hex == '00') { if ($hex == '00') {
return (is_null($default)) ? 0 : $default; return (is_null($default)) ? 0 : $default;
} }
return hexdec($hex); return hexdec($hex);
} elseif ($type == 'Date') { } elseif ($type == 'Date') {
if ($hex == '00') { if ($hex == '00') {
return (is_null($default)) ? $this->convertUIntToTimestamp(0) : $default; return (is_null($default)) ? $this->convertUIntToTimestamp(0) : $default;
} }
return $this->convertUIntToTimestamp(hexdec($hex)); return $this->convertUIntToTimestamp(hexdec($hex));
} elseif ($type == 'Bool') { } elseif ($type == 'Bool') {
return ($hex == "01") ? true : false; return ($hex == "01");
} }
break; break;
default: default:
throw new \InvalidArgumentException("Datatype not known"); throw new InvalidArgumentException("Datatype not known");
break;
} }
return false; return false;
} }
/**
* Converts integer value to a date representation
*
* @param int $date
* @return bool|DateTime
*/
private function convertUIntToTimestamp(int $date)
{
$curyear = date('Y');
$yearoffset = $curyear - self::PT_PASTOFFSET;
// Day
$day = $date % self::PT_DAYFACTOR;
if ($day < 1) {
$day = 1;
}
// Month
$month = ($date / self::PT_DAYFACTOR) % self::PT_MONTHFACTOR;
if ($month < 1) {
$month = 1;
}
// Year
$year = ($date / self::PT_YEARFACTOR) + $yearoffset;
$concat = $month . '/' . $day . '/' . intval($year);
$format = 'm/d/Y';
return DateTime::createFromFormat($format, $concat);
}
/**
* Adds the first tiebreak to the tournament
*/
private function addTiebreaks(): void
{
switch ($this->Tournament->System) {
case TournamentSystem::Keizer:
$firstElement = new Tiebreak(Tiebreak::Keizer);
break;
case TournamentSystem::American:
case TournamentSystem::Closed:
case TournamentSystem::Swiss:
$firstElement = new Tiebreak(Tiebreak::Points);
break;
}
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->Tournament->Tiebreaks = $tiebreaks;
}
} }

View File

@ -1,16 +1,20 @@
<?php <?php
/** /**
* Reader Swar-4 * Reader Swar-4
* *
* Reads out Swar-4 files * Reads out Swar-4 files
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo\Readers; namespace JeroenED\Libpairtwo\Readers;
use DateTime;
use InvalidArgumentException;
use JeroenED\Libpairtwo\Enums\Color; use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Gender; use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Result; use JeroenED\Libpairtwo\Enums\Result;
@ -23,45 +27,25 @@ use JeroenED\Libpairtwo\Pairing;
use JeroenED\Libpairtwo\Player; use JeroenED\Libpairtwo\Player;
use JeroenED\Libpairtwo\Round; use JeroenED\Libpairtwo\Round;
use JeroenED\Libpairtwo\Tournament; use JeroenED\Libpairtwo\Tournament;
use DateTime;
/** /**
* Reader Swar4 * Reader Swar4
* *
* Reads out Swar-4 files * Reads out Swar-4 files
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Swar4 implements ReaderInterface class Swar4 implements ReaderInterface
{ {
/** /**
* Version of Pairtwo this file was created with * @var array
*
* @var string
*/ */
public $Release; public const COMPATIBLE_VERSIONS = ['v4.'];
/** public const TEMPOS = [
* The tournament
*
* @var Tournament
*/
public $Tournament;
/**
* Binary data that was read out of the pairing file
*
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
/** @var array */
const CompatibleVersions = ['v4.'];
const Tempos = [
[ [
'105 min/40 moves + 15 min. QPF', '105 min/40 moves + 15 min. QPF',
'120 min/40 moves + 15 min. with incr. 30" starting from 40th move', '120 min/40 moves + 15 min. with incr. 30" starting from 40th move',
@ -78,7 +62,8 @@ class Swar4 implements ReaderInterface
'90 min with incr. 30"', '90 min with incr. 30"',
'50 min with incr. 10"', '50 min with incr. 10"',
'other' 'other'
],[ ],
[
'10 min. with incr. 10"', '10 min. with incr. 10"',
'10 min. with incr. 15"', '10 min. with incr. 15"',
'10 min. with incr.5"', '10 min. with incr.5"',
@ -102,7 +87,8 @@ class Swar4 implements ReaderInterface
'45 min. QPF', '45 min. QPF',
'8 min. with incr.4"', '8 min. with incr.4"',
'other' 'other'
],[ ],
[
'3 min. with incr. 2"', '3 min. with incr. 2"',
'3 min. with incr. 3"', '3 min. with incr. 3"',
'4 min. with incr. 2"', '4 min. with incr. 2"',
@ -120,10 +106,97 @@ class Swar4 implements ReaderInterface
] ]
]; ];
/**
* Binary data that was read out of the pairing file
*
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
/**
* Version of Pairtwo this file was created with
*
* @var string
*/
public $Release;
/**
* The tournament
*
* @var Tournament
*/
public $Tournament;
/**
* Returns binary data that was read out the swar file but was not needed immediately
*
* @param string $key
*
* @return bool|DateTime|int|string|null
*/
public function __get(string $key)
{
if (isset($this->BinaryData[ $key ])) {
return $this->BinaryData[ $key ];
}
return null;
}
/**
* Sets binary data that is read out the swar file but is not needed immediately
*
* @param string $key
* @param bool|int|DateTime|string $value
*/
public function __set(string $key, $value): void
{
$this->BinaryData[ $key ] = $value;
}
/**
* Adds the first tiebreak to the tournament
*/
private function addTiebreaks(): void
{
switch ($this->Tournament->System) {
case TournamentSystem::AMERICAN:
case TournamentSystem::CLOSED:
case TournamentSystem::SWISS:
default:
$firstElement = new Tiebreak(Tiebreak::POINTS);
}
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->Tournament->Tiebreaks = $tiebreaks;
}
/**
* Converts a swar-4 string to a \DateTime object
*
* @param string $string
*
* @return DateTime
*/
public function convertStringToDate(string $string): DateTime
{
if (strlen($string) == 10) {
return DateTime::createFromFormat('d/m/Y', $string);
} elseif (strlen($string) == 8) {
return DateTime::createFromFormat('Ymd', $string);
} else {
$default = new DateTime();
$default->setTimestamp(0);
return $default;
}
}
/** /**
* Actually reads the Swar-File * Actually reads the Swar-File
* *
* @param string $filename * @param string $filename
*
* @throws IncompatibleReaderException * @throws IncompatibleReaderException
*/ */
public function read(string $filename): void public function read(string $filename): void
@ -131,7 +204,7 @@ class Swar4 implements ReaderInterface
$swshandle = fopen($filename, 'rb'); $swshandle = fopen($filename, 'rb');
$this->Release = $this->readData('String', $swshandle); $this->Release = $this->readData('String', $swshandle);
if (array_search(substr($this->Release, 0, 3), self::CompatibleVersions) === false) { if (array_search(substr($this->Release, 0, 3), self::COMPATIBLE_VERSIONS) === false) {
throw new IncompatibleReaderException("This file was not created with Swar 4"); throw new IncompatibleReaderException("This file was not created with Swar 4");
} }
@ -181,16 +254,16 @@ class Swar4 implements ReaderInterface
case 3: case 3:
case 4: case 4:
default: default:
$system = TournamentSystem::Swiss; $system = TournamentSystem::SWISS;
break; break;
case 5: case 5:
case 6: case 6:
case 7: case 7:
$system = TournamentSystem::Closed; $system = TournamentSystem::CLOSED;
break; break;
case 8: case 8:
case 9: case 9:
$system = TournamentSystem::American; $system = TournamentSystem::AMERICAN;
break; break;
} }
$this->Tournament->System = new TournamentSystem($system); $this->Tournament->System = new TournamentSystem($system);
@ -244,7 +317,7 @@ class Swar4 implements ReaderInterface
// [DATES] // [DATES]
$this->readData('String', $swshandle); $this->readData('String', $swshandle);
$this->Tournament->Tempo = Self::Tempos[$this->Tournament->TournoiStd][$this->Tournament->TempoIndex]; $this->Tournament->Tempo = self::TEMPOS[ $this->Tournament->TournoiStd ][ $this->Tournament->TempoIndex ];
for ($i = 0; $i < $this->Tournament->NoOfRounds; $i++) { for ($i = 0; $i < $this->Tournament->NoOfRounds; $i++) {
$round = new Round(); $round = new Round();
@ -261,52 +334,52 @@ class Swar4 implements ReaderInterface
switch ($this->readData('Int', $swshandle)) { switch ($this->readData('Int', $swshandle)) {
case 0: case 0:
default: default:
$tiebreak = Tiebreak::None; $tiebreak = Tiebreak::NONE;
break; break;
case 1: case 1:
$tiebreak = Tiebreak::Buchholz; $tiebreak = Tiebreak::BUCHHOLZ;
break; break;
case 2: case 2:
$tiebreak = Tiebreak::BuchholzMed; $tiebreak = Tiebreak::BUCHHOLZ_MED;
break; break;
case 3: case 3:
$tiebreak = Tiebreak::BuchholzMed2; $tiebreak = Tiebreak::BUCHHOLZ_MED_2;
break; break;
case 4: case 4:
$tiebreak = Tiebreak::BuchholzCut; $tiebreak = Tiebreak::BUCHHOLZ_CUT;
break; break;
case 5: case 5:
$tiebreak = Tiebreak::BuchholzCut2; $tiebreak = Tiebreak::BUCHHOLZ_CUT_2;
break; break;
case 6: case 6:
$tiebreak = Tiebreak::Sonneborn; $tiebreak = Tiebreak::SONNEBORN;
break; break;
case 7: case 7:
$tiebreak = Tiebreak::Cumulative; $tiebreak = Tiebreak::CUMULATIVE;
break; break;
case 8: case 8:
$tiebreak = Tiebreak::Between; $tiebreak = Tiebreak::BETWEEN;
break; break;
case 9: case 9:
$tiebreak = Tiebreak::Koya; $tiebreak = Tiebreak::KOYA;
break; break;
case 10: case 10:
$tiebreak = Tiebreak::Baumbach; $tiebreak = Tiebreak::BAUMBACH;
break; break;
case 11: case 11:
$tiebreak = Tiebreak::AveragePerformance; $tiebreak = Tiebreak::AVERAGE_PERFORMANCE;
break; break;
case 12: case 12:
$tiebreak = Tiebreak::Aro; $tiebreak = Tiebreak::ARO;
break; break;
case 13: case 13:
$tiebreak = Tiebreak::AroCut; $tiebreak = Tiebreak::AROCUT;
break; break;
case 14: case 14:
$tiebreak = Tiebreak::BlackPlayed; $tiebreak = Tiebreak::BLACK_PLAYED;
break; break;
case 15: case 15:
$tiebreak = Tiebreak::BlackWin; $tiebreak = Tiebreak::BLACK_WIN;
break; break;
} }
$tiebreaks[] = new Tiebreak($tiebreak); $tiebreaks[] = new Tiebreak($tiebreak);
@ -323,19 +396,19 @@ class Swar4 implements ReaderInterface
$this->Tournament->Catogory_type = $this->readData('Int', $swshandle); $this->Tournament->Catogory_type = $this->readData('Int', $swshandle);
for ($i = 0; $i <= 12; $i++) { for ($i = 0; $i <= 12; $i++) {
$category[$i]['Cat1'] =$this->readData('String', $swshandle); $category[ $i ][ 'Cat1' ] = $this->readData('String', $swshandle);
} }
for ($i = 0; $i <= 12; $i++) { for ($i = 0; $i <= 12; $i++) {
$category[$i]['Cat2'] =$this->readData('String', $swshandle); $category[ $i ][ 'Cat2' ] = $this->readData('String', $swshandle);
} }
$this->Tournament->Category = $category; $this->Tournament->Category = $category;
// [XTRA_POINTS] // [XTRA_POINTS]
$this->readData('String', $swshandle); $this->readData('String', $swshandle);
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
$extrapoints[$i]['pts'] = $this->readData('Int', $swshandle); $extrapoints[ $i ][ 'pts' ] = $this->readData('Int', $swshandle);
$extrapoints[$i]['elo'] = $this->readData('Int', $swshandle); $extrapoints[ $i ][ 'elo' ] = $this->readData('Int', $swshandle);
} }
$this->Tournament->Extrapoints = $extrapoints; $this->Tournament->Extrapoints = $extrapoints;
@ -351,19 +424,19 @@ class Swar4 implements ReaderInterface
$player = new Player(); $player = new Player();
$player->Classement = $this->readData('Int', $swshandle); $player->Classement = $this->readData('Int', $swshandle);
$player->Name = $this->readData('String', $swshandle); $player->Name = $this->readData('String', $swshandle);
$inscriptionNos[$this->readData('Int', $swshandle)] = $i; $inscriptionNos[ $this->readData('Int', $swshandle) ] = $i;
$player->Rank = $this->readData('Int', $swshandle); $player->Rank = $this->readData('Int', $swshandle);
$player->CatIndex = $this->readData('Int', $swshandle); $player->CatIndex = $this->readData('Int', $swshandle);
$player->DateOfBirth = $this->readData('Date', $swshandle); $player->DateOfBirth = $this->readData('Date', $swshandle);
switch ($this->readData('Int', $swshandle)) { switch ($this->readData('Int', $swshandle)) {
case 1: case 1:
$gender = Gender::Male; $gender = Gender::MALE;
break; break;
case 2: case 2:
$gender = Gender::Female; $gender = Gender::FEMALE;
break; break;
default: default:
$gender = Gender::Neutral; $gender = Gender::NEUTRAL;
break; break;
} }
$player->Gender = new Gender($gender); $player->Gender = new Gender($gender);
@ -415,10 +488,10 @@ class Swar4 implements ReaderInterface
$player->setId('Club', $this->readData('Int', $swshandle)); $player->setId('Club', $this->readData('Int', $swshandle));
$player->ClubName = $this->readData('String', $swshandle); $player->ClubName = $this->readData('String', $swshandle);
$player->NoOfMatchesNoBye = $this->readData('Int', $swshandle); $player->NoOfMatchesNoBye = $this->readData('Int', $swshandle);
$player->Points = $this->readData('Int', $swshandle); // To Calculate by libpairtwo $player->Points = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
$player->AmericanPoints = $this->readData('Int', $swshandle); // To Calculate by libpairtwo $player->AmericanPoints = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
for ($t = 0; $t < 5; $t++) { for ($t = 0; $t < 5; $t++) {
$tiebreaks[$t] = $this->readData('Int', $swshandle); // To Calculate by libpairtwo $tiebreaks[ $t ] = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
} }
$player->Tiebreak = $tiebreaks; $player->Tiebreak = $tiebreaks;
$player->Performance = $this->readData('Int', $swshandle); // To Calculate by libpairtwo $player->Performance = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
@ -432,14 +505,14 @@ class Swar4 implements ReaderInterface
if ($player->AllocatedRounds != 0) { if ($player->AllocatedRounds != 0) {
for ($j = 0; $j < $player->AllocatedRounds; $j++) { for ($j = 0; $j < $player->AllocatedRounds; $j++) {
$pairing[$pt]['player'] = $i; $pairing[ $pt ][ 'player' ] = $i;
$pairing[$pt]['round'] = $this->readData('Int', $swshandle) - 1; $pairing[ $pt ][ 'round' ] = $this->readData('Int', $swshandle) - 1;
$pairing[$pt]['table'] = $this->readData('Int', $swshandle) - 1; $pairing[ $pt ][ 'table' ] = $this->readData('Int', $swshandle) - 1;
$pairing[$pt]['opponent'] = $this->readData('Int', $swshandle); $pairing[ $pt ][ 'opponent' ] = $this->readData('Int', $swshandle);
$pairing[$pt]['result'] = $this->readData('Hex', $swshandle); $pairing[ $pt ][ 'result' ] = $this->readData('Hex', $swshandle);
$pairing[$pt]['color'] = $this->readData('Int', $swshandle); $pairing[ $pt ][ 'color' ] = $this->readData('Int', $swshandle);
$pairing[$pt]['float'] = $this->readData('Int', $swshandle); $pairing[ $pt ][ 'float' ] = $this->readData('Int', $swshandle);
$pairing[$pt]['extrapoints'] = $this->readData('Int', $swshandle); $pairing[ $pt ][ 'extrapoints' ] = $this->readData('Int', $swshandle);
$pt++; $pt++;
} }
@ -450,61 +523,62 @@ class Swar4 implements ReaderInterface
} }
$ptn = 0; $ptn = 0;
while (isset($this->Tournament->Pairing[$ptn]['round'])) { while (isset($this->Tournament->Pairing[ $ptn ][ 'round' ])) {
$pairing = new Pairing(); $pairing = new Pairing();
$pairing->Player = $this->Tournament->PlayerById($this->Tournament->Pairing[$ptn]['player']); $pairing->Player = $this->Tournament->playerById($this->Tournament->Pairing[ $ptn ][ 'player' ]);
$pairing->Round = $this->Tournament->Pairing[$ptn]['round']; $pairing->Round = $this->Tournament->Pairing[ $ptn ][ 'round' ];
if ($this->Tournament->Pairing[$ptn]['opponent'] != 4294967295) { if ($this->Tournament->Pairing[ $ptn ][ 'opponent' ] != 4294967295) {
$pairing->Opponent = $this->Tournament->PlayerById($inscriptionNos[$this->Tournament->Pairing[$ptn]['opponent']]); $pairing->Opponent =
$this->Tournament->playerById($inscriptionNos[ $this->Tournament->Pairing[ $ptn ][ 'opponent' ] ]);
} }
switch ($this->Tournament->Pairing[$ptn]['result']) { switch ($this->Tournament->Pairing[ $ptn ][ 'result' ]) {
case '1000': case '1000':
$result = Result::Lost; $result = Result::LOST;
break; break;
case '01': case '01':
$result = Result::Absent; $result = Result::ABSENT;
break; break;
case '0010': case '0010':
$result = Result::Bye; $result = Result::BYE;
break; break;
case '2000': case '2000':
$result = Result::Draw; $result = Result::DRAW;
break; break;
case '4000': case '4000':
$result = Result::Won; $result = Result::WON;
break; break;
case '04': case '04':
$result = Result::WonForfait; $result = Result::WON_FORFAIT;
break; break;
case '40': case '40':
$result = Result::WonBye; $result = Result::WON_BYE;
break; break;
case '00': case '00':
default: default:
$result = Result::None; $result = Result::NONE;
break; break;
} }
if (array_search($this->Tournament->Pairing[$ptn]['table'], [ 16383, 8191 ]) !== false) { if (array_search($this->Tournament->Pairing[ $ptn ][ 'table' ], [16383, 8191]) !== false) {
$result = Result::Absent; $result = Result::ABSENT;
} }
$pairing->Result = new Result($result); $pairing->Result = new Result($result);
switch ($this->Tournament->Pairing[$ptn]['color']) { switch ($this->Tournament->Pairing[ $ptn ][ 'color' ]) {
case 4294967295: case 4294967295:
$color = Color::Black; $color = Color::BLACK;
break; break;
case 1: case 1:
$color = Color::White; $color = Color::WHITE;
break; break;
case 0: case 0:
default: default:
$color = Color::None; $color = Color::NONE;
break; break;
} }
$pairing->Color = new Color($color); $pairing->Color = new Color($color);
$pairing->Board = $this->Tournament->Pairing[$ptn]['table']; $pairing->Board = $this->Tournament->Pairing[ $ptn ][ 'table' ];
$ptn++; $ptn++;
$this->Tournament->addPairing($pairing); $this->Tournament->addPairing($pairing);
} }
@ -524,8 +598,9 @@ class Swar4 implements ReaderInterface
* * Date (Date representation of $data. Default: 1902/01/01) * * Date (Date representation of $data. Default: 1902/01/01)
* *
* @param string $type * @param string $type
* @param $handle * @param $handle
* @param null $default * @param null $default
*
* @return array|bool|DateTime|false|float|int|string|null * @return array|bool|DateTime|false|float|int|string|null
*/ */
private function readData(string $type, $handle, $default = null) private function readData(string $type, $handle, $default = null)
@ -542,11 +617,13 @@ class Swar4 implements ReaderInterface
if ($data == '') { if ($data == '') {
return (is_null($default)) ? '' : $default; return (is_null($default)) ? '' : $default;
} }
return iconv('windows-1252', 'utf-8', $data); return iconv('windows-1252', 'utf-8', $data);
} elseif ($type == 'Date') { } elseif ($type == 'Date') {
if ($data == '') { if ($data == '') {
return (is_null($default)) ? $this->convertStringToDate('01/01/1900') : $default; return (is_null($default)) ? $this->convertStringToDate('01/01/1900') : $default;
} }
return $this->convertStringToDate($data); return $this->convertStringToDate($data);
} }
break; break;
@ -559,7 +636,7 @@ class Swar4 implements ReaderInterface
foreach ($hex as $key => $item) { foreach ($hex as $key => $item) {
if ($item == "00") { if ($item == "00") {
$hex[$key] = ""; $hex[ $key ] = "";
} else { } else {
break; break;
} }
@ -571,77 +648,22 @@ class Swar4 implements ReaderInterface
if ($hex == '00') { if ($hex == '00') {
return (is_null($default)) ? '00' : $default; return (is_null($default)) ? '00' : $default;
} }
return $hex; return $hex;
} elseif ($type == 'Int') { } elseif ($type == 'Int') {
if ($hex == '00') { if ($hex == '00') {
return (is_null($default)) ? 0 : $default; return (is_null($default)) ? 0 : $default;
} }
return hexdec($hex); return hexdec($hex);
} elseif ($type == 'Bool') { } elseif ($type == 'Bool') {
return ($hex == "01") ? true : false; return ($hex == "01");
} }
break; break;
default: default:
throw new \InvalidArgumentException("Datatype not known"); throw new InvalidArgumentException("Datatype not known");
break;
} }
return false; return false;
} }
/**
* Returns binary data that was read out the swar file but was not needed immediately
*
* @param string $key
* @return bool|DateTime|int|string|null
*/
public function __get(string $key)
{
if (isset($this->BinaryData[$key])) {
return $this->BinaryData[$key];
}
return null;
}
/**
* Sets binary data that is read out the swar file but is not needed immediately
*
* @param string $key
* @param bool|int|DateTime|string $value
*/
public function __set(string $key, $value): void
{
$this->BinaryData[$key] = $value;
}
/**
* Converts a swar-4 string to a \DateTime object
* @param string $string
* @return DateTime
*/
public function convertStringToDate(string $string): DateTime
{
if (strlen($string) == 10) {
return DateTime::createFromFormat('d/m/Y', $string);
} elseif (strlen($string) == 8) {
return DateTime::createFromFormat('Ymd', $string);
}
}
/**
* Adds the first tiebreak to the tournament
*/
private function addTiebreaks(): void
{
switch ($this->Tournament->System) {
case TournamentSystem::American:
case TournamentSystem::Closed:
case TournamentSystem::Swiss:
default:
$firstElement = new Tiebreak(Tiebreak::Points);
}
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->Tournament->Tiebreaks = $tiebreaks;
}
} }

View File

@ -1,13 +1,14 @@
<?php <?php
/** /**
* Class Round * Class Round
* *
* Class for a round of the tournament * Class for a round of the tournament
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
namespace JeroenED\Libpairtwo; namespace JeroenED\Libpairtwo;
@ -20,10 +21,10 @@ use JeroenED\Libpairtwo\Enums\Result;
* *
* Class for a round of the tournament * Class for a round of the tournament
* *
* @author Jeroen De Meerleer <schaak@jeroened.be> * @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main * @category Main
* @package Libpairtwo * @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be> * @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/ */
class Round class Round
{ {
@ -41,6 +42,13 @@ class Round
*/ */
public $Games = []; public $Games = [];
/**
* Array of all pairings for this round
*
* @var Pairing[]
*/
public $Pairings = [];
/** /**
* Number of the round * Number of the round
* *
@ -49,11 +57,44 @@ class Round
public $RoundNo; public $RoundNo;
/** /**
* Array of all pairings for this round * Magic method to read out several fields. If field was not found it is being searched in the binary data fields
* *
* @var Pairing[] * @param string $key
*
* @return bool|DateTime|int|string|null
*/ */
public $Pairings = []; public function __get(string $key)
{
if ($key == 'Bye') {
return $this->bye();
} elseif ($key == 'Absent') {
return $this->absent();
} elseif ($key == 'GamesByBoard') {
return $this->gamesByBoard();
} elseif (isset($this->BinaryData[ $key ])) {
return $this->BinaryData[ $key ];
}
return null;
}
/**
* Returns an array of pairings where the player is absent
*
* @return Pairing[]
*/
private function absent(): array
{
$allPairings = $this->Pairings;
$absentPairings = [];
foreach ($allPairings as $pairing) {
if ($pairing->Result == Result::ABSENT) {
$absentPairings[] = $pairing;
}
}
return $absentPairings;
}
/** /**
* Adds a game to the round * Adds a game to the round
@ -89,28 +130,12 @@ class Round
$allPairings = $this->Pairings; $allPairings = $this->Pairings;
$byePairings = []; $byePairings = [];
foreach ($allPairings as $pairing) { foreach ($allPairings as $pairing) {
if ($pairing->Result == Result::WonBye) { if ($pairing->Result == Result::WON_BYE) {
$byePairings[] = $pairing; $byePairings[] = $pairing;
} }
} }
return $byePairings;
}
/** return $byePairings;
* Returns an array of pairings where the player is absent
*
* @return Pairing[]
*/
private function absent(): array
{
$allPairings = $this->Pairings;
$absentPairings = [];
foreach ($allPairings as $pairing) {
if ($pairing->Result == Result::Absent) {
$absentPairings[] = $pairing;
}
}
return $absentPairings;
} }
/** /**
@ -121,7 +146,8 @@ class Round
private function gamesByBoard(): array private function gamesByBoard(): array
{ {
$allGames = $this->Games; $allGames = $this->Games;
usort($allGames, array($this, 'sortByBoard')); usort($allGames, [$this, 'sortByBoard']);
return $allGames; return $allGames;
} }
@ -130,6 +156,7 @@ class Round
* *
* @param Game $a * @param Game $a
* @param Game $b * @param Game $b
*
* @return int * @return int
*/ */
private function sortByBoard(Game $a, Game $b): int private function sortByBoard(Game $a, Game $b): int
@ -137,26 +164,7 @@ class Round
if (($a->Board == $b->Board) || ($a->Board === false) || ($b->Board === false)) { if (($a->Board == $b->Board) || ($a->Board === false) || ($b->Board === false)) {
return 0; return 0;
} }
return ($a->Board > $b->Board) ? +1 : -1; return ($a->Board > $b->Board) ? +1 : -1;
} }
/**
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
*
* @param string $key
* @return bool|DateTime|int|string|null
*/
public function __get(string $key)
{
if ($key == 'Bye') {
return $this->bye();
} elseif ($key == 'Absent') {
return $this->absent();
} elseif ($key == 'GamesByBoard') {
return $this->gamesByBoard();
} elseif (isset($this->BinaryData[$key])) {
return $this->BinaryData[$key];
}
return null;
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
use JeroenED\Libpairtwo\IOFactory; use JeroenED\Libpairtwo\IOFactory;
require_once '../vendor/autoload.php'; require_once '../vendor/autoload.php';
@ -30,62 +31,67 @@ require_once '../vendor/autoload.php';
$sws = IOFactory::createReader('Swar-4'); $sws = IOFactory::createReader('Swar-4');
$sws->read('../res/testswar.swar'); $sws->read('../res/testswar.swar');
echo "Release: " . $sws->Release() . PHP_EOL; echo "Release: " . $sws->Release . PHP_EOL;
echo "Name: " . $sws->Tournament()->Name . PHP_EOL; echo "Name: " . $sws->Tournament->Name . PHP_EOL;
echo "Organiser: " . $sws->Tournament()->Organiser. PHP_EOL; echo "Organiser: " . $sws->Tournament->Organiser . PHP_EOL;
echo "TempoIndex: " . $sws->Tournament()->TempoIndex . PHP_EOL; echo "TempoIndex: " . $sws->Tournament->TempoIndex . PHP_EOL;
echo "TempoType: " . $sws->Tournament()->TournoiStd . PHP_EOL; echo "TempoType: " . $sws->Tournament->TournoiStd . PHP_EOL;
echo "Tempo: " . $sws->Tournament()->Tempo . PHP_EOL; echo "Tempo: " . $sws->Tournament->Tempo . PHP_EOL;
echo "Place: " . $sws->Tournament()->OrganiserPlace . PHP_EOL; echo "Place: " . $sws->Tournament->OrganiserPlace . PHP_EOL;
echo "Arbiter 1: " . $sws->Tournament()->Arbiters[0] . PHP_EOL; echo "Arbiter 1: " . $sws->Tournament->Arbiters[ 0 ] . PHP_EOL;
echo "Arbiter 2: " . $sws->Tournament()->Arbiter[1] . PHP_EOL; echo "Arbiter 2: " . $sws->Tournament->Arbiters[ 1 ] . PHP_EOL;
echo "Rounds: " . $sws->Tournament()->NoOfRounds . PHP_EOL; echo "Rounds: " . $sws->Tournament->NoOfRounds . PHP_EOL;
echo "Fidehomol: " . $sws->Tournament()->FideHomol . PHP_EOL; echo "Fidehomol: " . $sws->Tournament->FideHomol . PHP_EOL;
echo "Start-Date: " . $sws->Tournament()->StartDate->format('d/m/Y') . PHP_EOL; echo "Start-Date: " . $sws->Tournament->StartDate->format('d/m/Y') . PHP_EOL;
echo "End-Date: " . $sws->Tournament()->EndDate->format('d/m/Y') . PHP_EOL; echo "End-Date: " . $sws->Tournament->EndDate->format('d/m/Y') . PHP_EOL;
echo "System: " . $sws->Tournament()->System->Key() . PHP_EOL; echo "System: " . $sws->Tournament->System->getKey() . PHP_EOL;
echo "Place: " . $sws->Tournament()->OrganiserPlace . PHP_EOL; echo "Place: " . $sws->Tournament->OrganiserPlace . PHP_EOL;
echo "Unrated-Elo: " . $sws->Tournament()->NonRatedElo . PHP_EOL; echo "Unrated-Elo: " . $sws->Tournament->NonRatedElo . PHP_EOL;
echo "Federation: " . $sws->Tournament()->Federation . PHP_EOL; echo "Federation: " . $sws->Tournament->Federation . PHP_EOL;
echo "Organiser: " . $sws->Tournament()->OrganiserClubNo . PHP_EOL; echo "Organiser: " . $sws->Tournament->OrganiserClubNo . PHP_EOL;
echo "Fide Elo P1: " . $sws->Tournament()->PlayerById(0)->Elo('Fide') . PHP_EOL; echo "Fide Elo P1: " . $sws->Tournament->PlayerById(0)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P2: " . $sws->Tournament()->PlayerById(1)->Elo('Fide') . PHP_EOL; echo "Fide Elo P2: " . $sws->Tournament->PlayerById(1)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P3: " . $sws->Tournament()->PlayerById(2)->Elo('Fide') . PHP_EOL; echo "Fide Elo P3: " . $sws->Tournament->PlayerById(2)->getElo('Fide') . PHP_EOL;
echo "KBSB Elo P1: " . $sws->Tournament()->PlayerById(0)->Elo('Nation') . PHP_EOL; echo "KBSB Elo P1: " . $sws->Tournament->PlayerById(0)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P2: " . $sws->Tournament()->PlayerById(1)->Elo('Nation') . PHP_EOL; echo "KBSB Elo P2: " . $sws->Tournament->PlayerById(1)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P3: " . $sws->Tournament()->PlayerById(2)->Elo('Nation') . PHP_EOL; echo "KBSB Elo P3: " . $sws->Tournament->PlayerById(2)->getElo('Nation') . PHP_EOL;
echo "Name P1: " . $sws->Tournament()->PlayerById(0)->Name . PHP_EOL; echo "Name P1: " . $sws->Tournament->PlayerById(0)->Name . PHP_EOL;
echo "Name P2: " . $sws->Tournament()->PlayerById(1)->Name . PHP_EOL; echo "Name P2: " . $sws->Tournament->PlayerById(1)->Name . PHP_EOL;
echo "Name P3: " . $sws->Tournament()->PlayerById(2)->Name . PHP_EOL; echo "Name P3: " . $sws->Tournament->PlayerById(2)->Name . PHP_EOL;
echo "Gender P1: " . $sws->Tournament()->PlayerById(0)->Gender->Key() . PHP_EOL; echo "Gender P1: " . $sws->Tournament->PlayerById(0)->Gender->getKey() . PHP_EOL;
echo "Gender P2: " . $sws->Tournament()->PlayerById(1)->Gender->Key() . PHP_EOL; echo "Gender P2: " . $sws->Tournament->PlayerById(1)->Gender->getKey() . PHP_EOL;
echo "Gender P3: " . $sws->Tournament()->PlayerById(2)->Gender->Key() . PHP_EOL; echo "Gender P3: " . $sws->Tournament->PlayerById(2)->Gender->getKey() . PHP_EOL;
echo "Absent P1: " . $sws->Tournament()->PlayerById(0)->Absent . PHP_EOL; echo "Absent P1: " . $sws->Tournament->PlayerById(0)->Absent . PHP_EOL;
echo "Absent P2: " . $sws->Tournament()->PlayerById(1)->Absent . PHP_EOL; echo "Absent P2: " . $sws->Tournament->PlayerById(1)->Absent . PHP_EOL;
echo "Absent P3: " . $sws->Tournament()->PlayerById(2)->Absent . PHP_EOL; echo "Absent P3: " . $sws->Tournament->PlayerById(2)->Absent . PHP_EOL;
echo "Date Round 1: " . $sws->Tournament()->RoundByNo(0)->Date->format('d/m/Y') . PHP_EOL; echo "Category P1: " . $sws->Tournament->PlayerById(0)->Category . PHP_EOL;
echo "Date Round 2: " . $sws->Tournament()->RoundByNo(1)->Date->format('d/m/Y') . PHP_EOL; echo "Category P2: " . $sws->Tournament->PlayerById(1)->Category . PHP_EOL;
echo "Date Round 3: " . $sws->Tournament()->RoundByNo(2)->Date->format('d/m/Y') . PHP_EOL; echo "Category P3: " . $sws->Tournament->PlayerById(2)->Category . PHP_EOL;
echo "Game Round 1: " . $sws->Tournament()->RoundByNo(0)->Games[0]->Result->getValue() . PHP_EOL; echo "Date Round 1: " . $sws->Tournament->RoundByNo(0)->Date->format('d/m/Y') . PHP_EOL;
echo "Game Round 2: " . $sws->Tournament()->RoundByNo(1)->Games[0]->Result->getValue() . PHP_EOL; echo "Date Round 2: " . $sws->Tournament->RoundByNo(1)->Date->format('d/m/Y') . PHP_EOL;
echo "Game Round 3: " . $sws->Tournament()->RoundByNo(2)->Games[0]->Result->getValue() . PHP_EOL; echo "Date Round 3: " . $sws->Tournament->RoundByNo(2)->Date->format('d/m/Y') . PHP_EOL;
echo "Color Pairing 1: " . $sws->Tournament()->Pairings[1]->Color->getKey() . PHP_EOL; echo "Game Round 1: " . $sws->Tournament->RoundByNo(0)->Games[ 0 ]->Result->getValue() . PHP_EOL;
echo "Color Pairing 2: " . $sws->Tournament()->Pairings[2]->Color->getKey() . PHP_EOL; echo "Game Round 2: " . $sws->Tournament->RoundByNo(1)->Games[ 0 ]->Result->getValue() . PHP_EOL;
echo "Color Pairing 3: " . $sws->Tournament()->Pairings[3]->Color->getKey() . PHP_EOL; echo "Game Round 3: " . $sws->Tournament->RoundByNo(2)->Games[ 0 ]->Result->getValue() . PHP_EOL;
echo "Player Pairing 1: " . $sws->Tournament()->Pairings[0]->Player->Name . PHP_EOL; echo "Color Pairing 1: " . $sws->Tournament->Pairings[ 1 ]->Color->getKey() . PHP_EOL;
echo "Player Pairing 2: " . $sws->Tournament()->Pairings[1]->Player->Name . PHP_EOL; echo "Color Pairing 2: " . $sws->Tournament->Pairings[ 2 ]->Color->getKey() . PHP_EOL;
echo "Player Pairing 3: " . $sws->Tournament()->Pairings[2]->Player->Name . PHP_EOL; echo "Color Pairing 3: " . $sws->Tournament->Pairings[ 3 ]->Color->getKey() . PHP_EOL;
echo "Bye Round 1: " . $sws->Tournament()->RoundByNo(2)->Bye[0]->Player->Name . PHP_EOL; echo "Player Pairing 1: " . $sws->Tournament->Pairings[ 0 ]->Player->Name . PHP_EOL;
echo "Absent Round 1: " . $sws->Tournament()->RoundByNo(2)->Absent[0]->Player->Name . PHP_EOL; echo "Player Pairing 2: " . $sws->Tournament->Pairings[ 1 ]->Player->Name . PHP_EOL;
echo "Tiebreak 1: " . $sws->Tournament()->Tiebreaks[0]->Value() . PHP_EOL; echo "Player Pairing 3: " . $sws->Tournament->Pairings[ 2 ]->Player->Name . PHP_EOL;
echo "Tiebreak 2: " . $sws->Tournament()->Tiebreaks[1]->Value() . PHP_EOL; echo "Bye Round 1: " . $sws->Tournament->RoundByNo(2)->Bye[ 0 ]->Player->Name . PHP_EOL;
echo "Tiebreak 3: " . $sws->Tournament()->Tiebreaks[2]->Value() . PHP_EOL; echo "Absent Round 1: " . $sws->Tournament->RoundByNo(2)->Absent[ 0 ]->Player->Name . PHP_EOL;
echo "Tiebreak 4: " . $sws->Tournament()->Tiebreaks[3]->Value() . PHP_EOL; echo "Tiebreak 1: " . $sws->Tournament->Tiebreaks[ 0 ]->getValue() . PHP_EOL;
echo "Tiebreak 5: " . $sws->Tournament()->Tiebreaks[4]->Value() . PHP_EOL; echo "Tiebreak 2: " . $sws->Tournament->Tiebreaks[ 1 ]->getValue() . PHP_EOL;
echo "Tiebreak 6: " . $sws->Tournament()->Tiebreaks[5]->Value() . PHP_EOL; echo "Tiebreak 3: " . $sws->Tournament->Tiebreaks[ 2 ]->getValue() . PHP_EOL;
echo "Average Elo: " . $sws->Tournament()->AverageElo . PHP_EOL; echo "Tiebreak 4: " . $sws->Tournament->Tiebreaks[ 3 ]->getValue() . PHP_EOL;
foreach ($sws->Tournament()->Ranking as $player) { echo "Tiebreak 5: " . $sws->Tournament->Tiebreaks[ 4 ]->getValue() . PHP_EOL;
echo str_pad($player->Name . '(' . $player->Elo($sws->Tournament()->PriorityElo) . ') ', 35) . implode_pad(' ', $player->Tiebreaks, 5, ' ') . PHP_EOL; echo "Tiebreak 6: " . $sws->Tournament->Tiebreaks[ 5 ]->getValue() . PHP_EOL;
echo "Average Elo: " . $sws->Tournament->AverageElo . PHP_EOL;
foreach ($sws->Tournament->RankingForCategory('+2500') as $player) {
echo str_pad($player->Name . '(' . $player->getElo($sws->Tournament->PriorityElo) . ') ', 35) .
implode_pad(' ', $player->Tiebreaks, 5, ' ') .
PHP_EOL;
} }
function implode_pad($glue, $collection, $padlength, $padstring): string function implode_pad($glue, $collection, $padlength, $padstring): string
@ -94,5 +100,6 @@ function implode_pad($glue, $collection, $padlength, $padstring): string
foreach ($collection as $elem) { foreach ($collection as $elem) {
$newarray[] = str_pad($elem, $padlength, $padstring); $newarray[] = str_pad($elem, $padlength, $padstring);
} }
return implode($glue, $newarray); return implode($glue, $newarray);
} }