Compare commits

...

No commits in common. "v1.0rc1" and "master" have entirely different histories.

61 changed files with 8054 additions and 2689 deletions

7
.gitattributes vendored
View File

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

15
.gitignore vendored
View File

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

View File

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

View File

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

View File

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

12
.php_cs
View File

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

View File

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

View File

@ -1,3 +1,62 @@
# CHANGELOG
1. 0-0#
## v2.0 (Release: aa-bbb-cccc)
* NEW FEATURE: `Game::Board` for getting the board number of the game
* MAJOR CHANGE: Getter and setter methods have been removed. (Please see [0d8a325](https://github.com/JeroenED/libpairtwo/commit/0d8a325eb501b775830f68fa6f600f9f4ca5588c) for more info)
* MAJOR CHANGE: Changed license to AGPL-3.0
* CHANGE: Some fields has been renamed to match coding guideline (Please see [1ab96fa](https://github.com/JeroenED/libpairtwo/commit/1ab96fa04782c1b0f2b6bb9d1bac8397a74ab38e) for more info)
* CHANGE: Logo has been redesigned
* CHANGE: Phpdoc is used again for docs generation
* CHANGE: `Tiebreak::American` and all its uses were removed (Please see [a6015ae](https://github.com/JeroenED/libpairtwo/commit/a6015ae8169f0973f4937605d0f807aacc233630) for more info)
* CHANGE: `Tournament::calculateSonneborn()` did not use a virtual opponent for bye results
* BUGFIX: `Tournament::calculateMutualResult()` returned a value even it not all players did not play each other
## v1.2 (Release: 28-sep-2019)
* NEW READER: `Readers\Swar-4` for reading out files created with SWAR version 4.
* NEW FEATURE: `Tournament::getArbiters()` for multiple arbiters in 1 tournament
* ENHANCEMENT: `Class::getBinaryData()` methods return null if field is non-existent
* ENHANCEMENT: The template in distributions provides a more usable starting implementation
* ENHANCEMENT: The template in distributions is renamed to template.php
* CHANGE: `Tournament::getArbiter()` accepts a `int` parameter representing the order of the arbiters
* BUGFIX: `Player:getId()` returned elo instead of id
* BUGFIX: `Tournament::calculateBuchholz()` did not return the correct score when player had unplayed rounds
* BUGFIX: `Tournament::calculateMutualResult()` returned NULL if result was invalid
* BUGFIX: `Tournament::calculateBaumbach()` treated bye as won
* BUGFIX: `Tournament::calculateAverageRating()` returned NaN if no games were played
* BUGFIX: Distributions could be created from a branch other than master
## v1.1.2 (Release: 21-jun-2019)
* ENHANCEMENT: Added update section to dist/readme.md
* MAJOR BUGFIX: `Game::GetResult` threw fatal error `Cannot access parent:: when current class scope has no parent`
## v1.1.1 (Released: 20-jun-2019)
* NEW FEATURE: Added clean-dist and clean-dev targets
* ENHANCEMENT: Better Docs generation
* ENHANCEMENT: Resized logo in Doxygen for better fit
* ENHANCEMENT: Doxygen takes branch name or version tag as `PROJECT_NUMBER`
* CHANGE: Version tag directly put in distribution filename
* CHANGE: `Tournament::GameExists()` renamed to `Tournament::gameExists()`
* CHANGE: Updated composer metadata
* CHANGE: Some setters changed to fluent setters. (More info: [7aca350](https://github.com/JeroenED/libpairtwo/commit/7aca35057c10d2b982f93a698499c0c01df2fdc5))
* CHANGE: Kashdan and Soccer Kashdan are combined in 1 function
* BUGFIX: Tagging did not work
## v1.1 (Released: 20-jun-2019)
* NEW FEATURE: Libpairtwo distribution releases (use these if you don't have knowledge of composer or dependency management)
* NEW FEATURE: Soccer Kashdan (aka: kashdan using 3-1-0 scoring)
* MAJOR CHANGE: Model Classes has been removed
* CHANGE: Deprecated `sws::class` was removed
* CHANGE: Added a logo to the project
* CHANGE: Replaced PhpDoc with Doxygen
* BUGFIX: `Tournament::getParticipants()` did not return a correct value
## v1.0.2 (Released: 05-jun-2019)
* NEW FEATURE: `Player::getPlayedGames()` to return the number of played games
* BUGFIX: `Tournament::calculateBuchholz()` always returned 0
* BUGFIX: `Tournament::calculateMutualResult()` only took account of last tiebreak instead all previous
## v1.0.1 (Released: 04-jun-2019)
* BUGFIX: `Round::getBye()` did not return bye players
## v1.0 (Released: 03-jun-2019)
* Initial release

2494
Doxyfile Normal file

File diff suppressed because it is too large Load Diff

651
LICENSE.md Normal file
View File

@ -0,0 +1,651 @@
GNU Affero General Public License
=================================
_Version 3, 19 November 2007_
_Copyright © 2007 Free Software Foundation, Inc. &lt;<http://fsf.org/>&gt;_
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
## Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: **(1)** assert copyright on the software, and **(2)** offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
## TERMS AND CONDITIONS
### 0. Definitions
“This License” refers to version 3 of the GNU Affero General Public License.
“Copyright” also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
“The Program” refers to any copyrightable work licensed under this
License. Each licensee is addressed as “you”. “Licensees” and
“recipients” may be individuals or organizations.
To “modify” a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a “modified version” of the
earlier work or a work “based on” the earlier work.
A “covered work” means either the unmodified Program or a work based
on the Program.
To “propagate” a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To “convey” a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays “Appropriate Legal Notices”
to the extent that it includes a convenient and prominently visible
feature that **(1)** displays an appropriate copyright notice, and **(2)**
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
### 1. Source Code
The “source code” for a work means the preferred form of the work
for making modifications to it. “Object code” means any non-source
form of a work.
A “Standard Interface” means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The “System Libraries” of an executable work include anything, other
than the work as a whole, that **(a)** is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and **(b)** serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
“Major Component”, in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
### 2. Basic Permissions
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
### 4. Conveying Verbatim Copies
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
### 5. Conveying Modified Source Versions
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
* **a)** The work must carry prominent notices stating that you modified
it, and giving a relevant date.
* **b)** The work must carry prominent notices stating that it is
released under this License and any conditions added under section 7.
This requirement modifies the requirement in section 4 to
“keep intact all notices”.
* **c)** You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
* **d)** If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
“aggregate” if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
### 6. Conveying Non-Source Forms
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
* **a)** Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
* **b)** Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either **(1)** a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or **(2)** access to copy the
Corresponding Source from a network server at no charge.
* **c)** Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
* **d)** Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
* **e)** Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A “User Product” is either **(1)** a “consumer product”, which means any
tangible personal property which is normally used for personal, family,
or household purposes, or **(2)** anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, “normally used” refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
“Installation Information” for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
### 7. Additional Terms
“Additional permissions” are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
* **a)** Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
* **b)** Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
* **c)** Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
* **d)** Limiting the use for publicity purposes of names of licensors or
authors of the material; or
* **e)** Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
* **f)** Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered “further
restrictions” within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
### 8. Termination
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated **(a)**
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and **(b)** permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
### 9. Acceptance Not Required for Having Copies
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
### 10. Automatic Licensing of Downstream Recipients
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An “entity transaction” is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
### 11. Patents
A “contributor” is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's “contributor version”.
A contributor's “essential patent claims” are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, “control” includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To “grant” such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either **(1)** cause the Corresponding Source to be so
available, or **(2)** arrange to deprive yourself of the benefit of the
patent license for this particular work, or **(3)** arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. “Knowingly relying” means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is “discriminatory” if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license **(a)** in connection with copies of the covered work
conveyed by you (or copies made from those copies), or **(b)** primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
### 12. No Surrender of Others' Freedom
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
### 13. Remote Network Interaction; Use with the GNU General Public License
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
### 14. Revised Versions of this License
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License “or any later version” applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
### 15. Disclaimer of Warranty
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
### 16. Limitation of Liability
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
### 17. Interpretation of Sections 15 and 16
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
_END OF TERMS AND CONDITIONS_
## How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the “copyright” line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a “Source” link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a “copyright disclaimer” for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
&lt;<http://www.gnu.org/licenses/>&gt;.

102
Makefile
View File

