mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-22 04:11:22 +01:00
Merge branch 'develop'
This commit is contained in:
commit
c35180271e
7
.gitattributes
vendored
7
.gitattributes
vendored
@ -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
7
.gitignore
vendored
@ -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
|
||||||
|
134
.idea/codeStyles/Project.xml
generated
Normal file
134
.idea/codeStyles/Project.xml
generated
Normal 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>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
17
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
17
.idea/inspectionProfiles/Project_Default.xml
generated
Normal 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
12
.php_cs
@ -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,
|
|
||||||
]);
|
|
18
.travis.yml
18
.travis.yml
@ -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
|
|
54
Makefile
54
Makefile
@ -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"))
|
||||||
|
@ -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
0
bin/.gitkeep
Normal 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": {
|
||||||
|
55
dist/template.php
vendored
55
dist/template.php
vendored
@ -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;
|
||||||
@ -89,6 +102,7 @@ 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;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<?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>
|
<script src="js/scripts.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -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
BIN
res/categories_test.sws
Normal file
Binary file not shown.
@ -6,11 +6,10 @@
|
|||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="134.01421mm"
|
width="134.01421mm"
|
||||||
height="89.507103mm"
|
height="89.507103mm"
|
||||||
viewBox="0 0 134.01421 89.507103"
|
viewBox="0 0 134.01421 89.507103"
|
||||||
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 46 KiB |
@ -6,11 +6,10 @@
|
|||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="134.01421mm"
|
width="134.01421mm"
|
||||||
height="89.507103mm"
|
height="89.507103mm"
|
||||||
viewBox="0 0 134.01421 89.507103"
|
viewBox="0 0 134.01421 89.507103"
|
||||||
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 46 KiB |
337
res/testsws.html
337
res/testsws.html
@ -1,53 +1,153 @@
|
|||||||
<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;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rh {
|
||||||
|
background-color: #408080;
|
||||||
|
font-size: 16pt;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vh {
|
||||||
|
font-size: 10pt;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thr {
|
||||||
|
font-size: 10pt;
|
||||||
|
text-align: right
|
||||||
|
}
|
||||||
|
|
||||||
|
.thl {
|
||||||
|
font-size: 10pt;
|
||||||
|
text-align: left
|
||||||
|
}
|
||||||
|
|
||||||
|
.thc {
|
||||||
|
font-size: 10pt;
|
||||||
|
text-align: center
|
||||||
|
}
|
||||||
|
|
||||||
|
.tdr {
|
||||||
|
font-size: 8pt;
|
||||||
|
text-align: right
|
||||||
|
}
|
||||||
|
|
||||||
|
.tdl {
|
||||||
|
font-size: 8pt;
|
||||||
|
text-align: left
|
||||||
|
}
|
||||||
|
|
||||||
|
.tdc {
|
||||||
|
font-size: 8pt;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tdp {
|
||||||
|
font-size: 10pt;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
background-color = 'yellow'
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:visited {
|
||||||
|
text-decoration: none;
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<TITLE>Libpairtwo Tournament</TITLE>
|
<TITLE>Libpairtwo Tournament</TITLE>
|
||||||
<META name='DESCRIPTION' content='Classement, Résultats, Appariement, Grille Américaine'>
|
<META content='Classement, R<EFBFBD>sultats, Appariement, Grille Am<41>ricaine' name='DESCRIPTION'>
|
||||||
<META name='AUTHOR' content='Georges Marchal'>
|
<META content='Georges Marchal' name='AUTHOR'>
|
||||||
<META name='KEYWORDS' content='échecs,echecs,chess,jeux,game,belgique,belgium,forum'>
|
<META content='<27>checs,echecs,chess,jeux,game,belgique,belgium,forum' name='KEYWORDS'>
|
||||||
<META name='KEYWORDS' content='liège,liege,666,elo,classement,tournoi,interclub'>
|
<META content='li<6C>ge,liege,666,elo,classement,tournoi,interclub' name='KEYWORDS'>
|
||||||
<META name='KEYWORDS' content='pairtwo, kbsb,frbe,fefb,666'>
|
<META content='pairtwo, kbsb,frbe,fefb,666' name='KEYWORDS'>
|
||||||
<META name='ROBOTS' content='INDEX,FOLLOW'>
|
<META content='INDEX,FOLLOW' name='ROBOTS'>
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<BODY>
|
<BODY>
|
||||||
<A name=Top></A>
|
<A name=Top></A>
|
||||||
|
|
||||||
<!-- TITRE GENERAL EN BLEU -->
|
<!-- TITRE GENERAL EN BLEU -->
|
||||||
<!-- ===================== -->
|
<!-- ===================== -->
|
||||||
<TABLE width='90%' align='center' bgColor='#000080' border='0'>
|
<TABLE align='center' bgColor='#000080' border='0' width='90%'>
|
||||||
<TR><TD><H1>Libpairtwo Tournament</H1></TD></TR></TABLE>
|
<TR>
|
||||||
|
<TD><H1>Libpairtwo Tournament</H1></TD>
|
||||||
|
</TR>
|
||||||
|
</TABLE>
|
||||||
|
|
||||||
<!-- =============== -->
|
<!-- =============== -->
|
||||||
<!-- INFO DU TOURNOI -->
|
<!-- INFO DU TOURNOI -->
|
||||||
<!-- =============== --><br>
|
<!-- =============== --><br>
|
||||||
<table align='center' border='1''>
|
<table align='center' border='1'
|
||||||
<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>
|
||||||
<tr><td align='center' bgColor='#000090'><font color='white' size='-1'><b>(©) FRBE 2005</b></font></td>
|
<td align='center' valign='middle'><font size='+2'><b>313</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><td><i> Org. : </i></td><td>Libpairtwo Organiser ,Libpairtwo Place ,2019</td></tr>
|
<TABLE align='center' border='1' style='font-size: 8pt; font-family: verdana;'>
|
||||||
<tr><td><i>Arbit. : </i></td><td>Libpairtwo Organiser</td></tr>
|
<tr>
|
||||||
<tr><td><i> Tempo : </i></td><td>40c/2h + 1h QPF</td></tr>
|
<td align='center' bgColor='#000090'><font color='white' size='-1'><b>(©) FRBE 2005</b></font></td>
|
||||||
<tr><td><i>Tie Break</i></td><td>Pts, Mutual Result, Number of Victories, Number of game Black played, Bucholtz Cut 1, SonneBorn-Berger</td></tr>
|
<td align='center' bgColor='#000090'><font color='white' size='-1'><b>PairTwo 6.13
|
||||||
|
(2015/08/10)</b></font></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><i> Org. : </i></td>
|
||||||
|
<td>Libpairtwo Organiser ,Libpairtwo Place ,2019</td>
|
||||||
|
</tr>
|
||||||
|
<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, Mutual Result, Number of Victories, Number of game Black played, Bucholtz
|
||||||
|
Cut 1, SonneBorn-Berger
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
</td>
|
</td>
|
||||||
<td align='center' valign='middle'><font size='+2'><b>F.R.B.E.</b></font></td>
|
<td align='center' valign='middle'><font size='+2'><b>F.R.B.E.</b></font></td>
|
||||||
@ -56,13 +156,16 @@ a:hover { text-decoration:none ; color: red;}
|
|||||||
<!-- ================== -->
|
<!-- ================== -->
|
||||||
<!-- === REFERENCES === -->
|
<!-- === REFERENCES === -->
|
||||||
<!-- ================== -->
|
<!-- ================== -->
|
||||||
<br><TABLE align='center' border='3' bgcolor='#ffffdd'>
|
<br>
|
||||||
|
<TABLE align='center' bgcolor='#ffffdd' border='3'>
|
||||||
<TR>
|
<TR>
|
||||||
<TD class='vh'><A HREF='#Round1'>R1</A></TD>
|
<TD class='vh'><A HREF='#Round1'>R1</A></TD>
|
||||||
<TD class='vh'><A HREF='#Round2'>R2</A></TD>
|
<TD class='vh'><A HREF='#Round2'>R2</A></TD>
|
||||||
<TD class='vh'><A HREF='#Round3'>R3</A></TD>
|
<TD class='vh'><A HREF='#Round3'>R3</A></TD>
|
||||||
</TR>
|
</TR>
|
||||||
<TR><TD class='vh' colspan='3'><A HREF='#Americaine'>American Ranking</A></TD></TR>
|
<TR>
|
||||||
|
<TD class='vh' colspan='3'><A HREF='#Americaine'>American Ranking</A></TD>
|
||||||
|
</TR>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
<br>
|
<br>
|
||||||
<DIV ALIGN='CENTER'>
|
<DIV ALIGN='CENTER'>
|
||||||
@ -70,25 +173,36 @@ a:hover { text-decoration:none ; color: red;}
|
|||||||
<!-- =========================== -->
|
<!-- =========================== -->
|
||||||
<!-- === DEBUT DU CLASSEMENT === -->
|
<!-- === DEBUT DU CLASSEMENT === -->
|
||||||
<!-- =========================== -->
|
<!-- =========================== -->
|
||||||
<TR><TH>Ranking after round 3</TH></TR>
|
<TR>
|
||||||
<TR><TD><PRE>
|
<TH>Ranking after round 3</TH>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD><PRE>
|
||||||
<b><u>Tit Name Rati F/M Club Cou Pts Res Vic #Bla BC1 S B </u></b>
|
<b><u>Tit Name Rati F/M Club Cou Pts Res Vic #Bla BC1 S B </u></b>
|
||||||
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
|
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
|
||||||
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
|
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
|
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
|
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
|
||||||
<A href='#Top'>Top of Page</A>
|
<A href='#Top'>Top of Page</A>
|
||||||
</PRE></TD></TR>
|
</PRE>
|
||||||
<TR><TH class='rh'><A NAME='Round1' style='color: black'>Round 1 (01-01-2019)</A></TH></TR>
|
</TD>
|
||||||
<TR><TD><PRE>
|
</TR>
|
||||||
|
<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)
|
1 Libpairtwo Player 2 ( 3) <b>1-0 </b>Libpairtwo Player 4 ( 1)
|
||||||
2 Libpairtwo Player 3 ( 2) <b>0-1 </b>Libpairtwo Player 1 ( 4)
|
2 Libpairtwo Player 3 ( 2) <b>0-1 </b>Libpairtwo Player 1 ( 4)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<A HREF="#Top">(Go to Top)</A>
|
<A HREF="#Top">(Go to Top)</A>
|
||||||
</TD>
|
</TD>
|
||||||
<TR><TH class='rh'><A NAME='Round2' style='color: black'>Round 2 (06-01-2019)</A></TH></TR>
|
<TR>
|
||||||
<TR><TD><PRE>
|
<TH class='rh'><A NAME='Round2' style='color: black'>Round 2 (06-01-2019)</A></TH>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD><PRE>
|
||||||
1 Libpairtwo Player 1 ( 4) <b>0-1 </b>Libpairtwo Player 2 ( 3)
|
1 Libpairtwo Player 1 ( 4) <b>0-1 </b>Libpairtwo Player 2 ( 3)
|
||||||
2 Libpairtwo Player 3 ( 2) <font color='red'> Bye</font>
|
2 Libpairtwo Player 3 ( 2) <font color='red'> Bye</font>
|
||||||
Libpairtwo Player 4 ( 1)<font color='red'> Absent </font>
|
Libpairtwo Player 4 ( 1)<font color='red'> Absent </font>
|
||||||
@ -96,16 +210,20 @@ a:hover { text-decoration:none ; color: red;}
|
|||||||
|
|
||||||
<A HREF="#Top">(Go to Top)</A>
|
<A HREF="#Top">(Go to Top)</A>
|
||||||
</TD>
|
</TD>
|
||||||
<TR><TH class='rh'><A NAME='Round3' style='color: black'>Round 3 (11-01-2019)</A></TH></TR>
|
<TR>
|
||||||
<TR><TD><PRE>
|
<TH class='rh'><A NAME='Round3' style='color: black'>Round 3 (11-01-2019)</A></TH>
|
||||||
1 Libpairtwo Player 4 ( 1) <b>½-½ </b>Libpairtwo Player 1 ( 4)
|
</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>
|
2 Libpairtwo Player 2 ( 3) <font color='red'> Bye</font>
|
||||||
Libpairtwo Player 3 ( 2)<font color='red'> Absent </font>
|
Libpairtwo Player 3 ( 2)<font color='red'> Absent </font>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<A HREF="#Top">(Go to Top)</A>
|
<A HREF="#Top">(Go to Top)</A>
|
||||||
</TD>
|
</TD>
|
||||||
</table></div>
|
</table>
|
||||||
|
</div>
|
||||||
<!-- ================= -->
|
<!-- ================= -->
|
||||||
<!-- GRILLE AMERICAINE -->
|
<!-- GRILLE AMERICAINE -->
|
||||||
<!-- ================= -->
|
<!-- ================= -->
|
||||||
@ -114,7 +232,8 @@ a:hover { text-decoration:none ; color: red;}
|
|||||||
<TR>
|
<TR>
|
||||||
<TH colspan='14'>
|
<TH colspan='14'>
|
||||||
<FONT size='+2'>American Ranking</FONT>
|
<FONT size='+2'>American Ranking</FONT>
|
||||||
<A name=Americaine></A></TH></TR>
|
<A name=Americaine></A></TH>
|
||||||
|
</TR>
|
||||||
|
|
||||||
<TR bgcolor='#cccccc'>
|
<TR bgcolor='#cccccc'>
|
||||||
<TD class='thr'> </TD>
|
<TD class='thr'> </TD>
|
||||||
@ -133,83 +252,89 @@ a:hover { text-decoration:none ; color: red;}
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class='tdr' bgcolor='#eeeeee'> 1</td>
|
<td bgcolor='#eeeeee' class='tdr'> 1</td>
|
||||||
<td class='tdl' bgcolor='#eeeeee'><B>Libpairtwo Player 2 (FM)</B></td>
|
<td bgcolor='#eeeeee' class='tdl'><B>Libpairtwo Player 2 (FM)</B></td>
|
||||||
<td class='tdr' bgcolor='#eeeeee'>1802</td>
|
<td bgcolor='#eeeeee' class='tdr'>1802</td>
|
||||||
<td class='tdr' bgcolor='#eeeeee'><B>3.0</B></td>
|
<td bgcolor='#eeeeee' class='tdr'><B>3.0</B></td>
|
||||||
<td class='tdr' bgcolor='#eeeeee'><i>2602</i></td>
|
<td bgcolor='#eeeeee' class='tdr'><i>2602</i></td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'> 4W +</td>
|
<td bgcolor='#eeeeee' class='tdc'> 4W +</td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'> 2B +</td>
|
<td bgcolor='#eeeeee' class='tdc'> 2B +</td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'>bye</td>
|
<td bgcolor='#eeeeee' class='tdc'>bye</td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td>
|
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td>
|
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td>
|
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td>
|
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'><i> 0.00</i></td>
|
<td bgcolor='#eeeeee' class='tdc'><i> 0.00</i></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class='tdr' bgcolor='#cccccc'> 2</td>
|
<td bgcolor='#cccccc' class='tdr'> 2</td>
|
||||||
<td class='tdl' bgcolor='#cccccc'><B>Libpairtwo Player 1 (*)</B></td>
|
<td bgcolor='#cccccc' class='tdl'><B>Libpairtwo Player 1 (*)</B></td>
|
||||||
<td class='tdr' bgcolor='#cccccc'>1801</td>
|
<td bgcolor='#cccccc' class='tdr'>1801</td>
|
||||||
<td class='tdr' bgcolor='#cccccc'><B>1.5</B></td>
|
<td bgcolor='#cccccc' class='tdr'><B>1.5</B></td>
|
||||||
<td class='tdr' bgcolor='#cccccc'><i>1810</i></td>
|
<td bgcolor='#cccccc' class='tdr'><i>1810</i></td>
|
||||||
<td class='tdc' bgcolor='#cccccc'> 3B +</td>
|
<td bgcolor='#cccccc' class='tdc'> 3B +</td>
|
||||||
<td class='tdc' bgcolor='#cccccc'> 1W -</td>
|
<td bgcolor='#cccccc' class='tdc'> 1W -</td>
|
||||||
<td class='tdc' bgcolor='#cccccc'> 4B =</td>
|
<td bgcolor='#cccccc' class='tdc'> 4B =</td>
|
||||||
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td>
|
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
|
||||||
<td class='tdc' bgcolor='#cccccc'><i>0</i></td>
|
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
|
||||||
<td class='tdc' bgcolor='#cccccc'><i>0</i></td>
|
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
|
||||||
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td>
|
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
|
||||||
<td class='tdc' bgcolor='#cccccc'><i> 0.00</i></td>
|
<td bgcolor='#cccccc' class='tdc'><i> 0.00</i></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class='tdr' bgcolor='#eeeeee'> 3</td>
|
<td bgcolor='#eeeeee' class='tdr'> 3</td>
|
||||||
<td class='tdl' bgcolor='#eeeeee'><B>Libpairtwo Player 3 (IM)</B></td>
|
<td bgcolor='#eeeeee' class='tdl'><B>Libpairtwo Player 3 (IM)</B></td>
|
||||||
<td class='tdr' bgcolor='#eeeeee'>1803</td>
|
<td bgcolor='#eeeeee' class='tdr'>1803</td>
|
||||||
<td class='tdr' bgcolor='#eeeeee'><B>1.0</B></td>
|
<td bgcolor='#eeeeee' class='tdr'><B>1.0</B></td>
|
||||||
<td class='tdr' bgcolor='#eeeeee'><i>1331</i></td>
|
<td bgcolor='#eeeeee' class='tdr'><i>1331</i></td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'> 2W -</td>
|
<td bgcolor='#eeeeee' class='tdc'> 2W -</td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'>bye</td>
|
<td bgcolor='#eeeeee' class='tdc'>bye</td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'>...</td>
|
<td bgcolor='#eeeeee' class='tdc'>...</td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td>
|
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td>
|
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td>
|
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td>
|
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
|
||||||
<td class='tdc' bgcolor='#eeeeee'><i> 0.00</i></td>
|
<td bgcolor='#eeeeee' class='tdc'><i> 0.00</i></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class='tdr' bgcolor='#cccccc'> 4</td>
|
<td bgcolor='#cccccc' class='tdr'> 4</td>
|
||||||
<td class='tdl' bgcolor='#cccccc'><B>Libpairtwo Player 4 (GM)</B></td>
|
<td bgcolor='#cccccc' class='tdl'><B>Libpairtwo Player 4 (GM)</B></td>
|
||||||
<td class='tdr' bgcolor='#cccccc'>1804</td>
|
<td bgcolor='#cccccc' class='tdr'>1804</td>
|
||||||
<td class='tdr' bgcolor='#cccccc'><B>0.5</B></td>
|
<td bgcolor='#cccccc' class='tdr'><B>0.5</B></td>
|
||||||
<td class='tdr' bgcolor='#cccccc'><i>1626</i></td>
|
<td bgcolor='#cccccc' class='tdr'><i>1626</i></td>
|
||||||
<td class='tdc' bgcolor='#cccccc'> 1B -</td>
|
<td bgcolor='#cccccc' class='tdc'> 1B -</td>
|
||||||
<td class='tdc' bgcolor='#cccccc'>...</td>
|
<td bgcolor='#cccccc' class='tdc'>...</td>
|
||||||
<td class='tdc' bgcolor='#cccccc'> 2W =</td>
|
<td bgcolor='#cccccc' class='tdc'> 2W =</td>
|
||||||
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td>
|
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
|
||||||
<td class='tdc' bgcolor='#cccccc'><i>0</i></td>
|
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
|
||||||
<td class='tdc' bgcolor='#cccccc'><i>0</i></td>
|
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
|
||||||
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td>
|
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
|
||||||
<td class='tdc' bgcolor='#cccccc'><i> 0.00</i></td>
|
<td bgcolor='#cccccc' class='tdc'><i> 0.00</i></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</TABLE></DIV>
|
</TABLE>
|
||||||
|
</DIV>
|
||||||
|
|
||||||
<P align='center'><A href='#Top'><FONT size='-1'>Top of Page</FONT></A>
|
<P align='center'><A href='#Top'><FONT size='-1'>Top of Page</FONT></A>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
<!-- ========= -->
|
<!-- ========= -->
|
||||||
<!-- COPYRIGHT -->
|
<!-- COPYRIGHT -->
|
||||||
<!-- ========= -->
|
<!-- ========= -->
|
||||||
<p><TABLE border='0'>
|
<p>
|
||||||
<TR><TD align='center' bgColor='#000090'>
|
<TABLE border='0'>
|
||||||
|
<TR>
|
||||||
|
<TD align='center' bgColor='#000090'>
|
||||||
<FONT color='white' size='-1'><b>(©) FRBE 2005</b></font></TD>
|
<FONT color='white' size='-1'><b>(©) FRBE 2005</b></font></TD>
|
||||||
<TD align='center' bgColor='#000090'>
|
<TD align='center' bgColor='#000090'>
|
||||||
<FONT color='white' size='-1'><b>PairTwo 6.13 (2015/08/10)</b></font></td></tr>
|
<FONT color='white' size='-1'><b>PairTwo 6.13 (2015/08/10)</b></font></td>
|
||||||
</TD></TR></TABLE></p>
|
</tr>
|
||||||
</body></html>
|
</TD></TR></TABLE>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Constants
|
* Class Constants
|
||||||
*
|
*
|
||||||
@ -27,11 +28,28 @@ use JeroenED\Libpairtwo\Enums\Result;
|
|||||||
*/
|
*/
|
||||||
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];
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Color
|
* Enum Color
|
||||||
*
|
*
|
||||||
@ -26,7 +27,9 @@ use MyCLabs\Enum\Enum;
|
|||||||
*/
|
*/
|
||||||
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';
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Gameresult
|
* Enum Gameresult
|
||||||
*
|
*
|
||||||
@ -26,17 +27,29 @@ use MyCLabs\Enum\Enum;
|
|||||||
*/
|
*/
|
||||||
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';
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Gender
|
* Enum Gender
|
||||||
*
|
*
|
||||||
@ -26,7 +27,9 @@ use MyCLabs\Enum\Enum;
|
|||||||
*/
|
*/
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Result
|
* Enum Result
|
||||||
*
|
*
|
||||||
@ -26,15 +27,25 @@ use MyCLabs\Enum\Enum;
|
|||||||
*/
|
*/
|
||||||
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';
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Tiebreak
|
* Enum Tiebreak
|
||||||
*
|
*
|
||||||
@ -26,27 +27,49 @@ use MyCLabs\Enum\Enum;
|
|||||||
*/
|
*/
|
||||||
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";
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Title
|
* Enum Title
|
||||||
*
|
*
|
||||||
@ -26,17 +27,29 @@ use MyCLabs\Enum\Enum;
|
|||||||
*/
|
*/
|
||||||
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';
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum TournamentSystem
|
* Enum TournamentSystem
|
||||||
*
|
*
|
||||||
@ -26,8 +27,11 @@ use MyCLabs\Enum\Enum;
|
|||||||
*/
|
*/
|
||||||
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';
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception IncompatibleReaderException
|
* Exception IncompatibleReaderException
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception LibpairtwoException
|
* Exception LibpairtwoException
|
||||||
*
|
*
|
||||||
@ -12,6 +13,8 @@
|
|||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Exceptions;
|
namespace JeroenED\Libpairtwo\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception LibpairtwoException
|
* Exception LibpairtwoException
|
||||||
*
|
*
|
||||||
@ -22,6 +25,6 @@ namespace JeroenED\Libpairtwo\Exceptions;
|
|||||||
* @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
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
39
src/Game.php
39
src/Game.php
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Games
|
* Class Games
|
||||||
*
|
*
|
||||||
@ -13,8 +14,6 @@
|
|||||||
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
|
||||||
@ -29,26 +28,12 @@ use DateTime;
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class IOFactory
|
* Class IOFactory
|
||||||
*
|
*
|
||||||
@ -14,7 +15,6 @@ 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
|
||||||
@ -39,13 +39,13 @@ abstract class IOFactory
|
|||||||
'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
|
||||||
*/
|
*/
|
||||||
@ -57,8 +57,7 @@ abstract class IOFactory
|
|||||||
|
|
||||||
// create reader class
|
// create reader class
|
||||||
$readerClass = self::$Readers[ $type ];
|
$readerClass = self::$Readers[ $type ];
|
||||||
$reader = new $readerClass;
|
|
||||||
|
|
||||||
return $reader;
|
return new $readerClass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface ReaderInterface
|
* Interface ReaderInterface
|
||||||
*
|
*
|
||||||
@ -12,8 +13,6 @@
|
|||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Interfaces;
|
namespace JeroenED\Libpairtwo\Interfaces;
|
||||||
|
|
||||||
use JeroenED\Libpairtwo\Tournament;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface ReaderInterface
|
* Interface ReaderInterface
|
||||||
*
|
*
|
||||||
@ -30,7 +29,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Pairing
|
* Class Pairing
|
||||||
*
|
*
|
||||||
@ -28,18 +29,11 @@ use JeroenED\Libpairtwo\Enums\Result;
|
|||||||
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;
|
|
||||||
}
|
}
|
||||||
|
439
src/Player.php
439
src/Player.php
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Player
|
* Class Player
|
||||||
*
|
*
|
||||||
@ -12,9 +13,9 @@
|
|||||||
|
|
||||||
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
|
||||||
@ -29,25 +30,19 @@ use DateTime;
|
|||||||
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,6 +224,7 @@ 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
|
||||||
@ -225,32 +232,17 @@ class Player
|
|||||||
$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,67 +256,68 @@ 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++;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $total;
|
/**
|
||||||
|
* 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 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reader Pairtwo6
|
* Reader Pairtwo6
|
||||||
*
|
*
|
||||||
@ -10,9 +11,10 @@
|
|||||||
* @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,7 +27,6 @@ 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
|
||||||
@ -39,11 +40,22 @@ use DateTime;
|
|||||||
*/
|
*/
|
||||||
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,16 +71,11 @@ 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)
|
||||||
@ -76,6 +83,7 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
if (isset($this->BinaryData[ $key ])) {
|
if (isset($this->BinaryData[ $key ])) {
|
||||||
return $this->BinaryData[ $key ];
|
return $this->BinaryData[ $key ];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,10 +98,64 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
$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;
|
||||||
|
$category = $this->readData('Int', substr($swscontents, $offset, $length));
|
||||||
|
if ($category != 0) {
|
||||||
|
$this->Tournament->addCategory('+' . $category);
|
||||||
|
}
|
||||||
$offset += $length;
|
$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);
|
||||||
@ -748,6 +815,7 @@ 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':
|
||||||
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reader Swar-4
|
* Reader Swar-4
|
||||||
*
|
*
|
||||||
@ -9,8 +10,11 @@
|
|||||||
* @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,7 +27,6 @@ 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
|
||||||
@ -38,30 +41,11 @@ use DateTime;
|
|||||||
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);
|
||||||
@ -357,13 +430,13 @@ class Swar4 implements ReaderInterface
|
|||||||
$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);
|
||||||
@ -453,53 +526,54 @@ class Swar4 implements ReaderInterface
|
|||||||
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);
|
||||||
@ -526,6 +600,7 @@ class Swar4 implements ReaderInterface
|
|||||||
* @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;
|
||||||
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
1378
src/Tournament.php
1378
src/Tournament.php
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user