@ -1,25 +1,105 @@
.PHONY: help tests
.PHONY: help tests dist
.DEFAULT_GOAL := help
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
VERSION := $(if $(TAG),$(TAG),dev-$(BRANCH))
help:
@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
vendor/bin/phpunit
install-dev: ## Installs the required common devtools
@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
vendor/bin/phpunit --coverage-html build/coverage
docs: ## Generates api-docs
phpdoc -d ./src -t ./doc/api
view-coverage: ## Shows the code coverage report
open build/coverage/index.html
dist: ## Generates distribution
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
phpdoc -d ./src -t ./doc/api
dist: ## Generates distribution
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
cs: ## Fixes coding standard problems
vendor/bin/php-cs-fixer fix || true
php bin/phpcs || true
tag: ## Creates a new signed git tag
$(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=X.X.X"))
@echo Tagging $(TAG)
chag update $(TAG)
git add --all
git commit -m 'Release $(TAG)'
git tag -s $(TAG) -m 'Release $(TAG)'
git commit -m 'RELEASE: $(TAG) Release'
git tag -s $(TAG) -m 'RELEASE: $(TAG) Release'
make dist

View File

@ -1,35 +1,33 @@
# Lib Pairtwo
# 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>
This library reads sws-files that are saved using PairTwo developed by the Belgian Chess Federation (KBSB-FRBE).
This library reads out pairing files that are saved using common pairing applications
## Special thanks
* Daniel Halleux (Webmaster KBSB)
* Bernard Malfliet (Original developer Pairtwo)
* Sylvin De Vet (Arbiter at VSF championship 2019 who helped me explaining several tiebreaks and other arbiter related stuff)
## Licence
```
Libpairtwo: Export chess tournaments directly on the web
Copyright (C) 2018- Jeroen De Meerleer <schaak@jeroened.be>
The MIT License (MIT)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Copyright 2018- (c) Jeroen De Meerleer <schaak@jeroened.be>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
```

0
bin/.gitkeep Normal file
View File

View File

@ -1,9 +1,12 @@
{
"name": "jeroened/libpairtwo",
"type": "library",
"description": "PHP library that reads and writes SWS files from Pairtwo developed by the Belgian Chess Federation",
"keywords": ["chess", "frbe-kbsb", "pairtwo"],
"license": "MIT",
"description": "Export chess tournaments directly on the web",
"keywords": [
"chess",
"pairing"
],
"license": "AGPL-3.0-or-later",
"authors": [
{
"name": "Jeroen De Meerleer",
@ -13,13 +16,11 @@
}
],
"require": {
"php": "^7.1",
"myclabs/php-enum": "^1.6",
"php": "^7.1 || ^8.0",
"myclabs/php-enum": "^1.7",
"ext-iconv": "*"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"friendsofphp/php-cs-fixer": "^2.0"
},
"autoload": {
"psr-4": {

5
dist/composer-dist-installed.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"require": {
"jeroened/libpairtwo": "^1.2"
}
}

12
dist/composer-dist.json vendored Normal file
View File

@ -0,0 +1,12 @@
{
"repositories": [
{
"type": "git",
"url": "../"
}
],
"require": {
"jeroened/libpairtwo": "//VERSION//"
},
"minimum-stability": "dev"
}

32
dist/readme.md vendored Normal file
View File

@ -0,0 +1,32 @@
libpairtwo
==========
This distribution is a good start to use libpairtwo if you don't have knowledge of composer or dependency management.
How to use this distribution?
-----------------------------
The file `template.php` is the one you'll probably want to work with. The user will want to point your browser to this file.
The first 2 lines of this file contains 2 important variables. The most important one is the variable `$pairingfile`. You'll want to set this to your existing pairing file. The other variable (`$fileformat`) is a variable that defines the format of the above pairing file. For now only `Pairtwo-6`, `Pairtwo-5` and `Swar-4` are available. In the future more formats will become available.
Starting from line 8 you'll find some example code. The example codes gives the pairings and rankings of the currently used pairing file. If you need any modifications like adding your own template or you want to just write it to a file: go ahead it's all yours.
How to update the library?
--------------------------
If you want to upgrade the library to a new version you just need to remove the `vendor/` directory and upload the updated one.
It's important to remove the folder first because overwriting might cause problems because of residual files.
What if I need other dependencies?
----------------------------------
If you started to ask yourself this question, you'll probably know what composer and dependency management is? Therefore this section will become a little more advanced than the ones above.
To add another dependency you just run `composer require {{ your new dependency }}`
$ composer require phpoffice/phpspreadsheet
If you already have a project with other dependencies you'll only want to copy or edit the `template.php` file and run.
$ composer require jeroened/libpairtwo
If you want to update the libary while having other dependencies you don't want to remove `vendor/` directory or `composer.json` file. The `vendor/` folder contains these other dependencies and the `composer.json` contains the definitions of these dependencies. To update the library you only need to launch the update command.
$ composer update jeroened/libpairtwo

144
dist/template.php vendored Normal file
View File

@ -0,0 +1,144 @@
<?php
// EDIT ME!
$pairingfile = 'your pairing-file.swar';
$fileformat = 'Swar-4'; // Possible values: Pairtwo-5, Pairtwo-6, Swar-4
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My tournament</title>
<meta name="description" content="Libpairtwo">
<meta name="author" content="The chessclub">
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<?php
use JeroenED\Libpairtwo\IOFactory;
require_once 'vendor/autoload.php';
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
);
}
$reader = IOFactory::createReader($fileformat);
$reader->read($pairingfile);
// From here on you can start. Please use the examples on https://github.com/jeroened/libpairtwo/wiki
// You can also use the doc/api folder to get all possible methods and fields
// Below is an example of what can be used. Feel free to modify this.
echo '<h1>' . $reader->Tournament->Name . '</h1>' . PHP_EOL;
foreach ($reader->Tournament->Rounds as $round) {
echo '<h2>Round ' . ($round->RoundNo + 1) . ': ' . $round->Date->format('m/d/Y') . '</h2>' . PHP_EOL;
echo '<table>' . PHP_EOL;
echo '<thead>' . PHP_EOL;
echo '<tr><th></th><th>White</th><th>Black</th><th>Result</th></tr>' . PHP_EOL;
echo '</thead>' . PHP_EOL;
echo '<tbody>' . PHP_EOL;
foreach ($round->GamesByBoard as $game) {
echo '<tr>' . PHP_EOL;
echo '<td>' . ($game->Board + 1) . '</td>' . PHP_EOL;
echo '<td>' .
$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 '</tr>' . PHP_EOL;
}
echo '</tbody>' . PHP_EOL;
echo '</table>' . PHP_EOL;
echo '<p><strong>Bye:</strong> ';
$bye = [];
foreach ($round->Bye as $pairing) {
$bye[] = $pairing->Player->Name;
}
echo implode('; ', $bye);
echo '</p>' . PHP_EOL;
echo '<p><strong>Absent:</strong> ';
$bye = [];
foreach ($round->Absent as $pairing) {
$bye[] = $pairing->Player->Name;
}
echo implode('; ', $bye);
echo '</p>' . PHP_EOL;
}
echo '<h2>Global Rankings</h2>' . PHP_EOL;
echo '<table>' . PHP_EOL;
echo '<thead>' . PHP_EOL;
echo '<tr><th> </th><th>Name (elo)</th><th>Category</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->Ranking 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>' . $player->Category . '</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;
?>
<?php
echo '<h2>Rankings per Category</h2>' . PHP_EOL;
foreach ($reader->Tournament->Categories as $category) {
echo '<table>' . PHP_EOL;
echo '<caption>' . $category . '</caption>';
echo '<thead>' . PHP_EOL;
echo '<tr><th> </th><th>Name (elo)</th>' . PHP_EOL;
foreach ($reader->Tournament->Tiebreaks as $tiebreak) {
echo '<th>' . $tiebreak->getValue() . '</th>' . PHP_EOL;
}
echo '</tr>' . PHP_EOL;
echo '</thead>' . PHP_EOL;
echo '<tbody>' . PHP_EOL;
$rank = 1;
foreach ($reader->Tournament->RankingForCategory($category) as $player) {
echo '<tr>' . PHP_EOL;
echo '<td>' . $rank . '</td>' . PHP_EOL;
echo '<td>' . $player->Name . ' (' . $player->getElo($reader->Tournament->PriorityElo) . ')</td>' . PHP_EOL;
echo '<td>' . implode('</td><td>', $player->Tiebreaks) . '</td>' . PHP_EOL;
echo '</tr>' . PHP_EOL;
$rank++;
}
echo '</tbody>' . PHP_EOL;
echo '</table>' . PHP_EOL;
}
?>
<script src="js/scripts.js"></script>
</body>
</html>

0
doc/.gitkeep Normal file
View File

View File

@ -1,69 +0,0 @@
# Getting started
## Installing Libpairtwo
You can easily start using libpairtwo by installing it via composer
```bash
$ composer install JeroenED/libpairtwo
```
In you initialization code add the vendor/autoload.php
```php
require_once("vendor/autoload.php");
```
## Reading out a sws-file
Reading out a sws-file is very simple. Just call the Sws::ReadSws() method.
```php
$sws = JeroenED\Libpairtwo\Sws::ReadSws("Clubcompetition.sws");
```
This will return a usable object for reaching out for results, rankings, etc.
## Getting methods of the class
I didn't want to add the generated phpdoc in this library simply because it is generated.
The command to generate it yourself is just `$ phpdoc`. This will generate the docs in the doc/api folder.
## Examples
### Getting results of a tournament
```php
<?php
require_once("vendor/autoload.php");
use JeroenED\Libpairtwo\Sws;
$sws = Sws::ReadSws("Clubcompetition.sws");
$tournament = $sws->getTournament();
$calendar = $tournament->getRounds();
$roundNo = 1;
foreach ($calendar as $round) {
echo "Ronde: " . $roundNo . ' (' . $round->getDate()->format('Y/m/d') . PHP_EOL . ')'; $roundNo++;
foreach($round->getGames() as $game) {
if (!is_null($game->getResult())) {
echo (is_null($game->getWhite())) ? "bye" : $game->getWhite()->getPlayer()->getName();
echo " " . $game->getResult()->getValue() . " ";
echo (is_null($game->getBlack())) ? "bye" : $game->getBlack()->getPlayer()->getName();
echo PHP_EOL;
}
}
echo PHP_EOL;
```
### Getting rankings of the tournament
```php
<?php
require_once("vendor/autoload.php");
use JeroenED\Libpairtwo\Sws;
$sws = Sws::ReadSws("Clubcompetition.sws");
$tournament = $sws->getTournament();
$rankings = $tournament->getRanking();
$rankingNo = 1;
foreach ($rankings as $ranking) {
echo $rankingNo . '. ' . $ranking->getTitle()->getKey() . ' ' . $ranking->getName() . '(' . $ranking->getPoints() . '/' . $tournament->getNoOfRounds() . ')' . PHP_EOL;
}
echo PHP_EOL;
```

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpdoc>
<parser>
<target>doc/api</target>
</parser>
<transformer>
<target>doc/api</target>
</transformer>
<files>
<directory>src/</directory>
</files>
</phpdoc>

View File

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

BIN
res/categories_test.sws Normal file

Binary file not shown.

BIN
res/logo-darkback-111px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
res/logo-darkback-250px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
res/logo-darkback.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

194
res/logo-darkback.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
res/logo-lightback.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

194
res/logo-lightback.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 46 KiB

View File

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

View File

@ -1,17 +1,55 @@
<?php
/**
* Class Constants
*
* Static class for constants
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Result;
/**
* Class Constants
*
* Static class for constants
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Constants
{
const Won = [ Result::won, Result::wonforfait, Result::wonbye, Result::wonadjourned ];
const Draw = [ Result::draw, Result::drawadjourned];
const Lost = [ Result::absent, Result::bye, Result::lost, Result::adjourned ];
const NotPlayed = [ Result::bye, Result::wonbye, Result::absent ];
const Black = [ Color::black ];
const White = [ Color::white ];
public const BLACK = [Color::BLACK];
public const DRAW = [Result::DRAW, Result::DRAW_ADJOURNED];
public const LOST = [Result::ABSENT, Result::BYE, Result::LOST, Result::ADJOURNED];
public const NOTPLAYED = [Result::BYE, Result::WON_BYE, Result::ABSENT];
public const PLAYED = [
Result::WON,
Result::WON_FORFAIT,
Result::WON_BYE,
Result::WON_ADJOURNED,
Result::DRAW,
Result::DRAW_ADJOURNED,
Result::ABSENT,
Result::BYE,
Result::LOST,
Result::ADJOURNED
];
public const WHITE = [Color::WHITE];
public const WON = [Result::WON, Result::WON_FORFAIT, Result::WON_BYE, Result::WON_ADJOURNED];
}

View File

@ -1,18 +1,35 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 11/02/19
* Time: 14:51
* Enum Color
*
* List of all compatible colors
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
use MyCLabs\Enum\Enum;
/**
* Enum Color
*
* List of all compatible colors
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Color extends Enum
{
const black = 'B';
const white = 'W';
const none = '*';
public const BLACK = 'B';
public const NONE = '*';
public const WHITE = 'W';
}

View File

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

View File

@ -1,18 +1,35 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 25/01/19
* Time: 15:56
* Enum Gender
*
* List of all compatible genders
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
use MyCLabs\Enum\Enum;
/**
* Enum Gender
*
* List of all compatible genders
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Gender extends Enum
{
const Neutral = 'X'; // Unforturnately, Incompatible with Pairtwo (Dinos)
const Male = 'M';
const Female = 'F';
public const FEMALE = 'F';
public const MALE = 'M';
public const NEUTRAL = 'X'; // Unfortunately, Incompatible with Pairtwo (Dinos)
}

View File

@ -1,26 +1,51 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 11/02/19
* Time: 16:03
* Enum Result
*
* List of all compatible results
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
use MyCLabs\Enum\Enum;
/**
* Enum Result
*
* List of all compatible results
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Result extends Enum
{
const none = '*';
const lost = '0';
const draw = '0.5';
const won = '1';
const absent = '0 FF';
const wonforfait = '1 FF';
const adjourned = '0 A';
const drawadjourned = '0.5 A';
const wonadjourned = '1 A';
const bye = '0 Bye';
const wonbye = '1 Bye';
public const ABSENT = '0 FF';
public const ADJOURNED = '0 A';
public const BYE = '0 Bye';
public const DRAW = '0.5';
public const DRAW_ADJOURNED = '0.5 A';
public const LOST = '0';
public const NONE = '*';
public const WON = '1';
public const WON_ADJOURNED = '1 A';
public const WON_BYE = '1 Bye';
public const WON_FORFAIT = '1 FF';
}

View File

@ -1,31 +1,75 @@
<?php
/**
* Enum Tiebreak
*
* List of all compatible tiebreaks
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
use MyCLabs\Enum\Enum;
/**
* Enum Tiebreak
*
* List of all compatible tiebreaks
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Tiebreak extends Enum
{
const None = "";
const Keizer = "Keizer";
const Points = "Points";
const American = "American";
const Buchholz = "Buchholz";
const BuchholzMed = "Buchholz Median";
const BuchholzCut = "Buchholz Cut";
const Sonneborn = "Sonneborn-Berger";
const Kashdan = "Kashdan";
const Cumulative = "Cumulative";
const Between = "Mutual Result";
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?
const AveragePerformance = "Average performance";
const Performance = "Performance";
const Aro = "Average Rating";
const AroCut = "Average Rating Cut";
const BlackPlayed = "Black played";
const BlackWin = "Black Winned";
const Testmatch = "Testmatch";
const Drawing = "Drawing of lot";
public const ARO = "Average Rating";
public const AROCUT = "Average Rating Cut";
public const AVERAGE_PERFORMANCE = "Average performance";
public 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 BETWEEN = "Mutual Result";
public const BLACK_PLAYED = "Black played";
public const BLACK_WIN = "Black Winned";
public const BUCHHOLZ = "Buchholz";
public const BUCHHOLZ_CUT = "Buchholz Cut";
public const BUCHHOLZ_CUT_2 = "Buchholz Cut 2";
public const BUCHHOLZ_MED = "Buchholz Median";
public const BUCHHOLZ_MED_2 = "Buchholz Median 2";
public const CUMULATIVE = "Cumulative";
public const DRAWING_OF_LOT = "Drawing of lot";
public const KASHDAN = "Kashdan";
public const KEIZER = "Keizer";
public const KOYA = "Koya";
public const NONE = "";
public const PERFORMANCE = "Performance";
public const POINTS = "Points";
public const SOCCER_KASHDAN = "Soccer Kashdan";
public const SONNEBORN = "Sonneborn-Berger";
public const TESTMATCH = "Testmatch";
}

View File

@ -1,28 +1,55 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 25/01/19
* Time: 17:10
* Enum Title
*
* List of all compatible titles
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
use MyCLabs\Enum\Enum;
/**
* Enum Title
*
* List of all compatible titles
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Title extends Enum
{
const NONE = '*';
const ELO = 'Elo';
const NM = 'National Master';
const WCM = 'Woman Candidate Master';
const WFM = 'Woman Fide Master';
const CM = 'Candidate Master';
const WIM = 'Woman International Master';
const FM = 'Fide Master';
const WGM = 'Woman Grand Master';
const HM = 'Honorary International Master';
const IM = 'International Master';
const HG = 'Honorary Grand Master';
const GM = 'Grand Master';
public const CM = 'Candidate Master';
public const ELO = 'Elo';
public const FM = 'Fide Master';
public const GM = 'Grand Master';
public const HG = 'Honorary Grand Master';
public const HM = 'Honorary International Master';
public const IM = 'International Master';
public const NM = 'National Master';
public const NONE = '*';
public const WCM = 'Woman Candidate Master';
public const WFM = 'Woman Fide Master';
public const WGM = 'Woman Grand Master';
public const WIM = 'Woman International Master';
}

View File

@ -1,19 +1,37 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 19/01/19
* Time: 12:23
* Enum TournamentSystem
*
* List of all compatible tournament systems
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Enums;
use MyCLabs\Enum\Enum;
/**
* Enum TournamentSystem
*
* List of all compatible tournament systems
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class TournamentSystem extends Enum
{
const Swiss = 'Swiss';
const Closed = 'Closed';
const American = 'American';
const Keizer = 'Keizer';
public const AMERICAN = 'American';
public const CLOSED = 'Closed';
public const KEIZER = 'Keizer';
public const SWISS = 'Swiss';
}

View File

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

View File

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

View File

@ -1,49 +1,126 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 1/02/19
* Time: 17:17
* Class Games
*
* Class for a game of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Enums\Gameresult;
use JeroenED\Libpairtwo\Models\Game as GameModel;
class Game extends GameModel
/**
* Class Games
*
* Class for a game of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Game
{
/**
* This function gets the result from the game
* The pairing for this games as seen from black's side
*
* @var Pairing | null
*/
public function getResult(): Gameresult
public $Black;
/**
* The board where this game is held
*
* @var int
*/
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.
* Class Game contains the special field Result containing the result of the game
*
* @param string $key
*
* @return Gameresult
*/
public function __get(string $key)
{
if (!is_null(parent::getResult())) {
return parent::getResult();
if ($key == 'Result') {
return $this->calculateResult();
}
$whiteResult = $this->getWhite()->getResult();
$blackResult = $this->getBlack()->getResult();
return null;
}
/**
* Returns the result for the game.
* This method needs to be called from $Game->Result
*
* @return Gameresult
*/
private function calculateResult(): Gameresult
{
if (!is_null($this->CalculatedResult)) {
return $this->CalculatedResult;
}
$whiteResult = $this->White->Result;
$blackResult = $this->Black->Result;
$whitesplit = explode(" ", $whiteResult);
$blacksplit = explode(" ", $blackResult);
$special='';
if (isset($whitesplit[1]) && $whitesplit[1] != 'Bye') {
$special = ' ' . $whitesplit[1];
$special = '';
if (isset($whitesplit[ 1 ]) && $whitesplit[ 1 ] != 'Bye') {
$special = ' ' . $whitesplit[ 1 ];
}
if (isset($blacksplit[1]) && $blacksplit[1] != 'Bye') {
$special = ' ' . $blacksplit[1];
if (isset($blacksplit[ 1 ]) && $blacksplit[ 1 ] != 'Bye') {
$special = ' ' . $blacksplit[ 1 ];
}
if ($whitesplit[0] == '*') {
$whitesplit[0] = '';
if ($whitesplit[ 0 ] == '*') {
$whitesplit[ 0 ] = '';
}
if ($blacksplit[0] == '*') {
$blacksplit[0] = '';
if ($blacksplit[ 0 ] == '*') {
$blacksplit[ 0 ] = '';
}
$result = new Gameresult($whitesplit[0] . '-' . $blacksplit[0] . $special);
$this->setResult($result);
$result = new Gameresult($whitesplit[ 0 ] . '-' . $blacksplit[ 0 ] . $special);
$this->CalculatedResult = $result;
return $result;
}
/**
* Checks if 2 games are equal
*
* @param Game $game
*
* @return bool
*/
public function equals(Game $game): bool
{
return (
$this->White->Player === $game->White->Player &&
$this->Black->Player === $game->Black->Player &&
$this->Result->getKey() == $game->Result->getKey());
}
}

View File

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

View File

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

View File

@ -1,78 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 1/02/19
* Time: 17:16
*/
namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Enums\Gameresult;
use JeroenED\Libpairtwo\Pairing;
abstract class Game
{
/** @var Pairing|null */
private $white;
/** @var Pairing|null */
private $black;
/** @var GameResult|null */
private $result;
/**
* @return Pairing|null
*/
public function getWhite(): ?Pairing
{
return $this->white;
}
/**
* @param Pairing|null $white
* @return Game
*/
public function setWhite(?Pairing $white): Game
{
$this->white = $white;
return $this;
}
/**
* @return Pairing|null
*/
public function getBlack(): ?Pairing
{
return $this->black;
}
/**
* @param Pairing|null $black
* @return Game
*/
public function setBlack(?Pairing $black): Game
{
$this->black = $black;
return $this;
}
/**
* @return Gameresult|null
*/
public function getResult(): ?Gameresult
{
return $this->result;
}
/**
* @param Gameresult|null $result
* @return Game
*/
public function setResult(?Gameresult $result): Game
{
$this->result = $result;
return $this;
}
}

View File

@ -1,121 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 11/02/19
* Time: 14:48
*/
namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\Libpairtwo\Player;
abstract class Pairing
{
/** @var Player|null */
private $Player;
/** @var Player|null */
private $Opponent;
/** @var Color */
private $Color;
/** @var Result */
private $Result;
/** @var int */
private $Round;
/**
* @return Player|null
*/
public function getPlayer(): ?Player
{
return $this->Player;
}
/**
* @param Player|null $Player
* @return Pairing
*/
public function setPlayer(?Player $Player): Pairing
{
$this->Player = $Player;
return $this;
}
/**
* @return Player|null
*/
public function getOpponent(): ?Player
{
return $this->Opponent;
}
/**
* @param Player|null $Opponent
* @return Pairing
*/
public function setOpponent(?Player $Opponent): Pairing
{
$this->Opponent = $Opponent;
return $this;
}
/**
* @return Color
*/
public function getColor(): Color
{
return $this->Color;
}
/**
* @param Color $Color
* @return Pairing
*/
public function setColor(Color $Color): Pairing
{
$this->Color = $Color;
return $this;
}
/**
* @return Result
*/
public function getResult(): Result
{
return $this->Result;
}
/**
* @param Result $Result
* @return Pairing
*/
public function setResult(Result $Result): Pairing
{
$this->Result = $Result;
return $this;
}
/**
* @return int
*/
public function getRound(): int
{
return $this->Round;
}
/**
* @param int $Round
* @return Pairing
*/
public function setRound(int $Round): Pairing
{
$this->Round = $Round;
return $this;
}
}

View File

@ -1,255 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 19/01/19
* Time: 14:14
*/
namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Enums\Title;
use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Pairing;
use DateTime;
abstract class Player
{
/** @var string */
private $Name;
/** @var int[] */
private $Ids;
/** @var int[] */
private $Elos;
/** @var DateTime */
private $DateOfBirth;
/** @var float[] */
private $Tiebreaks = [];
/** @var string */
private $Nation;
// TODO: Implement categories
/** @var string */
private $Category;
/** @var Title */
private $Title;
/** @var Gender */
private $Gender;
/** @var Pairing[] */
private $Pairings = [];
/** @var bool|DateTime|int|string[] */
private $BinaryData;
/**
* @return string
*/
public function getName(): string
{
return $this->Name;
}
/**
* @param string $Name
* @return Player
*/
public function setName(string $Name): Player
{
$this->Name = $Name;
return $this;
}
/**
* @return string[]
*/
public function getIds(): ?array
{
return $this->Ids;
}
/**
* @param string[] $Ids
* @return Player
*/
public function setIds(array $Ids): Player
{
$this->Ids = $Ids;
return $this;
}
/**
* @return int[]
*/
public function getElos(): ?array
{
return $this->Elos;
}
/**
* @param int[] $Elos
* @return Player
*/
public function setElos(array $Elos): Player
{
$this->Elos = $Elos;
return $this;
}
/**
* @return \DateTime
*/
public function getDateOfBirth(): \DateTime
{
return $this->DateOfBirth;
}
/**
* @param \DateTime $DateOfBirth
* @return Player
*/
public function setDateOfBirth(\DateTime $DateOfBirth): Player
{
$this->DateOfBirth = $DateOfBirth;
return $this;
}
/**
* @return float[]
*/
public function getTiebreaks(): array
{
return $this->Tiebreaks;
}
/**
* @param float[] $Tiebreaks
* @return Player
*/
public function setTiebreaks(array $Tiebreaks): Player
{
$this->Tiebreaks = $Tiebreaks;
return $this;
}
/**
* example value: BEL
*
* @return string
*/
public function getNation(): string
{
return $this->Nation;
}
/**
* example value: BEL
*
* @param string $Nation
* @return Player
*/
public function setNation(string $Nation): Player
{
$this->Nation = $Nation;
return $this;
}
/**
* @return string
*/
public function getCategory(): string
{
return $this->Category;
}
/**
* @param string $Category
* @return Player
*/
public function setCategory(string $Category): Player
{
$this->Category = $Category;
return $this;
}
/**
* @return Title
*/
public function getTitle(): Title
{
return $this->Title;
}
/**
* @param Title $Title
* @return Player
*/
public function setTitle(Title $Title): Player
{
$this->Title = $Title;
return $this;
}
/**
* @return Gender
*/
public function getGender(): Gender
{
return $this->Gender;
}
/**
* @param Gender $Gender
* @return Player
*/
public function setGender(Gender $Gender): Player
{
$this->Gender = $Gender;
return $this;
}
/**
* @return Pairing[]
*/
public function getPairings(): array
{
return $this->Pairings;
}
/**
* @param Pairing[] $Pairings
* @return Player
*/
public function setPairings(array $Pairings): Player
{
$this->Pairings = $Pairings;
return $this;
}
/**
* @param string $Key
* @return bool|DateTime|int|string
*/
public function getBinaryData(string $Key)
{
return $this->BinaryData[$Key];
}
/**
* @param string $Key
* @param bool|int|DateTime|string $Value
* @return Player
*/
public function setBinaryData(string $Key, $Value): Player
{
$this->BinaryData[$Key] = $Value;
return $this;
}
}

View File

@ -1,100 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 1/02/19
* Time: 17:13
*/
namespace JeroenED\Libpairtwo\Models;
use DateTime;
use JeroenED\Libpairtwo\Game;
use JeroenED\Libpairtwo\Pairing;
abstract class Round
{
/** @var DateTime */
private $date;
/** @var Game[] */
private $games = [];
/** @var int */
private $roundNo;
/** @var Pairing[] */
private $pairings = [];
/**
* @return DateTime
*/
public function getDate(): DateTime
{
return $this->date;
}
/**
* @param DateTime $date
* @return Round
*/
public function setDate(DateTime $date): Round
{
$this->date = $date;
return $this;
}
/**
* @return Game[]
*/
public function getGames(): array
{
return $this->games;
}
/**
* @param Game[] $games
* @return Round
*/
public function setGames(array $games): Round
{
$this->games = $games;
return $this;
}
/**
* @return int
*/
public function getRoundNo(): int
{
return $this->roundNo;
}
/**
* @param int $roundNo
* @return Round
*/
public function setRoundNo(int $roundNo): Round
{
$this->roundNo = $roundNo;
return $this;
}
/**
* @return Pairing[]
*/
public function getPairings(): array
{
return $this->pairings;
}
/**
* @param Pairing[] $pairings
* @return Round
*/
public function setPairings(array $pairings): Round
{
$this->pairings = $pairings;
return $this;
}
}

View File

@ -1,564 +0,0 @@
<?php
/*
* The MIT License
*
* Copyright 2019 Jeroen De Meerleer <schaak@jeroened.be>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Enums\Tiebreak;
use JeroenED\Libpairtwo\Enums\TournamentSystem;
use JeroenED\Libpairtwo\Player;
use DateTime;
/**
* Description of Sws
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
*/
abstract class Tournament
{
/** @var string */
private $Name;
/** @var string */
private $Organiser;
/** @var int */
private $OrganiserClubNo;
/** @var string */
private $OrganiserClub;
/** @var string */
private $OrganiserPlace;
/** @var string */
private $OrganiserCountry;
/** @var int */
private $FideHomol;
/** @var DateTime */
private $StartDate;
/** @var DateTime */
private $EndDate;
/** @var string */
private $Arbiter;
/** @var int */
private $NoOfRounds;
/** @var Round[] */
private $Rounds = [];
/** @var int */
private $Participants;
/** @var string */
private $Tempo;
/** @var int */
private $NonRatedElo;
/** @var TournamentSystem */
private $System;
/** @var string */
private $FirstPeriod;
/** @var string */
private $SecondPeriod;
/** @var string */
private $Federation;
/** @var Player[] */
private $Players = [];
/** @var int */
private $Year;
/** @var Pairing[] */
private $Pairings = [];
/** @var Tiebreak[] */
private $Tiebreaks = [];
/** @var string */
private $PriorityElo = 'Fide';
/** @var string */
private $PriorityId = 'Nation';
/**
* @return string
*/
public function getName(): string
{
return $this->Name;
}
/**
* @param string $Name
* @return Tournament
*/
public function setName(string $Name): Tournament
{
$this->Name = $Name;
return $this;
}
/**
* @return string
*/
public function getOrganiser(): string
{
return $this->Organiser;
}
/**
* @param string $Organiser
* @return Tournament
*/
public function setOrganiser(string $Organiser): Tournament
{
$this->Organiser = $Organiser;
return $this;
}
/**
* @return int
*/
public function getOrganiserClubNo(): int
{
return $this->OrganiserClubNo;
}
/**
* @param int $OrganiserClubNo
* @return Tournament
*/
public function setOrganiserClubNo(int $OrganiserClubNo): Tournament
{
$this->OrganiserClubNo = $OrganiserClubNo;
return $this;
}
/**
* @return string
*/
public function getOrganiserClub(): string
{
return $this->OrganiserClub;
}
/**
* @param string $OrganiserClub
* @return Tournament
*/
public function setOrganiserClub(string $OrganiserClub): Tournament
{
$this->OrganiserClub = $OrganiserClub;
return $this;
}
/**
* @return string
*/
public function getOrganiserPlace(): string
{
return $this->OrganiserPlace;
}
/**
* @param string $OrganiserPlace
* @return Tournament
*/
public function setOrganiserPlace(string $OrganiserPlace): Tournament
{
$this->OrganiserPlace = $OrganiserPlace;
return $this;
}
/**
* @return string
*/
public function getOrganiserCountry(): string
{
return $this->OrganiserCountry;
}
/**
* @param string $OrganiserCountry
* @return Tournament
*/
public function setOrganiserCountry(string $OrganiserCountry): Tournament
{
$this->OrganiserCountry = $OrganiserCountry;
return $this;
}
/**
* @return int
*/
public function getFideHomol(): int
{
return $this->FideHomol;
}
/**
* @param int $FideHomol
* @return Tournament
*/
public function setFideHomol(int $FideHomol): Tournament
{
$this->FideHomol = $FideHomol;
return $this;
}
/**
* @return DateTime
*/
public function getStartDate(): DateTime
{
return $this->StartDate;
}
/**
* @param DateTime $StartDate
* @return Tournament
*/
public function setStartDate(DateTime $StartDate): Tournament
{
$this->StartDate = $StartDate;
return $this;
}
/**
* @return DateTime
*/
public function getEndDate(): DateTime
{
return $this->EndDate;
}
/**
* @param DateTime $EndDate
* @return Tournament
*/
public function setEndDate(DateTime $EndDate): Tournament
{
$this->EndDate = $EndDate;
return $this;
}
/**
* @return string
*/
public function getArbiter(): string
{
return $this->Arbiter;
}
/**
* @param string $Arbiter
* @return Tournament
*/
public function setArbiter(string $Arbiter): Tournament
{
$this->Arbiter = $Arbiter;
return $this;
}
/**
* @return int
*/
public function getNoOfRounds(): int
{
return $this->NoOfRounds;
}
/**
* @param int $NoOfRounds
* @return Tournament
*/
public function setNoOfRounds(int $NoOfRounds): Tournament
{
$this->NoOfRounds = $NoOfRounds;
return $this;
}
/**
* @return Round[]
*/
public function getRounds(): array
{
return $this->Rounds;
}
/**
* @param Round[] $Rounds
* @return Tournament
*/
public function setRounds(array $Rounds): Tournament
{
$this->Rounds = $Rounds;
return $this;
}
/**
* @return int
*/
public function getParticipants(): int
{
return $this->Participants;
}
/**
* @param int $Participants
* @return Tournament
*/
public function setParticipants(int $Participants): Tournament
{
$this->Participants = $Participants;
return $this;
}
/**
* @return string
*/
public function getTempo(): string
{
return $this->Tempo;
}
/**
* @param string $Tempo
* @return Tournament
*/
public function setTempo(string $Tempo): Tournament
{
$this->Tempo = $Tempo;
return $this;
}
/**
* @return int
*/
public function getNonRatedElo(): int
{
return $this->NonRatedElo;
}
/**
* @param int $NonRatedElo
* @return Tournament
*/
public function setNonRatedElo(int $NonRatedElo): Tournament
{
$this->NonRatedElo = $NonRatedElo;
return $this;
}
/**
* @return TournamentSystem
*/
public function getSystem(): TournamentSystem
{
return $this->System;
}
/**
* @param TournamentSystem $System
* @return Tournament
*/
public function setSystem(TournamentSystem $System): Tournament
{
$this->System = $System;
return $this;
}
/**
* @return string
*/
public function getFirstPeriod(): string
{
return $this->FirstPeriod;
}
/**
* @param string $FirstPeriod
* @return Tournament
*/
public function setFirstPeriod(string $FirstPeriod): Tournament
{
$this->FirstPeriod = $FirstPeriod;
return $this;
}
/**
* @return string
*/
public function getSecondPeriod(): string
{
return $this->SecondPeriod;
}
/**
* @param string $SecondPeriod
* @return Tournament
*/
public function setSecondPeriod(string $SecondPeriod): Tournament
{
$this->SecondPeriod = $SecondPeriod;
return $this;
}
/**
* @return string
*/
public function getFederation(): string
{
return $this->Federation;
}
/**
* @param string $Federation
* @return Tournament
*/
public function setFederation(string $Federation): Tournament
{
$this->Federation = $Federation;
return $this;
}
/**
* @return Player[]
*/
public function getPlayers(): array
{
return $this->Players;
}
/**
* @param Player[] $Players
* @return Tournament
*/
public function setPlayers(array $Players): Tournament
{
$this->Players = $Players;
return $this;
}
/**
* @return int
*/
public function getYear(): int
{
return $this->Year;
}
/**
* @param int $Year
* @return Tournament
*/
public function setYear(int $Year): Tournament
{
$this->Year = $Year;
return $this;
}
/**
* @return Pairing[]
*/
public function getPairings(): array
{
return $this->Pairings;
}
/**
* @param Pairing[] $Pairings
* @return Tournament
*/
public function setPairings(array $Pairings): Tournament
{
$this->Pairings = $Pairings;
return $this;
}
/**
* @return Tiebreak[]
*/
public function getTiebreaks(): array
{
return $this->Tiebreaks;
}
/**
* @param Tiebreak[] $Tiebreaks
* @return Tournament
*/
public function setTiebreaks(array $Tiebreaks): Tournament
{
$this->Tiebreaks = $Tiebreaks;
return $this;
}
/**
* @return string
*/
public function getPriorityElo(): string
{
return $this->PriorityElo;
}
/**
* @param string $PriorityElo
* @return Tournament
*/
public function setPriorityElo(string $PriorityElo): Tournament
{
$this->PriorityElo = $PriorityElo;
return $this;
}
/**
* @return string
*/
public function getPriorityId(): string
{
return $this->PriorityId;
}
/**
* @param string $PriorityId
* @return Tournament
*/
public function setPriorityId(string $PriorityId): Tournament
{
$this->PriorityId = $PriorityId;
return $this;
}
}

View File

@ -1,15 +1,73 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 11/02/19
* Time: 15:56
* Class Pairing
*
* Class for a pairing of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Models\Pairing as PairingModel;
use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Result;
class Pairing extends PairingModel
/**
* Class Pairing
*
* Class for a pairing of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Pairing
{
/**
* The number of the board where the game was held
*
* @var int
*/
public $Board;
/**
* The color of the player.
* Possible values are Black and White
*
* @var 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.
*
* @var Result
*/
public $Result;
/**
* The round of the game
*
* @var int
*/
public $Round;
}

View File

@ -1,51 +1,170 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 1/02/19
* Time: 11:26
* Class Player
*
* Class for a player of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Models\Player as PlayerModel;
use DateTime;
use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\Libpairtwo\Enums\Title;
/**
* Class Player
* @package JeroenED\Libpairtwo
*
* Class for a player of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Player extends PlayerModel
class Player
{
/**
* Adds a pairing to the tournament
* Binary data that was read out of the pairing file
*
* @param Pairing $pairing
* @var bool|DateTime|int|string[]
*/
public function addPairing(Pairing $pairing)
private $BinaryData;
/**
* The category the player belongs to
*
* @var string
*/
public $Category;
/**
* Birthday of the player
*
* @var DateTime
*/
public $DateOfBirth;
/**
* The Elos for the player. Possible keys are, but not limited to nation and fide
*
* @var int[]
*/
public $Elos;
/**
* The gender of the player. Possible values contain Male, Female and Neutral
*
* @var 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
*
* @var Pairing[]
*/
public $Pairings = [];
/**
* Tiebreak points of the player. These values are calculated when Tournament->Ranking is called
*
* @var float[]
*/
public $Tiebreaks = [];
/**
* 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
{
$newArray = $this->GetPairings();
$newArray[] = $pairing;
$this->setPairings($newArray);
$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 string $search
* @param Tournament $tournament
*
* @return Player[]
*/
public static function getPlayersByName(string $search, Tournament $tournament): array
public static function PlayersByName(string $search, Tournament $tournament): array
{
/** @var Player[] */
$players = $tournament->getPlayers();
/**
* @var Player[]
*/
$players = $tournament->Players;
/** @var Player[] */
/**
* @var Player[]
*/
$return = [];
foreach ($players as $player) {
if (fnmatch($search, $player->getName())) {
if (fnmatch($search, $player->Name)) {
$return[] = $player;
}
}
@ -54,101 +173,252 @@ class Player extends PlayerModel
}
/**
* 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
*
* @param Pairing $pairing
*/
public function addPairing(Pairing $pairing): void
{
$newArray = $this->Pairings;
$newArray[] = $pairing;
$this->Pairings = $newArray;
}
/**
* Returns the points of the player after round $round
*
* 1 Point is awarded for winning
* 0.5 points are awarded for draw
* 0 points are awarded for loss
*
* @param int $round
*
* @return float
*/
public function calculatePoints(int $round = -1, array $custompoints = []): float
{
$points = 0;
foreach ($this->Pairings as $key => $pairing) {
if ($key < $round || $round == -1) {
if ($pairing->Result == Result::WON_BYE) {
$points += (isset($custompoints[ 'bye' ])) ? $custompoints[ 'bye' ] : 1;
} else if ($pairing->Result == Result::ABSENT) {
$points += (isset($custompoints[ 'absent' ])) ? $custompoints[ 'absent' ] : 0;
} elseif (array_search($pairing->Result, Constants::WON) !== false) {
$points += (isset($custompoints[ 'win' ])) ? $custompoints[ 'win' ] : 1;
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$points += (isset($custompoints[ 'draw' ])) ? $custompoints[ 'draw' ] : 0.5;
} elseif (array_search($pairing->Result, Constants::LOST) !== false) {
$points += (isset($custompoints[ 'loss' ])) ? $custompoints[ 'loss' ] : 0;
}
}
}
return $points;
}
/**
* Returns the points of the player that should be used for tiebreaking systems.
*
* 1 Point is awarded for winning
* 0.5 points are awarded for draw
* 0.5 points for not played
*
* @return float
*/
public function calculatePointsForTiebreaks(): float
{
$points = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::NOTPLAYED) !== false) {
$points = $points + 0.5;
} elseif (array_search($pairing->Result, Constants::WON) !== false) {
$points = $points + 1;
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$points = $points + 0.5;
}
}
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 elo of elotype for the player
*
* @param string $type
*
* @return int
*/
public function getElo(string $type): int
public function getElo(string $type): ?int
{
return $this->getElos()[$type];
}
/**
* @param string $type
* @param int $value
* @return Player
*/
public function setElo(string $type, int $value): Player
{
$currentElos = $this->getElos();
$currentElos[$type] = $value;
$this->setElos($currentElos);
return $this;
return isset($this->Elos[ $type ]) ? $this->Elos[ $type ] : null;
}
/**
* 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->getElos()[$type];
return $this->Ids[ $type ];
}
/**
* @param string $type
* @param string $value
* @return Player
* Returns if player has played against all players of the array
*
* @param Player[] $players
*
* @return bool
*/
public function setId(string $type, string $value): Player
public function hasPlayedAllPlayersOfArray(array $players): bool
{
$currentIds = $this->getIds();
$currentIds[$type] = $value;
$this->setIds($currentIds);
return $this;
$ownkey = array_search($this, $players);
if ($ownkey !== false) {
unset($players[ $ownkey ]);
}
$total = 0;
foreach ($players as $player) {
if (array_search($player, $this->Opponents) !== false) {
$total++;
}
}
return $total == count($players);
}
/**
* Returns the number of won matches for the player
*
* @return int
*/
public function getNoOfWins()
private function noOfWins(): int
{
$wins = 0;
foreach ($this->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::Won) !== false) {
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::WON) !== false) {
$wins++;
}
}
return $wins;
}
/**
* @return float
* Returns all opponents of $this
*
* @return Player[]
*/
public function getPoints(): float
private function opponents()
{
$points = 0;
foreach ($this->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::Won) !== false) {
$points = $points + 1;
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
$points = $points + 0.5;
$return = [];
foreach ($this->Pairings as $pairing) {
if (!empty($pairing->Opponent)) {
$return[] = $pairing->Opponent;
}
}
return $points;
}
return $return;
}
/**
* Returns the number of played games of the player
*
* @return int
*/
public function getPerformance(string $type, int $unratedElo) : float
private function playedGames(): int
{
$total = 0;
$opponents = 0;
foreach ($this->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
$opponentElo = $pairing->getOpponent()->getElo($type);
$opponentElo = $opponentElo != 0 ? $opponentElo : $unratedElo;
if (array_search($pairing->getResult(), Constants::Won) !== false) {
$total += $opponentElo + 400;
} elseif (array_search($pairing->getResult(), Constants::Lost) !== false) {
$total += $opponentElo - 400;
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
$total += $opponentElo;
}
$opponents++;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::PLAYED) !== false) {
$total++;
}
}
return round($total / $opponents);
return $total;
}
/**
* 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;
}
/**
* Sets the identifier of type for the player
*
* Common possible values are Fide or National
*
* @param string $type
* @param string $value
*/
public function setId(string $type, string $value): void
{
$currentIds = $this->Ids;
$currentIds[ $type ] = $value;
$this->Ids = $currentIds;
}
}

View File

@ -1,75 +0,0 @@
<?php
namespace JeroenED\Libpairtwo\Readers\Models;
use JeroenED\Libpairtwo\Tournament;
abstract class Pairtwo6
{
/** @var string */
private $Release;
/** @var tournament */
private $Tournament;
/** @var bool|DateTime|int|string[] */
private $BinaryData;
/**
* @return string
*/
public function getRelease(): string
{
return $this->Release;
}
/**
* @param string $Release
* @return Pairtwo6
*/
public function setRelease(string $Release): Pairtwo6
{
$this->Release = $Release;
return $this;
}
/**
* @return Tournament
*/
public function getTournament(): Tournament
{
return $this->Tournament;
}
/**
* @param Tournament $Tournament
* @return Pairtwo6
*/
public function setTournament(Tournament $Tournament): Pairtwo6
{
$this->Tournament = $Tournament;
return $this;
}
/**
* @param string $Key
* @return bool|DateTime|int|string
*/
public function getBinaryData(string $Key)
{
return $this->BinaryData[$Key];
}
/**
* @param string $Key
* @param bool|int|DateTime|string $Value
* @return Pairtwo6
*/
public function setBinaryData(string $Key, $Value): Pairtwo6
{
$this->BinaryData[$Key] = $Value;
return $this;
}
}

File diff suppressed because it is too large Load Diff

669
src/Readers/Swar4.php Normal file
View File

@ -0,0 +1,669 @@
<?php
/**
* Reader Swar-4
*
* Reads out Swar-4 files
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Readers;
use DateTime;
use InvalidArgumentException;
use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\Libpairtwo\Enums\Tiebreak;
use JeroenED\Libpairtwo\Enums\Title;
use JeroenED\Libpairtwo\Enums\TournamentSystem;
use JeroenED\Libpairtwo\Exceptions\IncompatibleReaderException;
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
use JeroenED\Libpairtwo\Pairing;
use JeroenED\Libpairtwo\Player;
use JeroenED\Libpairtwo\Round;
use JeroenED\Libpairtwo\Tournament;
/**
* Reader Swar4
*
* Reads out Swar-4 files
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Swar4 implements ReaderInterface
{
/**
* @var array
*/
public const COMPATIBLE_VERSIONS = ['v4.'];
public const TEMPOS = [
[
'105 min/40 moves + 15 min. QPF',
'120 min/40 moves + 15 min. with incr. 30" starting from 40th move',
'120 min/40 moves + 30 min. QPF',
'120 min/10 moves + 30 min. avec incr. 30" starting from 40th move',
'120 min QPF',
'150 min QPF',
'60 min QPF',
'60 min with incr. 30"',
'65 min QPF',
'75 min with incr. 30"',
'90 min/40 moves + 15 min with incr. 30" starting from 1st move',
'90 min/40 moves + 30 min with incr. 30" starting from 1st move',
'90 min with incr. 30"',
'50 min with incr. 10"',
'other'
],
[
'10 min. with incr. 10"',
'10 min. with incr. 15"',
'10 min. with incr.5"',
'11 min. QPF',
'12 min. QPF',
'13 min. with incr.3"',
'13 min. with incr.5"',
'15 min. QPF',
'15 min. with incr. 10"',
'15 min. with incr. 15"',
'15 min. with incr.5"',
'20 min. QPF',
'20 min. with incr. 10"',
'20 min. with incr. 15"',
'20 min. with incr.5"',
'25 min. QPF',
'25 min. with incr. 10"',
'25 min. with incr. 15"',
'25 min. with incr.5"',
'30 min. QPF',
'45 min. QPF',
'8 min. with incr.4"',
'other'
],
[
'3 min. with incr. 2"',
'3 min. with incr. 3"',
'4 min. with incr. 2"',
'4 min. with incr. 3"',
'5 min. QPF',
'5 min. with incr. 2"',
'5 min. with incr. 3"',
'6 min. with incr. 2"',
'6 min. with incr. 3"',
'7 min. with incr. 2"',
'7 min. with incr. 3"',
'8 min. with incr. 2"',
'10 min. QPF',
'other'
]
];
/**
* 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
*
* @param string $filename
*
* @throws IncompatibleReaderException
*/
public function read(string $filename): void
{
$swshandle = fopen($filename, 'rb');
$this->Release = $this->readData('String', $swshandle);
if (array_search(substr($this->Release, 0, 3), self::COMPATIBLE_VERSIONS) === false) {
throw new IncompatibleReaderException("This file was not created with Swar 4");
}
$this->Tournament = new Tournament();
$this->Guid = $this->readData('String', $swshandle);
$this->MacAddress = $this->readData('String', $swshandle);
// [Tournoi]
$this->readData('String', $swshandle);
$this->Tournament->Name = $this->readData('String', $swshandle);
$this->Tournament->Organiser = $this->readData('String', $swshandle);
$this->Tournament->OrganiserClub = $this->readData('String', $swshandle);
$this->Tournament->OrganiserPlace = $this->readData('String', $swshandle);
$this->Tournament->addArbiter($this->readData('String', $swshandle));
$this->Tournament->addArbiter($this->readData('String', $swshandle));
$this->Tournament->StartDate = $this->readData('Date', $swshandle);
$this->Tournament->EndDate = $this->readData('Date', $swshandle);
// Tempo string is not variable and dependant on kind of tournament
$this->Tournament->TempoIndex = $this->readData('Int', $swshandle);
$this->Tournament->NoOfRounds = $this->readData('Int', $swshandle);
$this->Tournament->FRBEfrom = $this->readData('Int', $swshandle);
$this->Tournament->FRBEto = $this->readData('Int', $swshandle);
$this->Tournament->FIDEfrom = $this->readData('Int', $swshandle);
$this->Tournament->FIDEto = $this->readData('Int', $swshandle);
$this->Tournament->CatSepares = $this->readData('Int', $swshandle);
$this->Tournament->AfficherEloOuPays = $this->readData('Int', $swshandle);
$this->Tournament->FideHomol = $this->readData('Int', $swshandle);
$this->Tournament->FideId = $this->readData('String', $swshandle);
$this->Tournament->FideArbitre1 = $this->readData('String', $swshandle);
$this->Tournament->FideArbitre2 = $this->readData('String', $swshandle);
$this->Tournament->FideEmail = $this->readData('String', $swshandle);
$this->Tournament->FideRemarques = $this->readData('String', $swshandle);
switch ($this->readData('Int', $swshandle)) {
case 0:
case 1:
case 2:
case 3:
case 4:
default:
$system = TournamentSystem::SWISS;
break;
case 5:
case 6:
case 7:
$system = TournamentSystem::CLOSED;
break;
case 8:
case 9:
$system = TournamentSystem::AMERICAN;
break;
}
$this->Tournament->System = new TournamentSystem($system);
$this->Tournament->Dummy1 = $this->readData('Int', $swshandle);
$this->Tournament->Dummy2 = $this->readData('Int', $swshandle);
$this->Tournament->SW_AmerPresence = $this->readData('Int', $swshandle);
$this->Tournament->Plusieurs = $this->readData('Int', $swshandle);
$this->Tournament->FirstTable = $this->readData('Int', $swshandle);
$this->Tournament->SW321_Win = $this->readData('Int', $swshandle);
$this->Tournament->SW321_Nul = $this->readData('Int', $swshandle);
$this->Tournament->SW321_Los = $this->readData('Int', $swshandle);
$this->Tournament->SW321_Bye = $this->readData('Int', $swshandle);
$this->Tournament->SW321_Pre = $this->readData('Int', $swshandle);
$this->Tournament->EloUsed = $this->readData('Int', $swshandle);
$this->Tournament->TournoiStd = $this->readData('Int', $swshandle);
$this->Tournament->TbPersonel = $this->readData('Int', $swshandle);
$this->Tournament->ApparOrder = $this->readData('Int', $swshandle);
$this->Tournament->EloEqual = $this->readData('Int', $swshandle);
$this->Tournament->ByeValue = $this->readData('Int', $swshandle);
$this->Tournament->AbsValue = $this->readData('Int', $swshandle);
$this->Tournament->FF_Value = $this->readData('Int', $swshandle);
switch ($this->readData('Int', $swshandle)) {
case 0:
default:
$federation = '';
break;
case 1:
$federation = 'FRBE';
break;
case 2:
$federation = 'KBSB';
break;
case 3:
$federation = 'FEFB';
break;
case 4:
$federation = 'VSF';
break;
case 5:
$federation = 'SVDB';
break;
case 6:
$federation = 'FIDE';
break;
}
$this->Tournament->Federation = $federation;
$this->Tournament->NonRatedElo = 0;
$this->Tournament->OrganiserClubNo = 0;
// [DATES]
$this->readData('String', $swshandle);
$this->Tournament->Tempo = self::TEMPOS[ $this->Tournament->TournoiStd ][ $this->Tournament->TempoIndex ];
for ($i = 0; $i < $this->Tournament->NoOfRounds; $i++) {
$round = new Round();
$round->RoundNo = $i;
$round->Date = $this->readData('Date', $swshandle);
$this->Tournament->addRound($round);
}
// [TIE_BREAK]
$this->readData('String', $swshandle);
$tiebreaks = [];
for ($i = 0; $i < 5; $i++) {
switch ($this->readData('Int', $swshandle)) {
case 0:
default:
$tiebreak = Tiebreak::NONE;
break;
case 1:
$tiebreak = Tiebreak::BUCHHOLZ;
break;
case 2:
$tiebreak = Tiebreak::BUCHHOLZ_MED;
break;
case 3:
$tiebreak = Tiebreak::BUCHHOLZ_MED_2;
break;
case 4:
$tiebreak = Tiebreak::BUCHHOLZ_CUT;
break;
case 5:
$tiebreak = Tiebreak::BUCHHOLZ_CUT_2;
break;
case 6:
$tiebreak = Tiebreak::SONNEBORN;
break;
case 7:
$tiebreak = Tiebreak::CUMULATIVE;
break;
case 8:
$tiebreak = Tiebreak::BETWEEN;
break;
case 9:
$tiebreak = Tiebreak::KOYA;
break;
case 10:
$tiebreak = Tiebreak::BAUMBACH;
break;
case 11:
$tiebreak = Tiebreak::AVERAGE_PERFORMANCE;
break;
case 12:
$tiebreak = Tiebreak::ARO;
break;
case 13:
$tiebreak = Tiebreak::AROCUT;
break;
case 14:
$tiebreak = Tiebreak::BLACK_PLAYED;
break;
case 15:
$tiebreak = Tiebreak::BLACK_WIN;
break;
}
$tiebreaks[] = new Tiebreak($tiebreak);
}
$this->Tournament->Tiebreaks = $tiebreaks;
// [EXCLUSION]
$this->readData('String', $swshandle);
$this->Tournament->ExclusionType = $this->readData('Int', $swshandle);
$this->Tournament->ExclusionValue = $this->readData('String', $swshandle);
// [CATEGORIES]
$this->readData('String', $swshandle);
$this->Tournament->Catogory_type = $this->readData('Int', $swshandle);
for ($i = 0; $i <= 12; $i++) {
$category[ $i ][ 'Cat1' ] = $this->readData('String', $swshandle);
}
for ($i = 0; $i <= 12; $i++) {
$category[ $i ][ 'Cat2' ] = $this->readData('String', $swshandle);
}
$this->Tournament->Category = $category;
// [XTRA_POINTS]
$this->readData('String', $swshandle);
for ($i = 0; $i < 4; $i++) {
$extrapoints[ $i ][ 'pts' ] = $this->readData('Int', $swshandle);
$extrapoints[ $i ][ 'elo' ] = $this->readData('Int', $swshandle);
}
$this->Tournament->Extrapoints = $extrapoints;
// [JOUEURS]
$this->readData('String', $swshandle);
$roundNo = 0;
$playerNo = 0;
$this->Tournament->NumberOfPlayers = $this->readData('Int', $swshandle);
$pt = 0;
for ($i = 0; $i < $this->Tournament->NumberOfPlayers; $i++) {
$player = new Player();
$player->Classement = $this->readData('Int', $swshandle);
$player->Name = $this->readData('String', $swshandle);
$inscriptionNos[ $this->readData('Int', $swshandle) ] = $i;
$player->Rank = $this->readData('Int', $swshandle);
$player->CatIndex = $this->readData('Int', $swshandle);
$player->DateOfBirth = $this->readData('Date', $swshandle);
switch ($this->readData('Int', $swshandle)) {
case 1:
$gender = Gender::MALE;
break;
case 2:
$gender = Gender::FEMALE;
break;
default:
$gender = Gender::NEUTRAL;
break;
}
$player->Gender = new Gender($gender);
$player->Nation = $this->readData('String', $swshandle);
$player->setId('Nation', $this->readData('Int', $swshandle));
$player->setId('Fide', $this->readData('Int', $swshandle));
$player->Affliation = $this->readData('Int', $swshandle);
$player->setElo('Nation', $this->readData('Int', $swshandle));
$player->setElo('Fide', $this->readData('Int', $swshandle));
switch ($this->readData('Int', $swshandle)) {
case 1:
$title = Title::WCM;
break;
case 2:
$title = Title::WFM;
break;
case 3:
$title = Title::CM;
break;
case 4:
$title = Title::WIM;
break;
case 5:
$title = Title::FM;
break;
case 6:
$title = Title::WGM;
break;
case 7:
$title = Title::HM;
break;
case 8:
$title = Title::IM;
break;
case 9:
$title = Title::HG;
break;
case 10:
$title = Title::GM;
break;
case 0:
default:
$title = Title::NONE;
break;
}
$player->Title = new Title($title);
$player->setId('Club', $this->readData('Int', $swshandle));
$player->ClubName = $this->readData('String', $swshandle);
$player->NoOfMatchesNoBye = $this->readData('Int', $swshandle);
$player->Points = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
$player->AmericanPoints = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
for ($t = 0; $t < 5; $t++) {
$tiebreaks[ $t ] = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
}
$player->Tiebreak = $tiebreaks;
$player->Performance = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
$player->Absent = $this->readData('Int', $swshandle);
$player->AbsentRounds = $this->readData('String', $swshandle);
$player->ExtraPoints = $this->readData('Int', $swshandle);
$player->SpecialPoints = $this->readData('Int', $swshandle);
$player->AllocatedRounds = $this->readData('Int', $swshandle);
// [RONDE]
$this->readData('String', $swshandle);
if ($player->AllocatedRounds != 0) {
for ($j = 0; $j < $player->AllocatedRounds; $j++) {
$pairing[ $pt ][ 'player' ] = $i;
$pairing[ $pt ][ 'round' ] = $this->readData('Int', $swshandle) - 1;
$pairing[ $pt ][ 'table' ] = $this->readData('Int', $swshandle) - 1;
$pairing[ $pt ][ 'opponent' ] = $this->readData('Int', $swshandle);
$pairing[ $pt ][ 'result' ] = $this->readData('Hex', $swshandle);
$pairing[ $pt ][ 'color' ] = $this->readData('Int', $swshandle);
$pairing[ $pt ][ 'float' ] = $this->readData('Int', $swshandle);
$pairing[ $pt ][ 'extrapoints' ] = $this->readData('Int', $swshandle);
$pt++;
}
$this->Tournament->Pairing = $pairing;
}
$this->Tournament->addPlayer($player);
}
$ptn = 0;
while (isset($this->Tournament->Pairing[ $ptn ][ 'round' ])) {
$pairing = new Pairing();
$pairing->Player = $this->Tournament->playerById($this->Tournament->Pairing[ $ptn ][ 'player' ]);
$pairing->Round = $this->Tournament->Pairing[ $ptn ][ 'round' ];
if ($this->Tournament->Pairing[ $ptn ][ 'opponent' ] != 4294967295) {
$pairing->Opponent =
$this->Tournament->playerById($inscriptionNos[ $this->Tournament->Pairing[ $ptn ][ 'opponent' ] ]);
}
switch ($this->Tournament->Pairing[ $ptn ][ 'result' ]) {
case '1000':
$result = Result::LOST;
break;
case '01':
$result = Result::ABSENT;
break;
case '0010':
$result = Result::BYE;
break;
case '2000':
$result = Result::DRAW;
break;
case '4000':
$result = Result::WON;
break;
case '04':
$result = Result::WON_FORFAIT;
break;
case '40':
$result = Result::WON_BYE;
break;
case '00':
default:
$result = Result::NONE;
break;
}
if (array_search($this->Tournament->Pairing[ $ptn ][ 'table' ], [16383, 8191]) !== false) {
$result = Result::ABSENT;
}
$pairing->Result = new Result($result);
switch ($this->Tournament->Pairing[ $ptn ][ 'color' ]) {
case 4294967295:
$color = Color::BLACK;
break;
case 1:
$color = Color::WHITE;
break;
case 0:
default:
$color = Color::NONE;
break;
}
$pairing->Color = new Color($color);
$pairing->Board = $this->Tournament->Pairing[ $ptn ][ 'table' ];
$ptn++;
$this->Tournament->addPairing($pairing);
}
fclose($swshandle);
$this->Tournament->pairingsToRounds();
$this->addTiebreaks();
}
/**
* Reads data of the filehandle and converts to $type. defaults to $default if given
*
* Possible types for $type are:
* * String (UTF-8 String representation of $data. Default: empty string '')
* * Hex (Capitalized Hex Value of $data. Default: 00)
* * Int (Unsigned Integer value of $data Default: 0)
* * Bool (Boolean representation of $data. Default: false)
* * Date (Date representation of $data. Default: 1902/01/01)
*
* @param string $type
* @param $handle
* @param null $default
*
* @return array|bool|DateTime|false|float|int|string|null
*/
private function readData(string $type, $handle, $default = null)
{
switch ($type) {
case 'String':
case 'Date':
$length = $this->readData('Int', $handle);
if ($length == 0) {
return '';
}
$data = fread($handle, $length);
if ($type == 'String') {
if ($data == '') {
return (is_null($default)) ? '' : $default;
}
return iconv('windows-1252', 'utf-8', $data);
} elseif ($type == 'Date') {
if ($data == '') {
return (is_null($default)) ? $this->convertStringToDate('01/01/1900') : $default;
}
return $this->convertStringToDate($data);
}
break;
case 'Hex':
case 'Int':
case 'Bool':
$data = fread($handle, 4);
$hex = implode(unpack("H*", $data));
$hex = array_reverse(str_split($hex, 2));
foreach ($hex as $key => $item) {
if ($item == "00") {
$hex[ $key ] = "";
} else {
break;
}
}
$hex = implode($hex);
$hex = ($hex == "") ? "00" : $hex;
if ($type == 'Hex') {
if ($hex == '00') {
return (is_null($default)) ? '00' : $default;
}
return $hex;
} elseif ($type == 'Int') {
if ($hex == '00') {
return (is_null($default)) ? 0 : $default;
}
return hexdec($hex);
} elseif ($type == 'Bool') {
return ($hex == "01");
}
break;
default:
throw new InvalidArgumentException("Datatype not known");
}
return false;
}
}

691
src/Readers/Swar5.php Normal file
View File

@ -0,0 +1,691 @@
<?php
/**
* Reader Swar-4
*
* Reads out Swar-4 files
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo\Readers;
use DateTime;
use InvalidArgumentException;
use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\Libpairtwo\Enums\Tiebreak;
use JeroenED\Libpairtwo\Enums\Title;
use JeroenED\Libpairtwo\Enums\TournamentSystem;
use JeroenED\Libpairtwo\Exceptions\IncompatibleReaderException;
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
use JeroenED\Libpairtwo\Pairing;
use JeroenED\Libpairtwo\Player;
use JeroenED\Libpairtwo\Round;
use JeroenED\Libpairtwo\Tournament;
/**
* Reader Swar5
*
* Reads out Swar-5 files
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2021 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Swar5 implements ReaderInterface
{
/**
* @var array
*/
public const COMPATIBLE_VERSIONS = ['v5.'];
public const TEMPOS = [
[
'105 min/40 moves + 15 min. QPF',
'120 min/40 moves + 15 min. with incr. 30" starting from 40th move',
'120 min/40 moves + 30 min. QPF',
'120 min/10 moves + 30 min. avec incr. 30" starting from 40th move',
'120 min QPF',
'150 min QPF',
'60 min QPF',
'60 min with incr. 30"',
'65 min QPF',
'75 min with incr. 30"',
'90 min/40 moves + 15 min with incr. 30" starting from 1st move',
'90 min/40 moves + 30 min with incr. 30" starting from 1st move',
'90 min with incr. 30"',
'50 min with incr. 10"',
'other'
],
[
'10 min. with incr. 10"',
'10 min. with incr. 15"',
'10 min. with incr.5"',
'11 min. QPF',
'12 min. QPF',
'13 min. with incr.3"',
'13 min. with incr.5"',
'15 min. QPF',
'15 min. with incr. 10"',
'15 min. with incr. 15"',
'15 min. with incr.5"',
'20 min. QPF',
'20 min. with incr. 10"',
'20 min. with incr. 15"',
'20 min. with incr.5"',
'25 min. QPF',
'25 min. with incr. 10"',
'25 min. with incr. 15"',
'25 min. with incr.5"',
'30 min. QPF',
'45 min. QPF',
'8 min. with incr.4"',
'other'
],
[
'3 min. with incr. 2"',
'3 min. with incr. 3"',
'4 min. with incr. 2"',
'4 min. with incr. 3"',
'5 min. QPF',
'5 min. with incr. 2"',
'5 min. with incr. 3"',
'6 min. with incr. 2"',
'6 min. with incr. 3"',
'7 min. with incr. 2"',
'7 min. with incr. 3"',
'8 min. with incr. 2"',
'10 min. QPF',
'other'
]
];
/**
* 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
*
* @param string $filename
*
* @throws IncompatibleReaderException
*/
public function read(string $filename, string $compatversion = ''): void
{
$swshandle = fopen($filename, 'rb');
$this->Release = $this->readData('String', $swshandle);
if($compatversion != '') {
$this->Release == $compatversion;
}
if (array_search(substr($this->Release, 0, 3), self::COMPATIBLE_VERSIONS) === false) {
throw new IncompatibleReaderException("This file was not created with Swar 5");
}
$this->Tournament = new Tournament();
$this->Guid = $this->readData('String', $swshandle);
$this->MacAddress = $this->readData('String', $swshandle);
// [Tournoi]
$this->readData('String', $swshandle);
$this->Tournament->Name = $this->readData('String', $swshandle);
$this->Tournament->Organiser = $this->readData('String', $swshandle);
$this->Tournament->OrganiserClub = $this->readData('String', $swshandle);
$this->Tournament->OrganiserPlace = $this->readData('String', $swshandle);
$this->Tournament->addArbiter($this->readData('String', $swshandle));
$this->Tournament->addArbiter($this->readData('String', $swshandle));
$this->Tournament->StartDate = $this->readData('Date', $swshandle);
$this->Tournament->EndDate = $this->readData('Date', $swshandle);
// Tempo string is not variable and dependant on kind of tournament
$this->Tournament->TempoIndex = $this->readData('Int', $swshandle);
$this->readData('String', $swshandle); // some unknown data
$this->Tournament->NoOfRounds = $this->readData('Int', $swshandle);
$this->Tournament->FRBEfrom = $this->readData('Int', $swshandle);
$this->Tournament->FRBEto = $this->readData('Int', $swshandle);
$this->Tournament->FIDEfrom = $this->readData('Int', $swshandle);
$this->Tournament->FIDEto = $this->readData('Int', $swshandle);
$this->Tournament->CatSepares = $this->readData('Int', $swshandle);
$this->Tournament->AfficherEloOuPays = $this->readData('Int', $swshandle);
$this->Tournament->FideHomol = $this->readData('Int', $swshandle);
if (version_compare($this->Release, '5.24', ">=")) {
$this->Tournament->FideId = $this->readData('Int', $swshandle);
} else {
for ($i = 0; $i <= 15; $i++) {
// First round
$this->readData('Int', $swshandle);
//last round
$this->readData('Int', $swshandle);
//fide ID
$this->readData('Int', $swshandle);
}
}
$this->Tournament->FideArbitre1 = $this->readData('String', $swshandle);
$this->Tournament->FideArbitre2 = $this->readData('String', $swshandle);
$this->Tournament->FideEmail = $this->readData('String', $swshandle);
$this->Tournament->FideRemarques = $this->readData('String', $swshandle);
$applycustompoints = false;
switch ($this->readData('Int', $swshandle)) {
case 4:
case 5:
case 6:
$system = TournamentSystem::CLOSED;
break;
case 7:
case 8:
$system = TournamentSystem::AMERICAN;
break;
case 3:
$applycustompoints = true;
case 0:
case 1:
case 2:
default:
$system = TournamentSystem::SWISS;
break;
}
$this->Tournament->System = new TournamentSystem($system);
$this->Tournament->Dummy1 = $this->readData('Int', $swshandle);
$this->Tournament->Dummy2 = $this->readData('Int', $swshandle);
$this->Tournament->SW_AmerPresence = $this->readData('Int', $swshandle);
$this->Tournament->Plusieurs = $this->readData('Int', $swshandle);
$this->Tournament->FirstTable = $this->readData('Int', $swshandle);
$custompoints['win'] = $this->readData('Int', $swshandle) / 4;
$custompoints['draw'] = $this->readData('Int', $swshandle) / 4;
$custompoints['loss'] = $this->readData('Int', $swshandle) / 4;
$custompoints['bye'] = $this->readData('Int', $swshandle) / 4;
$custompoints['absent'] = $this->readData('Int', $swshandle) / 4;
if($applycustompoints) $this->Tournament->CustomPoints = $custompoints;
$this->Tournament->EloUsed = $this->readData('Int', $swshandle);
$this->Tournament->TournoiStd = $this->readData('Int', $swshandle);
$this->Tournament->TbPersonel = $this->readData('Int', $swshandle);
$this->Tournament->ApparOrder = $this->readData('Int', $swshandle);
$this->Tournament->EloEqual = $this->readData('Int', $swshandle);
$this->Tournament->ByeValue = $this->readData('Int', $swshandle);
$this->Tournament->AbsValue = $this->readData('Int', $swshandle);
$this->Tournament->FF_Value = $this->readData('Int', $swshandle);
switch ($this->readData('Int', $swshandle)) {
case 0:
default:
$federation = '';
break;
case 1:
$federation = 'FRBE';
break;
case 2:
$federation = 'KBSB';
break;
case 3:
$federation = 'FEFB';
break;
case 4:
$federation = 'VSF';
break;
case 5:
$federation = 'SVDB';
break;
case 6:
$federation = 'FIDE';
break;
}
$this->Tournament->Federation = $federation;
$this->Tournament->NonRatedElo = 0;
$this->Tournament->OrganiserClubNo = 0;
// [DATES]
$this->readData('String', $swshandle);
$this->Tournament->Tempo = self::TEMPOS[ $this->Tournament->TournoiStd ][ $this->Tournament->TempoIndex ];
for ($i = 0; $i < $this->Tournament->NoOfRounds; $i++) {
$round = new Round();
$round->RoundNo = $i;
$round->Date = $this->readData('Date', $swshandle);
$this->Tournament->addRound($round);
}
// [TIE_BREAK]
$this->readData('String', $swshandle);
$tiebreaks = [];
for ($i = 0; $i < 5; $i++) {
switch ($this->readData('Int', $swshandle)) {
case 0:
default:
$tiebreak = Tiebreak::NONE;
break;
case 1:
$tiebreak = Tiebreak::BUCHHOLZ;
break;
case 2:
$tiebreak = Tiebreak::BUCHHOLZ_MED;
break;
case 3:
$tiebreak = Tiebreak::BUCHHOLZ_MED_2;
break;
case 4:
$tiebreak = Tiebreak::BUCHHOLZ_CUT;
break;
case 5:
$tiebreak = Tiebreak::BUCHHOLZ_CUT_2;
break;
case 6:
$tiebreak = Tiebreak::SONNEBORN;
break;
case 7:
$tiebreak = Tiebreak::CUMULATIVE;
break;
case 8:
$tiebreak = Tiebreak::BETWEEN;
break;
case 9:
$tiebreak = Tiebreak::KOYA;
break;
case 10:
$tiebreak = Tiebreak::BAUMBACH;
break;
case 11:
$tiebreak = Tiebreak::AVERAGE_PERFORMANCE;
break;
case 12:
$tiebreak = Tiebreak::ARO;
break;
case 13:
$tiebreak = Tiebreak::AROCUT;
break;
case 14:
$tiebreak = Tiebreak::BLACK_PLAYED;
break;
case 15:
$tiebreak = Tiebreak::BLACK_WIN;
break;
}
$tiebreaks[] = new Tiebreak($tiebreak);
}
$this->Tournament->Tiebreaks = $tiebreaks;
// [EXCLUSION]
$this->readData('String', $swshandle);
$this->Tournament->ExclusionType = $this->readData('Int', $swshandle);
$this->Tournament->ExclusionValue = $this->readData('String', $swshandle);
// [CATEGORIES]
$this->readData('String', $swshandle);
$this->Tournament->Catogory_type = $this->readData('Int', $swshandle);
for ($i = 0; $i <= 12; $i++) {
$category[ $i ][ 'Cat1' ] = $this->readData('String', $swshandle);
}
for ($i = 0; $i <= 12; $i++) {
$category[ $i ][ 'Cat2' ] = $this->readData('String', $swshandle);
}
$this->Tournament->Category = $category;
// [XTRA_POINTS]
$this->readData('String', $swshandle);
for ($i = 0; $i < 4; $i++) {
$extrapoints[ $i ][ 'pts' ] = $this->readData('Int', $swshandle);
$extrapoints[ $i ][ 'elo' ] = $this->readData('Int', $swshandle);
}
$this->Tournament->Extrapoints = $extrapoints;
// [JOUEURS]
$this->readData('String', $swshandle);
$roundNo = 0;
$playerNo = 0;
$this->Tournament->NumberOfPlayers = $this->readData('Int', $swshandle);
$pt = 0;
for ($i = 0; $i < $this->Tournament->NumberOfPlayers; $i++) {
$player = new Player();
$player->Classement = $this->readData('Int', $swshandle);
$player->Name = $this->readData('String', $swshandle);
$inscriptionNos[ $this->readData('Int', $swshandle) ] = $i;
$player->Rank = $this->readData('Int', $swshandle);
$player->CatIndex = $this->readData('Int', $swshandle);
$player->DateOfBirth = $this->readData('Date', $swshandle);
switch ($this->readData('Int', $swshandle)) {
case 1:
$gender = Gender::MALE;
break;
case 2:
$gender = Gender::FEMALE;
break;
default:
$gender = Gender::NEUTRAL;
break;
}
$player->Gender = new Gender($gender);
$player->Nation = $this->readData('String', $swshandle);
$player->setId('Nation', $this->readData('Int', $swshandle));
$player->setId('Fide', $this->readData('Int', $swshandle));
$player->Affliation = $this->readData('Int', $swshandle);
$player->setElo('Nation', $this->readData('Int', $swshandle));
$player->setElo('Fide', $this->readData('Int', $swshandle));
switch ($this->readData('Int', $swshandle)) {
case 1:
$title = Title::WCM;
break;
case 2:
$title = Title::WFM;
break;
case 3:
$title = Title::CM;
break;
case 4:
$title = Title::WIM;
break;
case 5:
$title = Title::FM;
break;
case 6:
$title = Title::WGM;
break;
case 7:
$title = Title::HM;
break;
case 8:
$title = Title::IM;
break;
case 9:
$title = Title::HG;
break;
case 10:
$title = Title::GM;
break;
case 0:
default:
$title = Title::NONE;
break;
}
$player->Title = new Title($title);
$player->setId('Club', $this->readData('Int', $swshandle));
$player->ClubName = $this->readData('String', $swshandle);
$player->NoOfMatchesNoBye = $this->readData('Int', $swshandle);
$player->Points = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
$player->AmericanPoints = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
for ($t = 0; $t < 5; $t++) {
$tiebreaks[ $t ] = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
}
$player->Tiebreak = $tiebreaks;
$player->Performance = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
$player->Absent = $this->readData('Int', $swshandle);
$player->AbsentRounds = $this->readData('Int', $swshandle);
if(version_compare($this->Release, '5.53', "<=")) $player->Paid = $this->readData('Int', $swshandle);
$player->ExtraPoints = $this->readData('Int', $swshandle);
$player->SpecialPoints = $this->readData('Int', $swshandle);
$player->AllocatedRounds = $this->readData('Int', $swshandle);
// [RONDE]
$this->readData('String', $swshandle);
if ($player->AllocatedRounds != 0) {
for ($j = 0; $j < $player->AllocatedRounds; $j++) {
$pairing[ $pt ][ 'player' ] = $i;
$pairing[ $pt ][ 'round' ] = $this->readData('Int', $swshandle) - 1;
$pairing[ $pt ][ 'table' ] = $this->readData('Int', $swshandle) - 1;
$pairing[ $pt ][ 'opponent' ] = $this->readData('Int', $swshandle);
$pairing[ $pt ][ 'result' ] = $this->readData('Hex', $swshandle);
$pairing[ $pt ][ 'color' ] = $this->readData('Int', $swshandle);
$pairing[ $pt ][ 'float' ] = $this->readData('Int', $swshandle);
$pairing[ $pt ][ 'extrapoints' ] = $this->readData('Int', $swshandle);
$pt++;
}
$this->Tournament->Pairing = $pairing;
}
$this->Tournament->addPlayer($player);
}
$ptn = 0;
while (isset($this->Tournament->Pairing[ $ptn ][ 'round' ])) {
$pairing = new Pairing();
$pairing->Player = $this->Tournament->playerById($this->Tournament->Pairing[ $ptn ][ 'player' ]);
$pairing->Round = $this->Tournament->Pairing[ $ptn ][ 'round' ];
if ($this->Tournament->Pairing[ $ptn ][ 'opponent' ] != 4294967295) {
$pairing->Opponent =
$this->Tournament->playerById($inscriptionNos[ $this->Tournament->Pairing[ $ptn ][ 'opponent' ] ]);
}
switch ($this->Tournament->Pairing[ $ptn ][ 'result' ]) {
case '1000':
$result = Result::LOST;
break;
case '01':
$result = Result::ABSENT;
break;
case '0010':
$result = Result::BYE;
break;
case '2000':
$result = Result::DRAW;
break;
case '4000':
$result = Result::WON;
break;
case '04':
$result = Result::WON_FORFAIT;
break;
case '40':
$result = Result::WON_BYE;
break;
case '00':
default:
$result = Result::NONE;
break;
}
if (array_search($this->Tournament->Pairing[ $ptn ][ 'table' ], [16383, 8191]) !== false) {
$result = Result::ABSENT;
}
$pairing->Result = new Result($result);
switch ($this->Tournament->Pairing[ $ptn ][ 'color' ]) {
case 4294967295:
$color = Color::BLACK;
break;
case 1:
$color = Color::WHITE;
break;
case 0:
default:
$color = Color::NONE;
break;
}
$pairing->Color = new Color($color);
$pairing->Board = $this->Tournament->Pairing[ $ptn ][ 'table' ];
$ptn++;
$this->Tournament->addPairing($pairing);
}
fclose($swshandle);
$this->Tournament->pairingsToRounds();
$this->addTiebreaks();
}
/**
* Reads data of the filehandle and converts to $type. defaults to $default if given
*
* Possible types for $type are:
* * String (UTF-8 String representation of $data. Default: empty string '')
* * Hex (Capitalized Hex Value of $data. Default: 00)
* * Int (Unsigned Integer value of $data Default: 0)
* * Bool (Boolean representation of $data. Default: false)
* * Date (Date representation of $data. Default: 1902/01/01)
*
* @param string $type
* @param $handle
* @param null $default
*
* @return array|bool|DateTime|false|float|int|string|null
*/
private function readData(string $type, $handle, $default = null)
{
switch ($type) {
case 'String':
case 'Date':
$length = $this->readData('Int', $handle);
if ($length == 0) {
return '';
}
$data = fread($handle, $length);
if ($type == 'String') {
if ($data == '') {
return (is_null($default)) ? '' : $default;
}
return iconv('windows-1252', 'utf-8', $data);
} elseif ($type == 'Date') {
if ($data == '') {
return (is_null($default)) ? $this->convertStringToDate('01/01/1900') : $default;
}
return $this->convertStringToDate($data);
}
break;
case 'Hex':
case 'Int':
case 'Bool':
$data = fread($handle, 4);
$hex = implode(unpack("H*", $data));
$hex = array_reverse(str_split($hex, 2));
foreach ($hex as $key => $item) {
if ($item == "00") {
$hex[ $key ] = "";
} else {
break;
}
}
$hex = implode($hex);
$hex = ($hex == "") ? "00" : $hex;
if ($type == 'Hex') {
if ($hex == '00') {
return (is_null($default)) ? '00' : $default;
}
return $hex;
} elseif ($type == 'Int') {
if ($hex == '00') {
return (is_null($default)) ? 0 : $default;
}
return hexdec($hex);
} elseif ($type == 'Bool') {
return ($hex == "01");
}
break;
default:
throw new InvalidArgumentException("Datatype not known");
}
return false;
}
}

View File

@ -1,30 +1,111 @@
<?php
/**
* Created by PhpStorm.
* User: jeroen
* Date: 1/02/19
* Time: 17:16
* Class Round
*
* Class for a round of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
namespace JeroenED\Libpairtwo;
use DateTime;
use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\Libpairtwo\Models\Round as RoundModel;
use JeroenED\Libpairtwo\Game;
use JeroenED\Libpairtwo\Pairing;
class Round extends RoundModel
/**
* Class Round
*
* Class for a round of the tournament
*
* @author Jeroen De Meerleer <schaak@jeroened.be>
* @category Main
* @package Libpairtwo
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
*/
class Round
{
/**
* Date of the round
*
* @var DateTime
*/
public $Date;
/**
* Array of all games
*
* @var Game[]
*/
public $Games = [];
/**
* Array of all pairings for this round
*
* @var Pairing[]
*/
public $Pairings = [];
/**
* Number of the round
*
* @var int
*/
public $RoundNo;
/**
* 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;
}
/**
* 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
*
* @param Game $game
*/
public function addGame(Game $game)
public function addGame(Game $game): void
{
$newarray = $this->getGames();
$newarray = $this->Games;
$newarray[] = $game;
$this->setGames($newarray);
$this->Games = $newarray;
}
/**
@ -32,46 +113,58 @@ class Round extends RoundModel
*
* @param Pairing $pairing
*/
public function addPairing(Pairing $pairing)
public function addPairing(Pairing $pairing): void
{
$newarray = $this->getPairings();
$newarray = $this->Pairings;
$newarray[] = $pairing;
$this->setPairings($newarray);
$this->Pairings = $newarray;
}
/**
* Returns an array of pairings where the player is bye
*
* @return Pairing[]
*/
public function getBye(): array
private function bye(): array
{
$allPairings = $this->getPairings();
$allPairings = $this->Pairings;
$byePairings = [];
foreach ($allPairings as $pairing) {
if ($pairing->getResult() == Result::bye) {
if ($pairing->Result == Result::WON_BYE) {
$byePairings[] = $pairing;
}
}
return $byePairings;
}
/**
* Retuns an array with the games of this round sorted by board
*
* @return Game[]
*/
private function gamesByBoard(): array
{
$allGames = $this->Games;
usort($allGames, [$this, 'sortByBoard']);
return $allGames;
}
/**
* Returns an array of pairings where the player is absent
* Sort by board
*
* @return Pairing[]
* @param Game $a
* @param Game $b
*
* @return int
*/
public function getAbsent(): array
private function sortByBoard(Game $a, Game $b): int
{
$allPairings = $this->getPairings();
$absentPairings = [];
foreach ($allPairings as $pairing) {
if ($pairing->getResult() == Result::absent) {
$absentPairings[] = $pairing;
}
if (($a->Board == $b->Board) || ($a->Board === false) || ($b->Board === false)) {
return 0;
}
return $absentPairings;
return ($a->Board > $b->Board) ? +1 : -1;
}
}

View File

@ -1,53 +0,0 @@
<?php
/*
* The MIT License
*
* Copyright 2019 Jeroen De Meerleer <schaak@jeroened.be>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
namespace JeroenED\Libpairtwo;
use JeroenED\LibPairtwo\Exceptions\LibpairtwoException;
/**
* This class reads a SWS file
*
* @deprecated
* @author Jeroen De Meerleer
*/
class Sws
{
/**
* Reads out $swsfile and returns a Pairtwo6 class object
*
* @param string $swsfile
* @throws LibpairtwoException
* @deprecated
*/
public static function ReadSws(string $swsfile)
{
trigger_error("This function is deprecated. Please convert your code to use the new pattern. More info to be found on Github (https://github.com/JeroenED/libpairtwo/wiki/Converting-your-code-to-the-generalized-format).", E_USER_DEPRECATED);
$reader = IOFactory::createReader("Pairtwo-6");
return $reader->read($swsfile);
}
}

View File

@ -1,295 +0,0 @@
<?php
namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Models\Tournament;
use JeroenED\Libpairtwo\Enums\Result;
abstract class Tiebreaks extends Tournament
{
/**
* @param Player $player
* @return float|null
*/
protected function calculateKeizer(Player $player): ?float
{
return $player->getBinaryData('ScoreAmerican');
}
/**
* @param Player $player
* @return float|null
*/
protected function calculateAmerican(Player $player): ?float
{
return $player->getBinaryData('ScoreAmerican');
}
/**
* @param Player $player
* @return float|null
*/
protected function calculatePoints(Player $player): ?float
{
return $player->getPoints();
}
/**
* @param Player $player
* @return float|null
*/
protected function calculateBaumbach(Player $player): ?float
{
$totalwins = 0;
foreach ($player->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::Won) !== false) {
$totalwins++;
}
}
return $totalwins;
}
/**
* @param Player $player
* @return float|null
*/
protected function calculateBlackPlayed(Player $player): ?float
{
$totalwins = 0;
foreach ($player->getPairings() as $pairing) {
if (array_search($pairing->getColor(), Constants::Black) !== false) {
$totalwins++;
}
}
return $totalwins;
}
/**
* @param Player $player
* @return float|null
*/
protected function calculateBlackWin(Player $player): ?float
{
$totalwins = 0;
foreach ($player->getPairings() as $pairing) {
if (array_search($pairing->getColor(), Constants::Black) !== false && array_search($pairing->getResult(), Constants::Won) !== false) {
$totalwins++;
}
}
return $totalwins;
}
/**
* @param Player $player
* @param array $opponents
* @param int $key
* @return float|null
*/
protected function calculateMutualResult(Player $player, array $opponents, int $key): ?float
{
$interestingplayers = $opponents;
if ($key != 0) {
$interestingplayers = [];
foreach ($opponents as $opponent) {
if (($opponent->getTiebreaks()[$key - 1] == $player->getTiebreaks()[$key - 1]) && ($player != $opponent)) {
$interestingplayers[] = $opponent;
}
}
}
$points = 0;
$totalmatches = 0;
foreach ($player->getPairings() as $pairing) {
if (array_search($pairing->getOpponent(), $interestingplayers) !== false) {
if (array_search($pairing->getResult(), Constants::Won) !== false) {
$points = $points + 1;
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
$points = $points + 0.5;
}
$totalmatches++;
}
}
if ($totalmatches != count($interestingplayers)) {
$points = null;
}
return $points;
}
/**
* @param Player $player
* @param int $cut
* @return float
*/
protected function calculateAverageRating(Player $player, string $type, int $cut = 0): ?float
{
$pairings = $player->getPairings();
$allratings = [];
foreach ($pairings as $pairing) {
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
$toadd = $pairing->getOpponent()->getElo($type);
if ($toadd != 0) {
$allratings[] = $toadd;
}
}
}
sort($allratings);
$allratings = array_slice($allratings, $cut);
return round(array_sum($allratings) / count($allratings));
}
/**
* @param Player $player
* @param int $cut
* @return float|null
*/
protected function calculateAveragePerformance(Player $player, string $type, int $cut = 0): ?float
{
$pairings = $player->getPairings();
$allratings = [];
foreach ($pairings as $pairing) {
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
$toadd = $pairing->getOpponent()->getPerformance($type, $this->getNonRatedElo());
if ($toadd != 0) {
$allratings[] = $toadd;
}
}
}
sort($allratings);
$allratings = array_slice($allratings, $cut);
return round(array_sum($allratings) / count($allratings));
}
/**
* @param Player $player
* @param int $cut
* @return float|null
*/
protected function calculateKoya(Player $player, int $cut = 50): ?float
{
$tiebreak = 0;
foreach ($player->getPairings() as $plkey => $plpairing) {
if (($plpairing->getOpponent()->getPoints() / count($plpairing->getOpponent()->getPairings()) * 100) >= $cut) {
if (array_search($plpairing->getResult(), Constants::Won) !== false) {
$tiebreak += 1;
} elseif (array_search($plpairing->getResult(), Constants::Draw) !== false) {
$tiebreak += 0.5;
}
}
}
return $tiebreak;
}
/**
* @param Player $player
* @param int $cutlowest
* @param int $cuthighest
* @return float|null
*/
protected function calculateBuchholz(Player $player, int $cutlowest = 0, int $cuthighest = 0): ?float
{
$tiebreak = 0;
$intpairings = $player->getPairings();
usort($intpairings, function ($a, $b) {
if (is_null($a->getOpponent())) {
return -1;
}
if (is_null($b->getOpponent())) {
return 1;
}
if ($b->getOpponent()->getPoints() == $a->getOpponent()->getPoints()) {
return 0;
}
return ($a->getOpponent()->getPoints() > $b->getOpponent()->getPoints()) ? 1 : -1;
});
$intpairings = array_slice($intpairings, $cutlowest);
$intpairings = array_slice($intpairings, 0, 0 - $cuthighest);
foreach ($intpairings as $intkey => $intpairing) {
if (!is_null($intpairing->getOpponent())) {
$tiebreak += $intpairing->getOpponent()->getPoints();
}
}
return $tiebreak;
}
/**
* @param Player $player
* @return float|null
*/
protected function calculateSonneborn(Player $player): ?float
{
$tiebreak = 0;
foreach ($player->getPairings() as $key => $pairing) {
if ($pairing->getOpponent()) {
if (array_search($pairing->getResult(), Constants::Won) !== false) {
$tiebreak += $pairing->getOpponent()->getPoints();
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
$tiebreak += $pairing->getOpponent()->getPoints() / 2;
}
}
}
return $tiebreak;
}
/**
* @param Player $player
* @return float|null
*/
protected function calculateKashdan(Player $player): ?float
{
$tiebreak = 0;
foreach ($player->getPairings() as $pairing) {
$toadd = 0;
if (array_search($pairing->getResult(), Constants::Won) !== false) {
$toadd = 3;
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
$toadd = 1;
} elseif (array_search($pairing->getResult(), Constants::Lost) !== false) {
$toadd = 0;
}
if (array_search($pairing->getResult(), Constants::NotPlayed) !== false) {
$toadd = -1;
}
$tiebreak += $toadd;
}
return $tiebreak; // - $player->getNoOfWins();
}
/**
* @param Player $player
* @return float|null
*/
protected function calculateCumulative(Player $player): ?float
{
$tiebreak = 0;
$score = [];
foreach ($player->getPairings() as $pairing) {
$toadd = 0;
if (array_search($pairing->getResult(), Constants::Won) !== false) {
$toadd = 1;
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
$toadd = 0.5;
}
$tiebreak += $toadd;
$score[] = $tiebreak;
}
return array_sum($score);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -23,62 +23,75 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
use JeroenED\Libpairtwo\IOFactory;
require_once '../vendor/autoload.php';
$sws = IOFactory::createReader('Pairtwo-6');
$sws->read('../res/testsws.sws');
$sws = IOFactory::createReader('Swar-4');
$sws->read('../res/testswar.swar');
echo "Release: " . $sws->getRelease() . PHP_EOL;
echo "Name: " . $sws->getTournament()->getName() . PHP_EOL;
echo "Organiser: " . $sws->getTournament()->getOrganiser(). PHP_EOL;
echo "Tempo: " . $sws->getTournament()->getTempo() . PHP_EOL;
echo "Country: " . $sws->getTournament()->getOrganiserCountry() . PHP_EOL;
echo "Arbiter: " . $sws->getTournament()->getArbiter() . PHP_EOL;
echo "Rounds: " . $sws->getTournament()->getNoOfRounds() . PHP_EOL;
echo "Participants: " . $sws->getTournament()->getNoOfRounds() . PHP_EOL;
echo "Fidehomol: " . $sws->getTournament()->getFideHomol() . PHP_EOL;
echo "Start-Date: " . $sws->getTournament()->getStartDate()->format('d/m/Y') . PHP_EOL;
echo "End-Date: " . $sws->getTournament()->getEndDate()->format('d/m/Y') . PHP_EOL;
echo "System: " . $sws->getTournament()->getSystem()->getKey() . PHP_EOL;
echo "Place: " . $sws->getTournament()->getOrganiserPlace() . PHP_EOL;
echo "Unrated-Elo: " . $sws->getTournament()->getNonRatedElo() . PHP_EOL;
echo "Federation: " . $sws->getTournament()->getFederation() . PHP_EOL;
echo "Organiser: " . $sws->getTournament()->getOrganiserClubNo() . PHP_EOL;
echo "Fide Elo P1: " . $sws->getTournament()->getPlayerById(0)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P2: " . $sws->getTournament()->getPlayerById(1)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P3: " . $sws->getTournament()->getPlayerById(2)->getElo('Fide') . PHP_EOL;
echo "KBSB Elo P1: " . $sws->getTournament()->getPlayerById(0)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P2: " . $sws->getTournament()->getPlayerById(1)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P3: " . $sws->getTournament()->getPlayerById(2)->getElo('Nation') . PHP_EOL;
echo "Name P1: " . $sws->getTournament()->getPlayerById(0)->getName() . PHP_EOL;
echo "Name P2: " . $sws->getTournament()->getPlayerById(1)->getName() . PHP_EOL;
echo "Name P3: " . $sws->getTournament()->getPlayerById(2)->getName() . PHP_EOL;
echo "Gender P1: " . $sws->getTournament()->getPlayerById(0)->getGender()->getKey() . PHP_EOL;
echo "Gender P2: " . $sws->getTournament()->getPlayerById(1)->getGender()->getKey() . PHP_EOL;
echo "Gender P3: " . $sws->getTournament()->getPlayerById(2)->getGender()->getKey() . PHP_EOL;
echo "Absent P1: " . $sws->getTournament()->getPlayerById(0)->getBinaryData("Absent") . PHP_EOL;
echo "Absent P2: " . $sws->getTournament()->getPlayerById(1)->getBinaryData("Absent") . PHP_EOL;
echo "Absent P3: " . $sws->getTournament()->getPlayerById(2)->getBinaryData("Absent") . PHP_EOL;
echo "Date Round 1: " . $sws->getTournament()->getRoundByNo(0)->getDate()->format('d/m/Y') . PHP_EOL;
echo "Date Round 2: " . $sws->getTournament()->getRoundByNo(1)->getDate()->format('d/m/Y') . PHP_EOL;
echo "Date Round 3: " . $sws->getTournament()->getRoundByNo(2)->getDate()->format('d/m/Y') . PHP_EOL;
echo "Color Pairing 1: " . $sws->getTournament()->getPairings()[1]->getColor()->getKey() . PHP_EOL;
echo "Color Pairing 2: " . $sws->getTournament()->getPairings()[2]->getColor()->getKey() . PHP_EOL;
echo "Color Pairing 3: " . $sws->getTournament()->getPairings()[3]->getColor()->getKey() . PHP_EOL;
echo "Player Pairing 1: " . $sws->getTournament()->getPairings()[0]->getPlayer()->getName() . PHP_EOL;
echo "Player Pairing 2: " . $sws->getTournament()->getPairings()[1]->getPlayer()->getName() . PHP_EOL;
echo "Player Pairing 3: " . $sws->getTournament()->getPairings()[2]->getPlayer()->getName() . PHP_EOL;
echo "Tiebreak 1: " . $sws->getTournament()->getTiebreaks()[0]->getValue() . PHP_EOL;
echo "Tiebreak 2: " . $sws->getTournament()->getTiebreaks()[1]->getValue() . PHP_EOL;
echo "Tiebreak 3: " . $sws->getTournament()->getTiebreaks()[2]->getValue() . PHP_EOL;
echo "Tiebreak 4: " . $sws->getTournament()->getTiebreaks()[3]->getValue() . PHP_EOL;
echo "Tiebreak 5: " . $sws->getTournament()->getTiebreaks()[4]->getValue() . PHP_EOL;
echo "Tiebreak 6: " . $sws->getTournament()->getTiebreaks()[5]->getValue() . PHP_EOL;
echo "Average Elo: " . $sws->getTournament()->getAverageElo() . PHP_EOL;
foreach ($sws->getTournament()->getRanking() as $player) {
echo str_pad($player->getName() . '(' . $player->getElo($sws->getTournament()->getPriorityElo()) . ') ', 35) . implode_pad(' ', $player->getTiebreaks(), 5, ' ') . PHP_EOL;
echo "Release: " . $sws->Release . PHP_EOL;
echo "Name: " . $sws->Tournament->Name . PHP_EOL;
echo "Organiser: " . $sws->Tournament->Organiser . PHP_EOL;
echo "TempoIndex: " . $sws->Tournament->TempoIndex . PHP_EOL;
echo "TempoType: " . $sws->Tournament->TournoiStd . PHP_EOL;
echo "Tempo: " . $sws->Tournament->Tempo . PHP_EOL;
echo "Place: " . $sws->Tournament->OrganiserPlace . PHP_EOL;
echo "Arbiter 1: " . $sws->Tournament->Arbiters[ 0 ] . PHP_EOL;
echo "Arbiter 2: " . $sws->Tournament->Arbiters[ 1 ] . PHP_EOL;
echo "Rounds: " . $sws->Tournament->NoOfRounds . PHP_EOL;
echo "Fidehomol: " . $sws->Tournament->FideHomol . 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 "System: " . $sws->Tournament->System->getKey() . PHP_EOL;
echo "Place: " . $sws->Tournament->OrganiserPlace . PHP_EOL;
echo "Unrated-Elo: " . $sws->Tournament->NonRatedElo . PHP_EOL;
echo "Federation: " . $sws->Tournament->Federation . PHP_EOL;
echo "Organiser: " . $sws->Tournament->OrganiserClubNo . PHP_EOL;
echo "Fide Elo P1: " . $sws->Tournament->PlayerById(0)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P2: " . $sws->Tournament->PlayerById(1)->getElo('Fide') . PHP_EOL;
echo "Fide Elo P3: " . $sws->Tournament->PlayerById(2)->getElo('Fide') . PHP_EOL;
echo "KBSB Elo P1: " . $sws->Tournament->PlayerById(0)->getElo('Nation') . PHP_EOL;
echo "KBSB Elo P2: " . $sws->Tournament->PlayerById(1)->getElo('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 P2: " . $sws->Tournament->PlayerById(1)->Name . PHP_EOL;
echo "Name P3: " . $sws->Tournament->PlayerById(2)->Name . PHP_EOL;
echo "Gender P1: " . $sws->Tournament->PlayerById(0)->Gender->getKey() . PHP_EOL;
echo "Gender P2: " . $sws->Tournament->PlayerById(1)->Gender->getKey() . 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 P2: " . $sws->Tournament->PlayerById(1)->Absent . PHP_EOL;
echo "Absent P3: " . $sws->Tournament->PlayerById(2)->Absent . PHP_EOL;
echo "Category P1: " . $sws->Tournament->PlayerById(0)->Category . PHP_EOL;
echo "Category P2: " . $sws->Tournament->PlayerById(1)->Category . PHP_EOL;
echo "Category P3: " . $sws->Tournament->PlayerById(2)->Category . PHP_EOL;
echo "Date Round 1: " . $sws->Tournament->RoundByNo(0)->Date->format('d/m/Y') . PHP_EOL;
echo "Date Round 2: " . $sws->Tournament->RoundByNo(1)->Date->format('d/m/Y') . PHP_EOL;
echo "Date Round 3: " . $sws->Tournament->RoundByNo(2)->Date->format('d/m/Y') . PHP_EOL;
echo "Game Round 1: " . $sws->Tournament->RoundByNo(0)->Games[ 0 ]->Result->getValue() . PHP_EOL;
echo "Game Round 2: " . $sws->Tournament->RoundByNo(1)->Games[ 0 ]->Result->getValue() . PHP_EOL;
echo "Game Round 3: " . $sws->Tournament->RoundByNo(2)->Games[ 0 ]->Result->getValue() . PHP_EOL;
echo "Color Pairing 1: " . $sws->Tournament->Pairings[ 1 ]->Color->getKey() . PHP_EOL;
echo "Color Pairing 2: " . $sws->Tournament->Pairings[ 2 ]->Color->getKey() . PHP_EOL;
echo "Color Pairing 3: " . $sws->Tournament->Pairings[ 3 ]->Color->getKey() . PHP_EOL;
echo "Player Pairing 1: " . $sws->Tournament->Pairings[ 0 ]->Player->Name . PHP_EOL;
echo "Player Pairing 2: " . $sws->Tournament->Pairings[ 1 ]->Player->Name . PHP_EOL;
echo "Player Pairing 3: " . $sws->Tournament->Pairings[ 2 ]->Player->Name . PHP_EOL;
echo "Bye Round 1: " . $sws->Tournament->RoundByNo(2)->Bye[ 0 ]->Player->Name . PHP_EOL;
echo "Absent Round 1: " . $sws->Tournament->RoundByNo(2)->Absent[ 0 ]->Player->Name . PHP_EOL;
echo "Tiebreak 1: " . $sws->Tournament->Tiebreaks[ 0 ]->getValue() . PHP_EOL;
echo "Tiebreak 2: " . $sws->Tournament->Tiebreaks[ 1 ]->getValue() . PHP_EOL;
echo "Tiebreak 3: " . $sws->Tournament->Tiebreaks[ 2 ]->getValue() . PHP_EOL;
echo "Tiebreak 4: " . $sws->Tournament->Tiebreaks[ 3 ]->getValue() . PHP_EOL;
echo "Tiebreak 5: " . $sws->Tournament->Tiebreaks[ 4 ]->getValue() . 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
@ -87,5 +100,6 @@ function implode_pad($glue, $collection, $padlength, $padstring): string
foreach ($collection as $elem) {
$newarray[] = str_pad($elem, $padlength, $padstring);
}
return implode($glue, $newarray);
}