mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-21 14:07:42 +01:00
Merge branch 'task/removing_files' into develop
This commit is contained in:
commit
f4c526ff41
@ -15,32 +15,36 @@
|
|||||||
<option name="VARIABLE_NAMING_STYLE" value="CAMEL_CASE" />
|
<option name="VARIABLE_NAMING_STYLE" value="CAMEL_CASE" />
|
||||||
<option name="BLANK_LINES_BEFORE_RETURN_STATEMENT" value="1" />
|
<option name="BLANK_LINES_BEFORE_RETURN_STATEMENT" value="1" />
|
||||||
<option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
|
<option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
|
||||||
<option name="SPACES_AROUND_VAR_WITHIN_BRACKETS" value="true" />
|
|
||||||
<option name="BLANK_LINES_AROUND_CONSTANTS" value="1" />
|
<option name="BLANK_LINES_AROUND_CONSTANTS" value="1" />
|
||||||
<option name="KEEP_BLANK_LINES_AFTER_LBRACE" 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="SPACE_BETWEEN_TERNARY_QUEST_AND_COLON" value="true" />
|
||||||
<option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" 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" />
|
<option name="PLACE_PARENS_FOR_CONSTRUCTOR" value="1" />
|
||||||
</PHPCodeStyleSettings>
|
</PHPCodeStyleSettings>
|
||||||
<codeStyleSettings language="PHP">
|
<codeStyleSettings language="PHP">
|
||||||
<option name="RIGHT_MARGIN" value="120" />
|
<option name="RIGHT_MARGIN" value="120" />
|
||||||
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
|
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
|
||||||
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
||||||
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
|
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
|
||||||
<option name="BLANK_LINES_AFTER_PACKAGE" value="1" />
|
<option name="BLANK_LINES_AFTER_PACKAGE" value="1" />
|
||||||
<option name="BLANK_LINES_AROUND_FIELD" value="1" />
|
<option name="BLANK_LINES_AROUND_FIELD" value="1" />
|
||||||
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
|
<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_PARAMETERS_IN_CALLS" value="true" />
|
||||||
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
|
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
|
||||||
<option name="ALIGN_MULTILINE_TERNARY_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="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
|
||||||
<option name="SPACE_WITHIN_BRACKETS" value="true" />
|
<option name="SPACE_WITHIN_BRACKETS" value="true" />
|
||||||
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" />
|
|
||||||
<option name="CALL_PARAMETERS_WRAP" value="5" />
|
<option name="CALL_PARAMETERS_WRAP" value="5" />
|
||||||
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
|
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
|
||||||
<option name="CALL_PARAMETERS_RPAREN_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_LPAREN_ON_NEXT_LINE" value="true" />
|
||||||
<option name="METHOD_PARAMETERS_RPAREN_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="METHOD_CALL_CHAIN_WRAP" value="5" />
|
||||||
<option name="PARENTHESES_EXPRESSION_LPAREN_WRAP" value="true" />
|
<option name="PARENTHESES_EXPRESSION_LPAREN_WRAP" value="true" />
|
||||||
<option name="PARENTHESES_EXPRESSION_RPAREN_WRAP" value="true" />
|
<option name="PARENTHESES_EXPRESSION_RPAREN_WRAP" value="true" />
|
||||||
@ -49,11 +53,13 @@
|
|||||||
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
|
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
|
||||||
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
|
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
|
||||||
<option name="FOR_STATEMENT_WRAP" value="5" />
|
<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_WRAP" value="5" />
|
||||||
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
|
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
|
||||||
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
|
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
|
||||||
<option name="ASSIGNMENT_WRAP" value="5" />
|
<option name="ASSIGNMENT_WRAP" value="5" />
|
||||||
<option name="IF_BRACE_FORCE" value="1" />
|
<option name="IF_BRACE_FORCE" value="3" />
|
||||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||||
<option name="FOR_BRACE_FORCE" value="3" />
|
<option name="FOR_BRACE_FORCE" value="3" />
|
||||||
|
17
.idea/inspectionProfiles/Project_Default.xml
Normal file
17
.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="PhpCSValidationInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<option name="CODING_STANDARD" value="PSR12" />
|
||||||
|
<option name="EXTENSIONS" value="php,js,css,inc" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PhpCompoundNamespaceDepthInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="PhpLongTypeFormInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="PhpMissingVisibilityInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="PhpModifierOrderInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="PhpNewClassMissingParameterListInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="PhpSeparateElseIfInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="PhpTraitsUseListInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="PhpVarUsageInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
12
.php_cs
12
.php_cs
@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$finder = PhpCsFixer\Finder::create()
|
|
||||||
->exclude(['build', 'vendor'])
|
|
||||||
->in(__DIR__);
|
|
||||||
|
|
||||||
return PhpCsFixer\Config::create()
|
|
||||||
->setFinder($finder)
|
|
||||||
->setUsingCache(true)
|
|
||||||
->setRules([
|
|
||||||
'@PSR2' => true,
|
|
||||||
]);
|
|
4
Makefile
4
Makefile
@ -12,6 +12,8 @@ install-dev: ## Installs the required common devtools
|
|||||||
@echo "Downloading phpcs"
|
@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/phpcs.phar -O bin/phpcs 2> /dev/null
|
||||||
@wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar -O bin/phpcbf 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 "Installation of devtools finished"
|
||||||
@echo "Please add $(shell echo $(PWD))/bin to your PATH"
|
@echo "Please add $(shell echo $(PWD))/bin to your PATH"
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ clean-repo: ## Cleans the git repository
|
|||||||
git gc
|
git gc
|
||||||
|
|
||||||
cs: ## Fixes coding standard problems
|
cs: ## Fixes coding standard problems
|
||||||
vendor/bin/php-cs-fixer fix || true
|
php bin/phpcs || true
|
||||||
|
|
||||||
tag: ## Creates a new signed git tag
|
tag: ## Creates a new signed git tag
|
||||||
$(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=X.X.X"))
|
$(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=X.X.X"))
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Constants
|
* Class Constants
|
||||||
*
|
*
|
||||||
* Static class for constants
|
* Static class for constants
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo;
|
namespace JeroenED\Libpairtwo;
|
||||||
@ -20,18 +21,35 @@ use JeroenED\Libpairtwo\Enums\Result;
|
|||||||
*
|
*
|
||||||
* Static class for constants
|
* Static class for constants
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Constants
|
class Constants
|
||||||
{
|
{
|
||||||
const Won = [ Result::Won, Result::WonForfait, Result::WonBye, Result::WonAdjourned ];
|
public const WON = [Result::WON, Result::WON_FORFAIT, Result::WON_BYE, Result::WON_ADJOURNED];
|
||||||
const Draw = [ Result::Draw, Result::DrawAdjourned ];
|
|
||||||
const Lost = [ Result::Absent, Result::Bye, Result::Lost, Result::Adjourned ];
|
public const DRAW = [Result::DRAW, Result::DRAW_ADJOURNED];
|
||||||
const NotPlayed = [ Result::Bye, Result::WonBye, Result::Absent ];
|
|
||||||
const Played = [ Result::Won, Result::WonForfait, Result::WonBye, Result::WonAdjourned, Result::Draw, Result::DrawAdjourned, Result::Absent, Result::Bye, Result::Lost, Result::Adjourned ];
|
public const LOST = [Result::ABSENT, Result::BYE, Result::LOST, Result::ADJOURNED];
|
||||||
const Black = [ Color::Black ];
|
|
||||||
const White = [ Color::White ];
|
public const NOTPLAYED = [Result::BYE, Result::WON_BYE, Result::ABSENT];
|
||||||
|
|
||||||
|
public const PLAYED = [
|
||||||
|
Result::WON,
|
||||||
|
Result::WON_FORFAIT,
|
||||||
|
Result::WON_BYE,
|
||||||
|
Result::WON_ADJOURNED,
|
||||||
|
Result::DRAW,
|
||||||
|
Result::DRAW_ADJOURNED,
|
||||||
|
Result::ABSENT,
|
||||||
|
Result::BYE,
|
||||||
|
Result::LOST,
|
||||||
|
Result::ADJOURNED
|
||||||
|
];
|
||||||
|
|
||||||
|
public const BLACK = [Color::BLACK];
|
||||||
|
|
||||||
|
public const WHITE = [Color::WHITE];
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Color
|
* Enum Color
|
||||||
*
|
*
|
||||||
* List of all compatible colors
|
* List of all compatible colors
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Enums;
|
namespace JeroenED\Libpairtwo\Enums;
|
||||||
@ -19,14 +20,16 @@ use MyCLabs\Enum\Enum;
|
|||||||
*
|
*
|
||||||
* List of all compatible colors
|
* List of all compatible colors
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Color extends Enum
|
class Color extends Enum
|
||||||
{
|
{
|
||||||
const Black = 'B';
|
public const BLACK = 'B';
|
||||||
const White = 'W';
|
|
||||||
const None = '*';
|
public const NONE = '*';
|
||||||
|
|
||||||
|
public const WHITE = 'W';
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Gameresult
|
* Enum Gameresult
|
||||||
*
|
*
|
||||||
* List of all compatible gameresults
|
* List of all compatible gameresults
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Enums;
|
namespace JeroenED\Libpairtwo\Enums;
|
||||||
@ -19,24 +20,36 @@ use MyCLabs\Enum\Enum;
|
|||||||
*
|
*
|
||||||
* List of all compatible gameresults
|
* List of all compatible gameresults
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Gameresult extends Enum
|
class Gameresult extends Enum
|
||||||
{
|
{
|
||||||
const None = '-';
|
public const BLACK_WINS = '0-1';
|
||||||
const WhiteWins = '1-0';
|
|
||||||
const Draw = '0.5-0.5';
|
public const BLACK_WINS_FORFAIT = '0-1 FF';
|
||||||
const BlackWins = '0-1';
|
|
||||||
const WhiteWinsForfait = '1-0 FF';
|
public const BOTH_LOSE_FORFAIT = '0-0 FF';
|
||||||
const BlackWinsForfait = '0-1 FF';
|
|
||||||
const BothLoseForfait = '0-0 FF';
|
public const BOTH_WIN_ADJOURNED = '1-1 A';
|
||||||
const BothWinAdjourned = '1-1 A';
|
|
||||||
const WhiteWinsBlackDrawsAdjourned = '1-0.5 A';
|
public const DRAW = '0.5-0.5';
|
||||||
const WhiteDrawsBlackWinsAdjourned = '0.5-1 A';
|
|
||||||
const DrawAdjourned = '0.5-0.5 A';
|
public const DRAW_ADJOURNED = '0.5-0.5 A';
|
||||||
const WhiteLoseBlackDrawsAdjourned = '0-0.5';
|
|
||||||
const WhiteDrawsBlackLoseAdjourned = '0.5-0';
|
public const NONE = '-';
|
||||||
|
|
||||||
|
public const WHITE_DRAWS_BLACK_LOSE_ADJOURNED = '0.5-0';
|
||||||
|
|
||||||
|
public const WHITE_DRAWS_BLACK_WINS_ADJOURNED = '0.5-1 A';
|
||||||
|
|
||||||
|
public const WHITE_LOST_BLACK_DRAWS_ADJOURNED = '0-0.5';
|
||||||
|
|
||||||
|
public const WHITE_WINS = '1-0';
|
||||||
|
|
||||||
|
public const WHITE_WINS_BLACK_DRAWS_ADJOURNED = '1-0.5 A';
|
||||||
|
|
||||||
|
public const WHITE_WINS_FORFAIT = '1-0 FF';
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Gender
|
* Enum Gender
|
||||||
*
|
*
|
||||||
* List of all compatible genders
|
* List of all compatible genders
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Enums;
|
namespace JeroenED\Libpairtwo\Enums;
|
||||||
@ -19,14 +20,16 @@ use MyCLabs\Enum\Enum;
|
|||||||
*
|
*
|
||||||
* List of all compatible genders
|
* List of all compatible genders
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Gender extends Enum
|
class Gender extends Enum
|
||||||
{
|
{
|
||||||
const Neutral = 'X'; // Unforturnately, Incompatible with Pairtwo (Dinos)
|
public const FEMALE = 'F';
|
||||||
const Male = 'M';
|
|
||||||
const Female = 'F';
|
public const MALE = 'M';
|
||||||
|
|
||||||
|
public const NEUTRAL = 'X'; // Unfortunately, Incompatible with Pairtwo (Dinos)
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Result
|
* Enum Result
|
||||||
*
|
*
|
||||||
* List of all compatible results
|
* List of all compatible results
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Enums;
|
namespace JeroenED\Libpairtwo\Enums;
|
||||||
@ -19,22 +20,32 @@ use MyCLabs\Enum\Enum;
|
|||||||
*
|
*
|
||||||
* List of all compatible results
|
* List of all compatible results
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Result extends Enum
|
class Result extends Enum
|
||||||
{
|
{
|
||||||
const None = '*';
|
public const ABSENT = '0 FF';
|
||||||
const Lost = '0';
|
|
||||||
const Draw = '0.5';
|
public const ADJOURNED = '0 A';
|
||||||
const Won = '1';
|
|
||||||
const Absent = '0 FF';
|
public const BYE = '0 Bye';
|
||||||
const WonForfait = '1 FF';
|
|
||||||
const Adjourned = '0 A';
|
public const DRAW = '0.5';
|
||||||
const DrawAdjourned = '0.5 A';
|
|
||||||
const WonAdjourned = '1 A';
|
public const DRAW_ADJOURNED = '0.5 A';
|
||||||
const Bye = '0 Bye';
|
|
||||||
const WonBye = '1 Bye';
|
public const LOST = '0';
|
||||||
|
|
||||||
|
public const NONE = '*';
|
||||||
|
|
||||||
|
public const WON = '1';
|
||||||
|
|
||||||
|
public const WON_ADJOURNED = '1 A';
|
||||||
|
|
||||||
|
public const WON_BYE = '1 Bye';
|
||||||
|
|
||||||
|
public const WON_FORFAIT = '1 FF';
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Tiebreak
|
* Enum Tiebreak
|
||||||
*
|
*
|
||||||
* List of all compatible tiebreaks
|
* List of all compatible tiebreaks
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Enums;
|
namespace JeroenED\Libpairtwo\Enums;
|
||||||
@ -19,34 +20,56 @@ use MyCLabs\Enum\Enum;
|
|||||||
*
|
*
|
||||||
* List of all compatible tiebreaks
|
* List of all compatible tiebreaks
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Tiebreak extends Enum
|
class Tiebreak extends Enum
|
||||||
{
|
{
|
||||||
const None = "";
|
public const ARO = "Average Rating";
|
||||||
const Keizer = "Keizer";
|
|
||||||
const Points = "Points";
|
public const AROCUT = "Average Rating Cut";
|
||||||
const Buchholz = "Buchholz";
|
|
||||||
const BuchholzMed = "Buchholz Median";
|
public const AVERAGE_PERFORMANCE = "Average performance";
|
||||||
const BuchholzCut = "Buchholz Cut";
|
|
||||||
const BuchholzMed2 = "Buchholz Median 2";
|
public const BAUMBACH = "Most wins"; // Ref: https://en.wikipedia.org/wiki/Tie-breaking_in_Swiss-system_tournaments#Most_wins_(Baumbach) Please tell me why?
|
||||||
const BuchholzCut2 = "Buchholz Cut 2";
|
|
||||||
const Sonneborn = "Sonneborn-Berger";
|
public const BETWEEN = "Mutual Result";
|
||||||
const Kashdan = "Kashdan";
|
|
||||||
const SoccerKashdan = "Soccer Kashdan";
|
public const BLACK_PLAYED = "Black played";
|
||||||
const Cumulative = "Cumulative";
|
|
||||||
const Between = "Mutual Result";
|
public const BLACK_WIN = "Black Winned";
|
||||||
const Koya = "Koya";
|
|
||||||
const Baumbach = "Most wins"; // Ref: https://en.wikipedia.org/wiki/Tie-breaking_in_Swiss-system_tournaments#Most_wins_(Baumbach) Please tell me why?
|
public const BUCHHOLZ = "Buchholz";
|
||||||
const AveragePerformance = "Average performance";
|
|
||||||
const Performance = "Performance";
|
public const BUCHHOLZ_CUT = "Buchholz Cut";
|
||||||
const Aro = "Average Rating";
|
|
||||||
const AroCut = "Average Rating Cut";
|
public const BUCHHOLZ_CUT_2 = "Buchholz Cut 2";
|
||||||
const BlackPlayed = "Black played";
|
|
||||||
const BlackWin = "Black Winned";
|
public const BUCHHOLZ_MED = "Buchholz Median";
|
||||||
const Testmatch = "Testmatch";
|
|
||||||
const Drawing = "Drawing of lot";
|
public const BUCHHOLZ_MED_2 = "Buchholz Median 2";
|
||||||
|
|
||||||
|
public const CUMULATIVE = "Cumulative";
|
||||||
|
|
||||||
|
public const DRAWING_OF_LOT = "Drawing of lot";
|
||||||
|
|
||||||
|
public const KASHDAN = "Kashdan";
|
||||||
|
|
||||||
|
public const KEIZER = "Keizer";
|
||||||
|
|
||||||
|
public const KOYA = "Koya";
|
||||||
|
|
||||||
|
public const NONE = "";
|
||||||
|
|
||||||
|
public const PERFORMANCE = "Performance";
|
||||||
|
|
||||||
|
public const POINTS = "Points";
|
||||||
|
|
||||||
|
public const SOCCER_KASHDAN = "Soccer Kashdan";
|
||||||
|
|
||||||
|
public const SONNEBORN = "Sonneborn-Berger";
|
||||||
|
|
||||||
|
public const TESTMATCH = "Testmatch";
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Title
|
* Enum Title
|
||||||
*
|
*
|
||||||
* List of all compatible titles
|
* List of all compatible titles
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Enums;
|
namespace JeroenED\Libpairtwo\Enums;
|
||||||
@ -19,24 +20,36 @@ use MyCLabs\Enum\Enum;
|
|||||||
*
|
*
|
||||||
* List of all compatible titles
|
* List of all compatible titles
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Title extends Enum
|
class Title extends Enum
|
||||||
{
|
{
|
||||||
const NONE = '*';
|
public const CM = 'Candidate Master';
|
||||||
const ELO = 'Elo';
|
|
||||||
const NM = 'National Master';
|
public const ELO = 'Elo';
|
||||||
const WCM = 'Woman Candidate Master';
|
|
||||||
const WFM = 'Woman Fide Master';
|
public const FM = 'Fide Master';
|
||||||
const CM = 'Candidate Master';
|
|
||||||
const WIM = 'Woman International Master';
|
public const GM = 'Grand Master';
|
||||||
const FM = 'Fide Master';
|
|
||||||
const WGM = 'Woman Grand Master';
|
public const HG = 'Honorary Grand Master';
|
||||||
const HM = 'Honorary International Master';
|
|
||||||
const IM = 'International Master';
|
public const HM = 'Honorary International Master';
|
||||||
const HG = 'Honorary Grand Master';
|
|
||||||
const GM = 'Grand Master';
|
public const IM = 'International Master';
|
||||||
|
|
||||||
|
public const NM = 'National Master';
|
||||||
|
|
||||||
|
public const NONE = '*';
|
||||||
|
|
||||||
|
public const WCM = 'Woman Candidate Master';
|
||||||
|
|
||||||
|
public const WFM = 'Woman Fide Master';
|
||||||
|
|
||||||
|
public const WGM = 'Woman Grand Master';
|
||||||
|
|
||||||
|
public const WIM = 'Woman International Master';
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum TournamentSystem
|
* Enum TournamentSystem
|
||||||
*
|
*
|
||||||
* List of all compatible tournament systems
|
* List of all compatible tournament systems
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Enums;
|
namespace JeroenED\Libpairtwo\Enums;
|
||||||
@ -19,15 +20,18 @@ use MyCLabs\Enum\Enum;
|
|||||||
*
|
*
|
||||||
* List of all compatible tournament systems
|
* List of all compatible tournament systems
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class TournamentSystem extends Enum
|
class TournamentSystem extends Enum
|
||||||
{
|
{
|
||||||
const Swiss = 'Swiss';
|
public const AMERICAN = 'American';
|
||||||
const Closed = 'Closed';
|
|
||||||
const American = 'American';
|
public const CLOSED = 'Closed';
|
||||||
const Keizer = 'Keizer';
|
|
||||||
|
public const KEIZER = 'Keizer';
|
||||||
|
|
||||||
|
public const SWISS = 'Swiss';
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception IncompatibleReaderException
|
* Exception IncompatibleReaderException
|
||||||
*
|
*
|
||||||
* Exception to be raised when a reader is used that is incompatible
|
* Exception to be raised when a reader is used that is incompatible
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Exceptions;
|
namespace JeroenED\Libpairtwo\Exceptions;
|
||||||
@ -17,10 +18,10 @@ namespace JeroenED\Libpairtwo\Exceptions;
|
|||||||
*
|
*
|
||||||
* Exception to be raised when a reader is used that is incompatible
|
* Exception to be raised when a reader is used that is incompatible
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class IncompatibleReaderException extends LibpairtwoException
|
class IncompatibleReaderException extends LibpairtwoException
|
||||||
{
|
{
|
||||||
|
@ -1,27 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception LibpairtwoException
|
* Exception LibpairtwoException
|
||||||
*
|
*
|
||||||
* General exception when something goes wrong with libpairtwo
|
* General exception when something goes wrong with libpairtwo
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Exceptions;
|
namespace JeroenED\Libpairtwo\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception LibpairtwoException
|
* Exception LibpairtwoException
|
||||||
*
|
*
|
||||||
* General exception when something goes wrong with libpairtwo
|
* General exception when something goes wrong with libpairtwo
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class LibpairtwoException extends \Exception
|
class LibpairtwoException extends Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
28
src/Game.php
28
src/Game.php
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Games
|
* Class Games
|
||||||
*
|
*
|
||||||
* Class for a game of the tournament
|
* Class for a game of the tournament
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo;
|
namespace JeroenED\Libpairtwo;
|
||||||
@ -21,10 +22,10 @@ use DateTime;
|
|||||||
*
|
*
|
||||||
* Class for a game of the tournament
|
* Class for a game of the tournament
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Game
|
class Game
|
||||||
{
|
{
|
||||||
@ -36,7 +37,7 @@ class Game
|
|||||||
public $White;
|
public $White;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pairing for this games as seen from blacks's side
|
* The pairing for this games as seen from black's side
|
||||||
*
|
*
|
||||||
* @var Pairing | null
|
* @var Pairing | null
|
||||||
*/
|
*/
|
||||||
@ -59,7 +60,8 @@ class Game
|
|||||||
/**
|
/**
|
||||||
* Returns fields that were not directly assigned.
|
* Returns fields that were not directly assigned.
|
||||||
* Class Game contains the special field Result containing the result of the game
|
* Class Game contains the special field Result containing the result of the game
|
||||||
* @param string $key
|
*
|
||||||
|
* @param string $key
|
||||||
* @return Gameresult
|
* @return Gameresult
|
||||||
*/
|
*/
|
||||||
public function __get(string $key)
|
public function __get(string $key)
|
||||||
@ -88,7 +90,7 @@ class Game
|
|||||||
$whitesplit = explode(" ", $whiteResult);
|
$whitesplit = explode(" ", $whiteResult);
|
||||||
$blacksplit = explode(" ", $blackResult);
|
$blacksplit = explode(" ", $blackResult);
|
||||||
|
|
||||||
$special='';
|
$special = '';
|
||||||
if (isset($whitesplit[1]) && $whitesplit[1] != 'Bye') {
|
if (isset($whitesplit[1]) && $whitesplit[1] != 'Bye') {
|
||||||
$special = ' ' . $whitesplit[1];
|
$special = ' ' . $whitesplit[1];
|
||||||
}
|
}
|
||||||
@ -110,7 +112,7 @@ class Game
|
|||||||
/**
|
/**
|
||||||
* Checks if 2 games are equal
|
* Checks if 2 games are equal
|
||||||
*
|
*
|
||||||
* @param Game $game
|
* @param Game $game
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function equals(Game $game): bool
|
public function equals(Game $game): bool
|
||||||
@ -118,6 +120,6 @@ class Game
|
|||||||
return (
|
return (
|
||||||
$this->White->Player === $game->White->Player &&
|
$this->White->Player === $game->White->Player &&
|
||||||
$this->Black->Player === $game->Black->Player &&
|
$this->Black->Player === $game->Black->Player &&
|
||||||
$this->Result == $game->Result);
|
$this->Result->getKey() == $game->Result->getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class IOFactory
|
* Class IOFactory
|
||||||
*
|
*
|
||||||
* Class for creating readers for pairing files
|
* Class for creating readers for pairing files
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo;
|
namespace JeroenED\Libpairtwo;
|
||||||
@ -21,10 +22,10 @@ use JeroenED\Libpairtwo\Readers\Pairtwo6;
|
|||||||
*
|
*
|
||||||
* Class for creating readers for pairing files
|
* Class for creating readers for pairing files
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
abstract class IOFactory
|
abstract class IOFactory
|
||||||
{
|
{
|
||||||
@ -45,7 +46,7 @@ abstract class IOFactory
|
|||||||
*
|
*
|
||||||
* Compatible types are Swar-4, Pairtwo-5, Pairtwo-6
|
* Compatible types are Swar-4, Pairtwo-5, Pairtwo-6
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return ReaderInterface
|
* @return ReaderInterface
|
||||||
* @throws LibpairtwoException
|
* @throws LibpairtwoException
|
||||||
*/
|
*/
|
||||||
@ -57,8 +58,7 @@ abstract class IOFactory
|
|||||||
|
|
||||||
// create reader class
|
// create reader class
|
||||||
$readerClass = self::$Readers[$type];
|
$readerClass = self::$Readers[$type];
|
||||||
$reader = new $readerClass;
|
|
||||||
|
|
||||||
return $reader;
|
return new $readerClass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface ReaderInterface
|
* Interface ReaderInterface
|
||||||
*
|
*
|
||||||
* Sets the methods a reader needs to implement
|
* Sets the methods a reader needs to implement
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Interfaces;
|
namespace JeroenED\Libpairtwo\Interfaces;
|
||||||
@ -19,18 +20,18 @@ use JeroenED\Libpairtwo\Tournament;
|
|||||||
*
|
*
|
||||||
* Sets the methods a reader needs to implement
|
* Sets the methods a reader needs to implement
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
interface ReaderInterface
|
interface ReaderInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Reads out $filename
|
* Reads out $filename
|
||||||
*
|
*
|
||||||
* @param $filename
|
* @param $filename
|
||||||
* @return ReaderInterface
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function read(string $filename): void;
|
public function read(string $filename): void;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Pairing
|
* Class Pairing
|
||||||
*
|
*
|
||||||
* Class for a pairing of the tournament
|
* Class for a pairing of the tournament
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo;
|
namespace JeroenED\Libpairtwo;
|
||||||
@ -20,10 +21,10 @@ use JeroenED\Libpairtwo\Enums\Result;
|
|||||||
*
|
*
|
||||||
* Class for a pairing of the tournament
|
* Class for a pairing of the tournament
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Pairing
|
class Pairing
|
||||||
{
|
{
|
||||||
@ -51,6 +52,7 @@ class Pairing
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The result of the Game. Possible values contain Won, Lost, Draw, Forfait, Bye, etc.
|
* The result of the Game. Possible values contain Won, Lost, Draw, Forfait, Bye, etc.
|
||||||
|
*
|
||||||
* @var Result
|
* @var Result
|
||||||
*/
|
*/
|
||||||
public $Result;
|
public $Result;
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Player
|
* Class Player
|
||||||
*
|
*
|
||||||
* Class for a player of the tournament
|
* Class for a player of the tournament
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo;
|
namespace JeroenED\Libpairtwo;
|
||||||
@ -21,10 +22,10 @@ use DateTime;
|
|||||||
*
|
*
|
||||||
* Class for a player of the tournament
|
* Class for a player of the tournament
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
@ -122,16 +123,20 @@ class Player
|
|||||||
/**
|
/**
|
||||||
* Returns an array of Player objects where name matches $search
|
* Returns an array of Player objects where name matches $search
|
||||||
*
|
*
|
||||||
* @param string $search
|
* @param string $search
|
||||||
* @param Tournament $tournament
|
* @param Tournament $tournament
|
||||||
* @return Player[]
|
* @return Player[]
|
||||||
*/
|
*/
|
||||||
public static function PlayersByName(string $search, Tournament $tournament): array
|
public static function PlayersByName(string $search, Tournament $tournament): array
|
||||||
{
|
{
|
||||||
/** @var Player[] */
|
/**
|
||||||
|
* @var Player[]
|
||||||
|
*/
|
||||||
$players = $tournament->Players;
|
$players = $tournament->Players;
|
||||||
|
|
||||||
/** @var Player[] */
|
/**
|
||||||
|
* @var Player[]
|
||||||
|
*/
|
||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
foreach ($players as $player) {
|
foreach ($players as $player) {
|
||||||
@ -145,7 +150,8 @@ class Player
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the elo of elotype for the player
|
* Returns the elo of elotype for the player
|
||||||
* @param string $type
|
*
|
||||||
|
* @param string $type
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getElo(string $type): int
|
public function getElo(string $type): int
|
||||||
@ -157,7 +163,7 @@ class Player
|
|||||||
* Sets the elo of elotype for the player
|
* Sets the elo of elotype for the player
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param int $value
|
* @param int $value
|
||||||
*/
|
*/
|
||||||
public function setElo(string $type, int $value): void
|
public function setElo(string $type, int $value): void
|
||||||
{
|
{
|
||||||
@ -171,7 +177,7 @@ class Player
|
|||||||
*
|
*
|
||||||
* Common possible values are Fide or National
|
* Common possible values are Fide or National
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getId(string $type): string
|
public function getId(string $type): string
|
||||||
@ -203,7 +209,7 @@ class Player
|
|||||||
{
|
{
|
||||||
$wins = 0;
|
$wins = 0;
|
||||||
foreach ($this->Pairings as $pairing) {
|
foreach ($this->Pairings as $pairing) {
|
||||||
if (array_search($pairing->Result, Constants::Won) !== false) {
|
if (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$wins++;
|
$wins++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,17 +223,17 @@ class Player
|
|||||||
* 0.5 points are awarded for draw
|
* 0.5 points are awarded for draw
|
||||||
* 0 points are awarded for loss
|
* 0 points are awarded for loss
|
||||||
*
|
*
|
||||||
* @param int $round
|
* @param int $round
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function calculatePoints(int $round = -1): float
|
public function calculatePoints(int $round = -1): float
|
||||||
{
|
{
|
||||||
$points = 0;
|
$points = 0;
|
||||||
foreach ($this->Pairings as $key=>$pairing) {
|
foreach ($this->Pairings as $key => $pairing) {
|
||||||
if ($key < $round || $round == -1) {
|
if ($key < $round || $round == -1) {
|
||||||
if (array_search($pairing->Result, Constants::Won) !== false) {
|
if (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$points = $points + 1;
|
$points = $points + 1;
|
||||||
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
|
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||||
$points = $points + 0.5;
|
$points = $points + 0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,13 +246,13 @@ class Player
|
|||||||
*
|
*
|
||||||
* Return the same score for all rounds until $byeround and added with a half point for each subsequent round
|
* Return the same score for all rounds until $byeround and added with a half point for each subsequent round
|
||||||
*
|
*
|
||||||
* @param int $byeround
|
* @param int $byeround
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function calculatePointsForVirtualPlayer(int $byeround): float
|
public function calculatePointsForVirtualPlayer(int $byeround): float
|
||||||
{
|
{
|
||||||
$points = $this->calculatePoints($byeround);
|
$points = $this->calculatePoints($byeround);
|
||||||
foreach (array_slice($this->Pairings, $byeround +1) as $key=>$pairing) {
|
foreach (array_slice($this->Pairings, $byeround + 1) as $key => $pairing) {
|
||||||
$points += 0.5;
|
$points += 0.5;
|
||||||
}
|
}
|
||||||
return $points;
|
return $points;
|
||||||
@ -264,11 +270,11 @@ class Player
|
|||||||
{
|
{
|
||||||
$points = 0;
|
$points = 0;
|
||||||
foreach ($this->Pairings as $pairing) {
|
foreach ($this->Pairings as $pairing) {
|
||||||
if (array_search($pairing->Result, Constants::NotPlayed) !== false) {
|
if (array_search($pairing->Result, Constants::NOTPLAYED) !== false) {
|
||||||
$points = $points + 0.5;
|
$points = $points + 0.5;
|
||||||
} elseif (array_search($pairing->Result, Constants::Won) !== false) {
|
} elseif (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$points = $points + 1;
|
$points = $points + 1;
|
||||||
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
|
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||||
$points = $points + 0.5;
|
$points = $points + 0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,23 +285,23 @@ class Player
|
|||||||
*
|
*
|
||||||
* WARNING: Calculation currently incorrect. Uses the rule of 400 as temporary solution
|
* WARNING: Calculation currently incorrect. Uses the rule of 400 as temporary solution
|
||||||
*
|
*
|
||||||
* @param $type
|
* @param $type
|
||||||
* @param $unratedElo
|
* @param $unratedElo
|
||||||
* @return int
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function Performance(string $type, int $unratedElo): float
|
public function Performance(string $type, int $unratedElo): float
|
||||||
{
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$opponents = 0;
|
$opponents = 0;
|
||||||
foreach ($this->Pairings as $pairing) {
|
foreach ($this->Pairings as $pairing) {
|
||||||
if (array_search($pairing->Result, Constants::NotPlayed) === false) {
|
if (array_search($pairing->Result, Constants::NOTPLAYED) === false) {
|
||||||
$opponentElo = $pairing->Opponent->getElo($type);
|
$opponentElo = $pairing->Opponent->getElo($type);
|
||||||
$opponentElo = $opponentElo != 0 ? $opponentElo : $unratedElo;
|
$opponentElo = $opponentElo != 0 ? $opponentElo : $unratedElo;
|
||||||
if (array_search($pairing->Result, Constants::Won) !== false) {
|
if (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$total += $opponentElo + 400;
|
$total += $opponentElo + 400;
|
||||||
} elseif (array_search($pairing->Result, Constants::Lost) !== false) {
|
} elseif (array_search($pairing->Result, Constants::LOST) !== false) {
|
||||||
$total += $opponentElo - 400;
|
$total += $opponentElo - 400;
|
||||||
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
|
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||||
$total += $opponentElo;
|
$total += $opponentElo;
|
||||||
}
|
}
|
||||||
$opponents++;
|
$opponents++;
|
||||||
@ -314,7 +320,7 @@ class Player
|
|||||||
{
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
foreach ($this->Pairings as $pairing) {
|
foreach ($this->Pairings as $pairing) {
|
||||||
if (array_search($pairing->Result, Constants::Played) !== false) {
|
if (array_search($pairing->Result, Constants::PLAYED) !== false) {
|
||||||
$total++;
|
$total++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,7 +330,7 @@ class Player
|
|||||||
/**
|
/**
|
||||||
* Returns if player has played against all players of the array
|
* Returns if player has played against all players of the array
|
||||||
*
|
*
|
||||||
* @param Player[] $players
|
* @param Player[] $players
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasPlayedAllPlayersOfArray(array $players): bool
|
public function hasPlayedAllPlayersOfArray(array $players): bool
|
||||||
@ -362,7 +368,7 @@ class Player
|
|||||||
/**
|
/**
|
||||||
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
|
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return bool|DateTime|int|string|null
|
* @return bool|DateTime|int|string|null
|
||||||
*/
|
*/
|
||||||
public function __get(string $key)
|
public function __get(string $key)
|
||||||
@ -382,7 +388,7 @@ class Player
|
|||||||
/**
|
/**
|
||||||
* Sets binary data that is read out the pairing file but is not needed immediately
|
* Sets binary data that is read out the pairing file but is not needed immediately
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param bool|int|DateTime|string $value
|
* @param bool|int|DateTime|string $value
|
||||||
*/
|
*/
|
||||||
public function __set(string $key, $value): void
|
public function __set(string $key, $value): void
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reader Pairtwo6
|
* Reader Pairtwo6
|
||||||
*
|
*
|
||||||
* Reads out Pairtwo-6 and Pairtwo-5 files
|
* Reads out Pairtwo-6 and Pairtwo-5 files
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Readers;
|
namespace JeroenED\Libpairtwo\Readers;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
use JeroenED\Libpairtwo\Enums\Color;
|
use JeroenED\Libpairtwo\Enums\Color;
|
||||||
use JeroenED\Libpairtwo\Enums\Gender;
|
use JeroenED\Libpairtwo\Enums\Gender;
|
||||||
use JeroenED\Libpairtwo\Enums\Result;
|
use JeroenED\Libpairtwo\Enums\Result;
|
||||||
@ -32,18 +33,22 @@ use DateTime;
|
|||||||
*
|
*
|
||||||
* Reads out Pairtwo-6 files
|
* Reads out Pairtwo-6 files
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Pairtwo6 implements ReaderInterface
|
class Pairtwo6 implements ReaderInterface
|
||||||
{
|
{
|
||||||
const PT_DAYFACTOR = 32;
|
public const PT_DAYFACTOR = 32;
|
||||||
const PT_MONTHFACTOR = 16;
|
|
||||||
const PT_YEARFACTOR = 512;
|
public const PT_MONTHFACTOR = 16;
|
||||||
const PT_PASTOFFSET = 117;
|
|
||||||
const CompatibleVersions = ['6.', '5.'];
|
public const PT_YEARFACTOR = 512;
|
||||||
|
|
||||||
|
public const PT_PASTOFFSET = 117;
|
||||||
|
|
||||||
|
public const COMPATIBLE_VERSIONS = ['6.', '5.'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version of Pairtwo this file was created with
|
* Version of Pairtwo this file was created with
|
||||||
@ -61,6 +66,7 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Binary data that was read out of the pairing file
|
* Binary data that was read out of the pairing file
|
||||||
|
*
|
||||||
* @var bool|DateTime|int|string[]
|
* @var bool|DateTime|int|string[]
|
||||||
*/
|
*/
|
||||||
private $BinaryData;
|
private $BinaryData;
|
||||||
@ -68,7 +74,7 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
/**
|
/**
|
||||||
* Returns binary data that was read out the pairtwo file but was not needed immediately
|
* Returns binary data that was read out the pairtwo file but was not needed immediately
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return bool|DateTime|int|string|null
|
* @return bool|DateTime|int|string|null
|
||||||
*/
|
*/
|
||||||
public function __get(string $key)
|
public function __get(string $key)
|
||||||
@ -82,7 +88,7 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
/**
|
/**
|
||||||
* Sets binary data that is read out the pairtwo file but is not needed immediately
|
* Sets binary data that is read out the pairtwo file but is not needed immediately
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param bool|int|DateTime|string $value
|
* @param bool|int|DateTime|string $value
|
||||||
*/
|
*/
|
||||||
public function __set(string $key, $value): void
|
public function __set(string $key, $value): void
|
||||||
@ -93,7 +99,7 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
/**
|
/**
|
||||||
* Actually reads the Swar-File
|
* Actually reads the Swar-File
|
||||||
*
|
*
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @throws IncompatibleReaderException
|
* @throws IncompatibleReaderException
|
||||||
*/
|
*/
|
||||||
public function read(string $filename): void
|
public function read(string $filename): void
|
||||||
@ -109,7 +115,7 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
$this->Release = $this->readData('String', substr($swscontents, $offset, $length));
|
$this->Release = $this->readData('String', substr($swscontents, $offset, $length));
|
||||||
$offset += $length;
|
$offset += $length;
|
||||||
|
|
||||||
if (array_search(substr($this->Release, 0, 2), self::CompatibleVersions) === false) {
|
if (array_search(substr($this->Release, 0, 2), self::COMPATIBLE_VERSIONS) === false) {
|
||||||
throw new IncompatibleReaderException("This file was not created with Pairtwo 5 or higher");
|
throw new IncompatibleReaderException("This file was not created with Pairtwo 5 or higher");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,53 +267,53 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
$length = 4;
|
$length = 4;
|
||||||
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
|
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
|
||||||
case 1:
|
case 1:
|
||||||
$tiebreak = Tiebreak::Buchholz;
|
$tiebreak = Tiebreak::BUCHHOLZ;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$tiebreak = Tiebreak::BuchholzMed;
|
$tiebreak = Tiebreak::BUCHHOLZ_MED;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$tiebreak = Tiebreak::BuchholzCut;
|
$tiebreak = Tiebreak::BUCHHOLZ_CUT;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
$tiebreak = Tiebreak::Sonneborn;
|
$tiebreak = Tiebreak::SONNEBORN;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
$tiebreak = Tiebreak::Kashdan;
|
$tiebreak = Tiebreak::KASHDAN;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
$tiebreak = Tiebreak::Cumulative;
|
$tiebreak = Tiebreak::CUMULATIVE;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
$tiebreak = Tiebreak::Between;
|
$tiebreak = Tiebreak::BETWEEN;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
$tiebreak = Tiebreak::Koya;
|
$tiebreak = Tiebreak::KOYA;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
$tiebreak = Tiebreak::Baumbach;
|
$tiebreak = Tiebreak::BAUMBACH;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
$tiebreak = Tiebreak::Performance;
|
$tiebreak = Tiebreak::PERFORMANCE;
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
$tiebreak = Tiebreak::Aro;
|
$tiebreak = Tiebreak::ARO;
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
$tiebreak = Tiebreak::AroCut;
|
$tiebreak = Tiebreak::AROCUT;
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
$tiebreak = Tiebreak::BlackPlayed;
|
$tiebreak = Tiebreak::BLACK_PLAYED;
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
$tiebreak = Tiebreak::Testmatch;
|
$tiebreak = Tiebreak::TESTMATCH;
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
$tiebreak = Tiebreak::Drawing;
|
$tiebreak = Tiebreak::DRAWING_OF_LOT;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
$tiebreak = Tiebreak::None;
|
$tiebreak = Tiebreak::NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->Tournament->addTieBreak(new Tiebreak($tiebreak));
|
$this->Tournament->addTieBreak(new Tiebreak($tiebreak));
|
||||||
@ -447,13 +453,13 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
$length = 1;
|
$length = 1;
|
||||||
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
|
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
|
||||||
case 1:
|
case 1:
|
||||||
$gender = Gender::Male;
|
$gender = Gender::MALE;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$gender = Gender::Female;
|
$gender = Gender::FEMALE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$gender = Gender::Neutral;
|
$gender = Gender::NEUTRAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$player->Gender = new Gender($gender);
|
$player->Gender = new Gender($gender);
|
||||||
@ -498,12 +504,12 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
$this->Tournament->addPlayer($player);
|
$this->Tournament->addPlayer($player);
|
||||||
}
|
}
|
||||||
// PlayerNames
|
// PlayerNames
|
||||||
$length = (Integer)$this->NewNamePos + 0;
|
$length = (int)$this->NewNamePos + 0;
|
||||||
$this->PlayerNames = substr($swscontents, $offset, $length);
|
$this->PlayerNames = substr($swscontents, $offset, $length);
|
||||||
$offset += $length;
|
$offset += $length;
|
||||||
|
|
||||||
for ($i = 0; $i < $this->NewPlayer; $i++) {
|
for ($i = 0; $i < $this->NewPlayer; $i++) {
|
||||||
$player = $this->Tournament->PlayerById($i);
|
$player = $this->Tournament->playerById($i);
|
||||||
$namelength = $player->NameLength;
|
$namelength = $player->NameLength;
|
||||||
$nameoffset = $player->NamePos;
|
$nameoffset = $player->NamePos;
|
||||||
$player->Name = $this->readData("String", substr($this->PlayerNames, $nameoffset, $namelength));
|
$player->Name = $this->readData("String", substr($this->PlayerNames, $nameoffset, $namelength));
|
||||||
@ -585,17 +591,17 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
$length = 4;
|
$length = 4;
|
||||||
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
|
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
|
||||||
case 2:
|
case 2:
|
||||||
$system = TournamentSystem::Closed;
|
$system = TournamentSystem::CLOSED;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
$system = TournamentSystem::American;
|
$system = TournamentSystem::AMERICAN;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
$system = TournamentSystem::Keizer;
|
$system = TournamentSystem::KEIZER;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
$system = TournamentSystem::Swiss;
|
$system = TournamentSystem::SWISS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->Tournament->System = new TournamentSystem($system);
|
$this->Tournament->System = new TournamentSystem($system);
|
||||||
@ -651,12 +657,12 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
for ($x = 0; $x < $this->CreatedRounds; $x++) {
|
for ($x = 0; $x < $this->CreatedRounds; $x++) {
|
||||||
$pairing = new Pairing();
|
$pairing = new Pairing();
|
||||||
|
|
||||||
$pairing->Player = $this->Tournament->PlayerById($i);
|
$pairing->Player = $this->Tournament->playerById($i);
|
||||||
|
|
||||||
$length = 4;
|
$length = 4;
|
||||||
$opponent = $this->readData('Int', substr($swscontents, $offset, $length));
|
$opponent = $this->readData('Int', substr($swscontents, $offset, $length));
|
||||||
if ($opponent != 4294967295) {
|
if ($opponent != 4294967295) {
|
||||||
$pairing->Opponent = $this->Tournament->PlayerById($opponent);
|
$pairing->Opponent = $this->Tournament->playerById($opponent);
|
||||||
}
|
}
|
||||||
$offset += $length;
|
$offset += $length;
|
||||||
|
|
||||||
@ -665,15 +671,15 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
|
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
|
||||||
case 255:
|
case 255:
|
||||||
case 253:
|
case 253:
|
||||||
$color = Color::Black;
|
$color = Color::BLACK;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
case 3:
|
case 3:
|
||||||
$color = Color::White;
|
$color = Color::WHITE;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
$color = Color::None;
|
$color = Color::NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$pairing->Color = new Color($color);
|
$pairing->Color = new Color($color);
|
||||||
@ -682,38 +688,38 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
$length = 1;
|
$length = 1;
|
||||||
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
|
switch ($this->readData('Int', substr($swscontents, $offset, $length))) {
|
||||||
case 1:
|
case 1:
|
||||||
$result = Result::Lost;
|
$result = Result::LOST;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$result = Result::Absent;
|
$result = Result::ABSENT;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$result = Result::Adjourned;
|
$result = Result::ADJOURNED;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
$result = Result::Bye;
|
$result = Result::BYE;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
$result = Result::Draw;
|
$result = Result::DRAW;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
$result = Result::DrawAdjourned;
|
$result = Result::DRAW_ADJOURNED;
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
$result = Result::Won;
|
$result = Result::WON;
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
$result = Result::WonForfait;
|
$result = Result::WON_FORFAIT;
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
$result = Result::WonAdjourned;
|
$result = Result::WON_ADJOURNED;
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
$result = Result::WonBye;
|
$result = Result::WON_BYE;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
$result = Result::None;
|
$result = Result::NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$pairing->Result = new Result($result);
|
$pairing->Result = new Result($result);
|
||||||
@ -745,9 +751,9 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
* * Bool (Boolean representation of $data. Default: false)
|
* * Bool (Boolean representation of $data. Default: false)
|
||||||
* * Date (Date representation of $data. Default: 1902/01/01)
|
* * Date (Date representation of $data. Default: 1902/01/01)
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $data
|
* @param string $data
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
* @return bool|DateTime|int|string
|
* @return bool|DateTime|int|string
|
||||||
*/
|
*/
|
||||||
private function readData(string $type, string $data, $default = null)
|
private function readData(string $type, string $data, $default = null)
|
||||||
@ -759,7 +765,6 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
return (is_null($default)) ? '' : $default;
|
return (is_null($default)) ? '' : $default;
|
||||||
}
|
}
|
||||||
return iconv('windows-1252', 'utf-8', $data);
|
return iconv('windows-1252', 'utf-8', $data);
|
||||||
break;
|
|
||||||
case 'Hex':
|
case 'Hex':
|
||||||
case 'Int':
|
case 'Int':
|
||||||
case 'Bool':
|
case 'Bool':
|
||||||
@ -793,12 +798,11 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
}
|
}
|
||||||
return $this->convertUIntToTimestamp(hexdec($hex));
|
return $this->convertUIntToTimestamp(hexdec($hex));
|
||||||
} elseif ($type == 'Bool') {
|
} elseif ($type == 'Bool') {
|
||||||
return ($hex == "01") ? true : false;
|
return ($hex == "01");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException("Datatype not known");
|
throw new InvalidArgumentException("Datatype not known");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -807,7 +811,7 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
/**
|
/**
|
||||||
* Converts integer value to a date representation
|
* Converts integer value to a date representation
|
||||||
*
|
*
|
||||||
* @param int $date
|
* @param int $date
|
||||||
* @return bool|DateTime
|
* @return bool|DateTime
|
||||||
*/
|
*/
|
||||||
private function convertUIntToTimestamp(int $date)
|
private function convertUIntToTimestamp(int $date)
|
||||||
@ -844,13 +848,13 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
private function addTiebreaks(): void
|
private function addTiebreaks(): void
|
||||||
{
|
{
|
||||||
switch ($this->Tournament->System) {
|
switch ($this->Tournament->System) {
|
||||||
case TournamentSystem::Keizer:
|
case TournamentSystem::KEIZER:
|
||||||
$firstElement = new Tiebreak(Tiebreak::Keizer);
|
$firstElement = new Tiebreak(Tiebreak::KEIZER);
|
||||||
break;
|
break;
|
||||||
case TournamentSystem::American:
|
case TournamentSystem::AMERICAN:
|
||||||
case TournamentSystem::Closed:
|
case TournamentSystem::CLOSED:
|
||||||
case TournamentSystem::Swiss:
|
case TournamentSystem::SWISS:
|
||||||
$firstElement = new Tiebreak(Tiebreak::Points);
|
$firstElement = new Tiebreak(Tiebreak::POINTS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$tiebreaks = $this->Tournament->Tiebreaks;
|
$tiebreaks = $this->Tournament->Tiebreaks;
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reader Swar-4
|
* Reader Swar-4
|
||||||
*
|
*
|
||||||
* Reads out Swar-4 files
|
* Reads out Swar-4 files
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo\Readers;
|
namespace JeroenED\Libpairtwo\Readers;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
use JeroenED\Libpairtwo\Enums\Color;
|
use JeroenED\Libpairtwo\Enums\Color;
|
||||||
use JeroenED\Libpairtwo\Enums\Gender;
|
use JeroenED\Libpairtwo\Enums\Gender;
|
||||||
use JeroenED\Libpairtwo\Enums\Result;
|
use JeroenED\Libpairtwo\Enums\Result;
|
||||||
@ -30,10 +33,10 @@ use DateTime;
|
|||||||
*
|
*
|
||||||
* Reads out Swar-4 files
|
* Reads out Swar-4 files
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Swar4 implements ReaderInterface
|
class Swar4 implements ReaderInterface
|
||||||
{
|
{
|
||||||
@ -58,10 +61,12 @@ class Swar4 implements ReaderInterface
|
|||||||
*/
|
*/
|
||||||
private $BinaryData;
|
private $BinaryData;
|
||||||
|
|
||||||
/** @var array */
|
/**
|
||||||
const CompatibleVersions = ['v4.'];
|
* @var array
|
||||||
|
*/
|
||||||
|
public const COMPATIBLE_VERSIONS = ['v4.'];
|
||||||
|
|
||||||
const Tempos = [
|
public const TEMPOS = [
|
||||||
[
|
[
|
||||||
'105 min/40 moves + 15 min. QPF',
|
'105 min/40 moves + 15 min. QPF',
|
||||||
'120 min/40 moves + 15 min. with incr. 30" starting from 40th move',
|
'120 min/40 moves + 15 min. with incr. 30" starting from 40th move',
|
||||||
@ -78,7 +83,8 @@ class Swar4 implements ReaderInterface
|
|||||||
'90 min with incr. 30"',
|
'90 min with incr. 30"',
|
||||||
'50 min with incr. 10"',
|
'50 min with incr. 10"',
|
||||||
'other'
|
'other'
|
||||||
],[
|
],
|
||||||
|
[
|
||||||
'10 min. with incr. 10"',
|
'10 min. with incr. 10"',
|
||||||
'10 min. with incr. 15"',
|
'10 min. with incr. 15"',
|
||||||
'10 min. with incr.5"',
|
'10 min. with incr.5"',
|
||||||
@ -102,7 +108,8 @@ class Swar4 implements ReaderInterface
|
|||||||
'45 min. QPF',
|
'45 min. QPF',
|
||||||
'8 min. with incr.4"',
|
'8 min. with incr.4"',
|
||||||
'other'
|
'other'
|
||||||
],[
|
],
|
||||||
|
[
|
||||||
'3 min. with incr. 2"',
|
'3 min. with incr. 2"',
|
||||||
'3 min. with incr. 3"',
|
'3 min. with incr. 3"',
|
||||||
'4 min. with incr. 2"',
|
'4 min. with incr. 2"',
|
||||||
@ -124,6 +131,7 @@ class Swar4 implements ReaderInterface
|
|||||||
* Actually reads the Swar-File
|
* Actually reads the Swar-File
|
||||||
*
|
*
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
|
*
|
||||||
* @throws IncompatibleReaderException
|
* @throws IncompatibleReaderException
|
||||||
*/
|
*/
|
||||||
public function read(string $filename): void
|
public function read(string $filename): void
|
||||||
@ -131,7 +139,7 @@ class Swar4 implements ReaderInterface
|
|||||||
$swshandle = fopen($filename, 'rb');
|
$swshandle = fopen($filename, 'rb');
|
||||||
|
|
||||||
$this->Release = $this->readData('String', $swshandle);
|
$this->Release = $this->readData('String', $swshandle);
|
||||||
if (array_search(substr($this->Release, 0, 3), self::CompatibleVersions) === false) {
|
if (array_search(substr($this->Release, 0, 3), self::COMPATIBLE_VERSIONS) === false) {
|
||||||
throw new IncompatibleReaderException("This file was not created with Swar 4");
|
throw new IncompatibleReaderException("This file was not created with Swar 4");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,16 +189,16 @@ class Swar4 implements ReaderInterface
|
|||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
default:
|
default:
|
||||||
$system = TournamentSystem::Swiss;
|
$system = TournamentSystem::SWISS;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
case 7:
|
case 7:
|
||||||
$system = TournamentSystem::Closed;
|
$system = TournamentSystem::CLOSED;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
case 9:
|
case 9:
|
||||||
$system = TournamentSystem::American;
|
$system = TournamentSystem::AMERICAN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->Tournament->System = new TournamentSystem($system);
|
$this->Tournament->System = new TournamentSystem($system);
|
||||||
@ -244,7 +252,7 @@ class Swar4 implements ReaderInterface
|
|||||||
// [DATES]
|
// [DATES]
|
||||||
$this->readData('String', $swshandle);
|
$this->readData('String', $swshandle);
|
||||||
|
|
||||||
$this->Tournament->Tempo = Self::Tempos[$this->Tournament->TournoiStd][$this->Tournament->TempoIndex];
|
$this->Tournament->Tempo = self::TEMPOS[ $this->Tournament->TournoiStd ][ $this->Tournament->TempoIndex ];
|
||||||
|
|
||||||
for ($i = 0; $i < $this->Tournament->NoOfRounds; $i++) {
|
for ($i = 0; $i < $this->Tournament->NoOfRounds; $i++) {
|
||||||
$round = new Round();
|
$round = new Round();
|
||||||
@ -261,52 +269,52 @@ class Swar4 implements ReaderInterface
|
|||||||
switch ($this->readData('Int', $swshandle)) {
|
switch ($this->readData('Int', $swshandle)) {
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
$tiebreak = Tiebreak::None;
|
$tiebreak = Tiebreak::NONE;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$tiebreak = Tiebreak::Buchholz;
|
$tiebreak = Tiebreak::BUCHHOLZ;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$tiebreak = Tiebreak::BuchholzMed;
|
$tiebreak = Tiebreak::BUCHHOLZ_MED;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$tiebreak = Tiebreak::BuchholzMed2;
|
$tiebreak = Tiebreak::BUCHHOLZ_MED_2;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
$tiebreak = Tiebreak::BuchholzCut;
|
$tiebreak = Tiebreak::BUCHHOLZ_CUT;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
$tiebreak = Tiebreak::BuchholzCut2;
|
$tiebreak = Tiebreak::BUCHHOLZ_CUT_2;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
$tiebreak = Tiebreak::Sonneborn;
|
$tiebreak = Tiebreak::SONNEBORN;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
$tiebreak = Tiebreak::Cumulative;
|
$tiebreak = Tiebreak::CUMULATIVE;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
$tiebreak = Tiebreak::Between;
|
$tiebreak = Tiebreak::BETWEEN;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
$tiebreak = Tiebreak::Koya;
|
$tiebreak = Tiebreak::KOYA;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
$tiebreak = Tiebreak::Baumbach;
|
$tiebreak = Tiebreak::BAUMBACH;
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
$tiebreak = Tiebreak::AveragePerformance;
|
$tiebreak = Tiebreak::AVERAGE_PERFORMANCE;
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
$tiebreak = Tiebreak::Aro;
|
$tiebreak = Tiebreak::ARO;
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
$tiebreak = Tiebreak::AroCut;
|
$tiebreak = Tiebreak::AROCUT;
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
$tiebreak = Tiebreak::BlackPlayed;
|
$tiebreak = Tiebreak::BLACK_PLAYED;
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
$tiebreak = Tiebreak::BlackWin;
|
$tiebreak = Tiebreak::BLACK_WIN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$tiebreaks[] = new Tiebreak($tiebreak);
|
$tiebreaks[] = new Tiebreak($tiebreak);
|
||||||
@ -323,19 +331,19 @@ class Swar4 implements ReaderInterface
|
|||||||
|
|
||||||
$this->Tournament->Catogory_type = $this->readData('Int', $swshandle);
|
$this->Tournament->Catogory_type = $this->readData('Int', $swshandle);
|
||||||
for ($i = 0; $i <= 12; $i++) {
|
for ($i = 0; $i <= 12; $i++) {
|
||||||
$category[$i]['Cat1'] =$this->readData('String', $swshandle);
|
$category[ $i ][ 'Cat1' ] = $this->readData('String', $swshandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i <= 12; $i++) {
|
for ($i = 0; $i <= 12; $i++) {
|
||||||
$category[$i]['Cat2'] =$this->readData('String', $swshandle);
|
$category[ $i ][ 'Cat2' ] = $this->readData('String', $swshandle);
|
||||||
}
|
}
|
||||||
$this->Tournament->Category = $category;
|
$this->Tournament->Category = $category;
|
||||||
// [XTRA_POINTS]
|
// [XTRA_POINTS]
|
||||||
$this->readData('String', $swshandle);
|
$this->readData('String', $swshandle);
|
||||||
|
|
||||||
for ($i = 0; $i < 4; $i++) {
|
for ($i = 0; $i < 4; $i++) {
|
||||||
$extrapoints[$i]['pts'] = $this->readData('Int', $swshandle);
|
$extrapoints[ $i ][ 'pts' ] = $this->readData('Int', $swshandle);
|
||||||
$extrapoints[$i]['elo'] = $this->readData('Int', $swshandle);
|
$extrapoints[ $i ][ 'elo' ] = $this->readData('Int', $swshandle);
|
||||||
}
|
}
|
||||||
$this->Tournament->Extrapoints = $extrapoints;
|
$this->Tournament->Extrapoints = $extrapoints;
|
||||||
|
|
||||||
@ -351,19 +359,19 @@ class Swar4 implements ReaderInterface
|
|||||||
$player = new Player();
|
$player = new Player();
|
||||||
$player->Classement = $this->readData('Int', $swshandle);
|
$player->Classement = $this->readData('Int', $swshandle);
|
||||||
$player->Name = $this->readData('String', $swshandle);
|
$player->Name = $this->readData('String', $swshandle);
|
||||||
$inscriptionNos[$this->readData('Int', $swshandle)] = $i;
|
$inscriptionNos[ $this->readData('Int', $swshandle) ] = $i;
|
||||||
$player->Rank = $this->readData('Int', $swshandle);
|
$player->Rank = $this->readData('Int', $swshandle);
|
||||||
$player->CatIndex = $this->readData('Int', $swshandle);
|
$player->CatIndex = $this->readData('Int', $swshandle);
|
||||||
$player->DateOfBirth = $this->readData('Date', $swshandle);
|
$player->DateOfBirth = $this->readData('Date', $swshandle);
|
||||||
switch ($this->readData('Int', $swshandle)) {
|
switch ($this->readData('Int', $swshandle)) {
|
||||||
case 1:
|
case 1:
|
||||||
$gender = Gender::Male;
|
$gender = Gender::MALE;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$gender = Gender::Female;
|
$gender = Gender::FEMALE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$gender = Gender::Neutral;
|
$gender = Gender::NEUTRAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$player->Gender = new Gender($gender);
|
$player->Gender = new Gender($gender);
|
||||||
@ -415,10 +423,10 @@ class Swar4 implements ReaderInterface
|
|||||||
$player->setId('Club', $this->readData('Int', $swshandle));
|
$player->setId('Club', $this->readData('Int', $swshandle));
|
||||||
$player->ClubName = $this->readData('String', $swshandle);
|
$player->ClubName = $this->readData('String', $swshandle);
|
||||||
$player->NoOfMatchesNoBye = $this->readData('Int', $swshandle);
|
$player->NoOfMatchesNoBye = $this->readData('Int', $swshandle);
|
||||||
$player->Points = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
$player->Points = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
||||||
$player->AmericanPoints = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
$player->AmericanPoints = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
||||||
for ($t = 0; $t < 5; $t++) {
|
for ($t = 0; $t < 5; $t++) {
|
||||||
$tiebreaks[$t] = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
$tiebreaks[ $t ] = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
||||||
}
|
}
|
||||||
$player->Tiebreak = $tiebreaks;
|
$player->Tiebreak = $tiebreaks;
|
||||||
$player->Performance = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
$player->Performance = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
||||||
@ -432,14 +440,14 @@ class Swar4 implements ReaderInterface
|
|||||||
|
|
||||||
if ($player->AllocatedRounds != 0) {
|
if ($player->AllocatedRounds != 0) {
|
||||||
for ($j = 0; $j < $player->AllocatedRounds; $j++) {
|
for ($j = 0; $j < $player->AllocatedRounds; $j++) {
|
||||||
$pairing[$pt]['player'] = $i;
|
$pairing[ $pt ][ 'player' ] = $i;
|
||||||
$pairing[$pt]['round'] = $this->readData('Int', $swshandle) - 1;
|
$pairing[ $pt ][ 'round' ] = $this->readData('Int', $swshandle) - 1;
|
||||||
$pairing[$pt]['table'] = $this->readData('Int', $swshandle) - 1;
|
$pairing[ $pt ][ 'table' ] = $this->readData('Int', $swshandle) - 1;
|
||||||
$pairing[$pt]['opponent'] = $this->readData('Int', $swshandle);
|
$pairing[ $pt ][ 'opponent' ] = $this->readData('Int', $swshandle);
|
||||||
$pairing[$pt]['result'] = $this->readData('Hex', $swshandle);
|
$pairing[ $pt ][ 'result' ] = $this->readData('Hex', $swshandle);
|
||||||
$pairing[$pt]['color'] = $this->readData('Int', $swshandle);
|
$pairing[ $pt ][ 'color' ] = $this->readData('Int', $swshandle);
|
||||||
$pairing[$pt]['float'] = $this->readData('Int', $swshandle);
|
$pairing[ $pt ][ 'float' ] = $this->readData('Int', $swshandle);
|
||||||
$pairing[$pt]['extrapoints'] = $this->readData('Int', $swshandle);
|
$pairing[ $pt ][ 'extrapoints' ] = $this->readData('Int', $swshandle);
|
||||||
|
|
||||||
$pt++;
|
$pt++;
|
||||||
}
|
}
|
||||||
@ -450,61 +458,62 @@ class Swar4 implements ReaderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ptn = 0;
|
$ptn = 0;
|
||||||
while (isset($this->Tournament->Pairing[$ptn]['round'])) {
|
while (isset($this->Tournament->Pairing[ $ptn ][ 'round' ])) {
|
||||||
$pairing = new Pairing();
|
$pairing = new Pairing();
|
||||||
|
|
||||||
$pairing->Player = $this->Tournament->PlayerById($this->Tournament->Pairing[$ptn]['player']);
|
$pairing->Player = $this->Tournament->playerById($this->Tournament->Pairing[ $ptn ][ 'player' ]);
|
||||||
$pairing->Round = $this->Tournament->Pairing[$ptn]['round'];
|
$pairing->Round = $this->Tournament->Pairing[ $ptn ][ 'round' ];
|
||||||
if ($this->Tournament->Pairing[$ptn]['opponent'] != 4294967295) {
|
if ($this->Tournament->Pairing[ $ptn ][ 'opponent' ] != 4294967295) {
|
||||||
$pairing->Opponent = $this->Tournament->PlayerById($inscriptionNos[$this->Tournament->Pairing[$ptn]['opponent']]);
|
$pairing->Opponent =
|
||||||
|
$this->Tournament->playerById($inscriptionNos[ $this->Tournament->Pairing[ $ptn ][ 'opponent' ] ]);
|
||||||
}
|
}
|
||||||
switch ($this->Tournament->Pairing[$ptn]['result']) {
|
switch ($this->Tournament->Pairing[ $ptn ][ 'result' ]) {
|
||||||
case '1000':
|
case '1000':
|
||||||
$result = Result::Lost;
|
$result = Result::LOST;
|
||||||
break;
|
break;
|
||||||
case '01':
|
case '01':
|
||||||
$result = Result::Absent;
|
$result = Result::ABSENT;
|
||||||
break;
|
break;
|
||||||
case '0010':
|
case '0010':
|
||||||
$result = Result::Bye;
|
$result = Result::BYE;
|
||||||
break;
|
break;
|
||||||
case '2000':
|
case '2000':
|
||||||
$result = Result::Draw;
|
$result = Result::DRAW;
|
||||||
break;
|
break;
|
||||||
case '4000':
|
case '4000':
|
||||||
$result = Result::Won;
|
$result = Result::WON;
|
||||||
break;
|
break;
|
||||||
case '04':
|
case '04':
|
||||||
$result = Result::WonForfait;
|
$result = Result::WON_FORFAIT;
|
||||||
break;
|
break;
|
||||||
case '40':
|
case '40':
|
||||||
$result = Result::WonBye;
|
$result = Result::WON_BYE;
|
||||||
break;
|
break;
|
||||||
case '00':
|
case '00':
|
||||||
default:
|
default:
|
||||||
$result = Result::None;
|
$result = Result::NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (array_search($this->Tournament->Pairing[$ptn]['table'], [ 16383, 8191 ]) !== false) {
|
if (array_search($this->Tournament->Pairing[ $ptn ][ 'table' ], [16383, 8191]) !== false) {
|
||||||
$result = Result::Absent;
|
$result = Result::ABSENT;
|
||||||
}
|
}
|
||||||
$pairing->Result = new Result($result);
|
$pairing->Result = new Result($result);
|
||||||
|
|
||||||
switch ($this->Tournament->Pairing[$ptn]['color']) {
|
switch ($this->Tournament->Pairing[ $ptn ][ 'color' ]) {
|
||||||
case 4294967295:
|
case 4294967295:
|
||||||
$color = Color::Black;
|
$color = Color::BLACK;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$color = Color::White;
|
$color = Color::WHITE;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
$color = Color::None;
|
$color = Color::NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$pairing->Color = new Color($color);
|
$pairing->Color = new Color($color);
|
||||||
|
|
||||||
$pairing->Board = $this->Tournament->Pairing[$ptn]['table'];
|
$pairing->Board = $this->Tournament->Pairing[ $ptn ][ 'table' ];
|
||||||
$ptn++;
|
$ptn++;
|
||||||
$this->Tournament->addPairing($pairing);
|
$this->Tournament->addPairing($pairing);
|
||||||
}
|
}
|
||||||
@ -525,7 +534,8 @@ class Swar4 implements ReaderInterface
|
|||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param $handle
|
* @param $handle
|
||||||
* @param null $default
|
* @param null $default
|
||||||
|
*
|
||||||
* @return array|bool|DateTime|false|float|int|string|null
|
* @return array|bool|DateTime|false|float|int|string|null
|
||||||
*/
|
*/
|
||||||
private function readData(string $type, $handle, $default = null)
|
private function readData(string $type, $handle, $default = null)
|
||||||
@ -542,11 +552,13 @@ class Swar4 implements ReaderInterface
|
|||||||
if ($data == '') {
|
if ($data == '') {
|
||||||
return (is_null($default)) ? '' : $default;
|
return (is_null($default)) ? '' : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iconv('windows-1252', 'utf-8', $data);
|
return iconv('windows-1252', 'utf-8', $data);
|
||||||
} elseif ($type == 'Date') {
|
} elseif ($type == 'Date') {
|
||||||
if ($data == '') {
|
if ($data == '') {
|
||||||
return (is_null($default)) ? $this->convertStringToDate('01/01/1900') : $default;
|
return (is_null($default)) ? $this->convertStringToDate('01/01/1900') : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->convertStringToDate($data);
|
return $this->convertStringToDate($data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -559,7 +571,7 @@ class Swar4 implements ReaderInterface
|
|||||||
|
|
||||||
foreach ($hex as $key => $item) {
|
foreach ($hex as $key => $item) {
|
||||||
if ($item == "00") {
|
if ($item == "00") {
|
||||||
$hex[$key] = "";
|
$hex[ $key ] = "";
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -571,19 +583,20 @@ class Swar4 implements ReaderInterface
|
|||||||
if ($hex == '00') {
|
if ($hex == '00') {
|
||||||
return (is_null($default)) ? '00' : $default;
|
return (is_null($default)) ? '00' : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hex;
|
return $hex;
|
||||||
} elseif ($type == 'Int') {
|
} elseif ($type == 'Int') {
|
||||||
if ($hex == '00') {
|
if ($hex == '00') {
|
||||||
return (is_null($default)) ? 0 : $default;
|
return (is_null($default)) ? 0 : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hexdec($hex);
|
return hexdec($hex);
|
||||||
} elseif ($type == 'Bool') {
|
} elseif ($type == 'Bool') {
|
||||||
return ($hex == "01") ? true : false;
|
return ($hex == "01");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException("Datatype not known");
|
throw new InvalidArgumentException("Datatype not known");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -593,30 +606,34 @@ class Swar4 implements ReaderInterface
|
|||||||
* Returns binary data that was read out the swar file but was not needed immediately
|
* Returns binary data that was read out the swar file but was not needed immediately
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
|
*
|
||||||
* @return bool|DateTime|int|string|null
|
* @return bool|DateTime|int|string|null
|
||||||
*/
|
*/
|
||||||
public function __get(string $key)
|
public function __get(string $key)
|
||||||
{
|
{
|
||||||
if (isset($this->BinaryData[$key])) {
|
if (isset($this->BinaryData[ $key ])) {
|
||||||
return $this->BinaryData[$key];
|
return $this->BinaryData[ $key ];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets binary data that is read out the swar file but is not needed immediately
|
* Sets binary data that is read out the swar file but is not needed immediately
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param bool|int|DateTime|string $value
|
* @param bool|int|DateTime|string $value
|
||||||
*/
|
*/
|
||||||
public function __set(string $key, $value): void
|
public function __set(string $key, $value): void
|
||||||
{
|
{
|
||||||
$this->BinaryData[$key] = $value;
|
$this->BinaryData[ $key ] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a swar-4 string to a \DateTime object
|
* Converts a swar-4 string to a \DateTime object
|
||||||
|
*
|
||||||
* @param string $string
|
* @param string $string
|
||||||
|
*
|
||||||
* @return DateTime
|
* @return DateTime
|
||||||
*/
|
*/
|
||||||
public function convertStringToDate(string $string): DateTime
|
public function convertStringToDate(string $string): DateTime
|
||||||
@ -625,6 +642,10 @@ class Swar4 implements ReaderInterface
|
|||||||
return DateTime::createFromFormat('d/m/Y', $string);
|
return DateTime::createFromFormat('d/m/Y', $string);
|
||||||
} elseif (strlen($string) == 8) {
|
} elseif (strlen($string) == 8) {
|
||||||
return DateTime::createFromFormat('Ymd', $string);
|
return DateTime::createFromFormat('Ymd', $string);
|
||||||
|
} else {
|
||||||
|
$default = new DateTime();
|
||||||
|
$default->setTimestamp(0);
|
||||||
|
return $default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,11 +655,11 @@ class Swar4 implements ReaderInterface
|
|||||||
private function addTiebreaks(): void
|
private function addTiebreaks(): void
|
||||||
{
|
{
|
||||||
switch ($this->Tournament->System) {
|
switch ($this->Tournament->System) {
|
||||||
case TournamentSystem::American:
|
case TournamentSystem::AMERICAN:
|
||||||
case TournamentSystem::Closed:
|
case TournamentSystem::CLOSED:
|
||||||
case TournamentSystem::Swiss:
|
case TournamentSystem::SWISS:
|
||||||
default:
|
default:
|
||||||
$firstElement = new Tiebreak(Tiebreak::Points);
|
$firstElement = new Tiebreak(Tiebreak::POINTS);
|
||||||
}
|
}
|
||||||
$tiebreaks = $this->Tournament->Tiebreaks;
|
$tiebreaks = $this->Tournament->Tiebreaks;
|
||||||
array_unshift($tiebreaks, $firstElement);
|
array_unshift($tiebreaks, $firstElement);
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Round
|
* Class Round
|
||||||
*
|
*
|
||||||
* Class for a round of the tournament
|
* Class for a round of the tournament
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo;
|
namespace JeroenED\Libpairtwo;
|
||||||
@ -20,10 +21,10 @@ use JeroenED\Libpairtwo\Enums\Result;
|
|||||||
*
|
*
|
||||||
* Class for a round of the tournament
|
* Class for a round of the tournament
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Round
|
class Round
|
||||||
{
|
{
|
||||||
@ -89,7 +90,7 @@ class Round
|
|||||||
$allPairings = $this->Pairings;
|
$allPairings = $this->Pairings;
|
||||||
$byePairings = [];
|
$byePairings = [];
|
||||||
foreach ($allPairings as $pairing) {
|
foreach ($allPairings as $pairing) {
|
||||||
if ($pairing->Result == Result::WonBye) {
|
if ($pairing->Result == Result::WON_BYE) {
|
||||||
$byePairings[] = $pairing;
|
$byePairings[] = $pairing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +107,7 @@ class Round
|
|||||||
$allPairings = $this->Pairings;
|
$allPairings = $this->Pairings;
|
||||||
$absentPairings = [];
|
$absentPairings = [];
|
||||||
foreach ($allPairings as $pairing) {
|
foreach ($allPairings as $pairing) {
|
||||||
if ($pairing->Result == Result::Absent) {
|
if ($pairing->Result == Result::ABSENT) {
|
||||||
$absentPairings[] = $pairing;
|
$absentPairings[] = $pairing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,8 +129,8 @@ class Round
|
|||||||
/**
|
/**
|
||||||
* Sort by board
|
* Sort by board
|
||||||
*
|
*
|
||||||
* @param Game $a
|
* @param Game $a
|
||||||
* @param Game $b
|
* @param Game $b
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function sortByBoard(Game $a, Game $b): int
|
private function sortByBoard(Game $a, Game $b): int
|
||||||
@ -143,7 +144,7 @@ class Round
|
|||||||
/**
|
/**
|
||||||
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
|
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return bool|DateTime|int|string|null
|
* @return bool|DateTime|int|string|null
|
||||||
*/
|
*/
|
||||||
public function __get(string $key)
|
public function __get(string $key)
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The file contains the Tournament class which takes care of almost every element in your tournament
|
* The file contains the Tournament class which takes care of almost every element in your tournament
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JeroenED\Libpairtwo;
|
namespace JeroenED\Libpairtwo;
|
||||||
@ -21,10 +22,10 @@ use DateTime;
|
|||||||
*
|
*
|
||||||
* Class for the tournament from the pairing file
|
* Class for the tournament from the pairing file
|
||||||
*
|
*
|
||||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
* @category Main
|
* @category Main
|
||||||
* @package Libpairtwo
|
* @package Libpairtwo
|
||||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||||
*/
|
*/
|
||||||
class Tournament
|
class Tournament
|
||||||
{
|
{
|
||||||
@ -38,7 +39,6 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Organiser of the tournament (eg. Donald J. Trump)
|
* Organiser of the tournament (eg. Donald J. Trump)
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Organiser;
|
public $Organiser;
|
||||||
@ -80,6 +80,7 @@ class Tournament
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Start date (First round or Players meeting) of the tournament
|
* Start date (First round or Players meeting) of the tournament
|
||||||
|
*
|
||||||
* @var DateTime
|
* @var DateTime
|
||||||
*/
|
*/
|
||||||
public $StartDate;
|
public $StartDate;
|
||||||
@ -114,6 +115,7 @@ class Tournament
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The tempo of the tournament (eg. 90 min/40 moves + 30 sec. increment starting from move 1)
|
* The tempo of the tournament (eg. 90 min/40 moves + 30 sec. increment starting from move 1)
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Tempo;
|
public $Tempo;
|
||||||
@ -205,10 +207,10 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Gets a player by its ID
|
* Gets a player by its ID
|
||||||
*
|
*
|
||||||
* @param integer $id
|
* @param int $id
|
||||||
* @return Player
|
* @return Player
|
||||||
*/
|
*/
|
||||||
public function PlayerById(int $id): Player
|
public function playerById(int $id): Player
|
||||||
{
|
{
|
||||||
return $this->Players[$id];
|
return $this->Players[$id];
|
||||||
}
|
}
|
||||||
@ -217,7 +219,6 @@ class Tournament
|
|||||||
* Adds a player
|
* Adds a player
|
||||||
*
|
*
|
||||||
* @param Player $Player
|
* @param Player $Player
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function addPlayer(Player $Player): void
|
public function addPlayer(Player $Player): void
|
||||||
{
|
{
|
||||||
@ -229,9 +230,8 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Updates player on id to the given Player object
|
* Updates player on id to the given Player object
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function updatePlayer(int $id, Player $player): void
|
public function updatePlayer(int $id, Player $player): void
|
||||||
{
|
{
|
||||||
@ -244,7 +244,6 @@ class Tournament
|
|||||||
* Adds a Tiebreak
|
* Adds a Tiebreak
|
||||||
*
|
*
|
||||||
* @param Tiebreak $tiebreak
|
* @param Tiebreak $tiebreak
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function addTiebreak(Tiebreak $tiebreak): void
|
public function addTiebreak(Tiebreak $tiebreak): void
|
||||||
{
|
{
|
||||||
@ -257,7 +256,6 @@ class Tournament
|
|||||||
* Adds a round with given Round object
|
* Adds a round with given Round object
|
||||||
*
|
*
|
||||||
* @param Round $round
|
* @param Round $round
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function addRound(Round $round): void
|
public function addRound(Round $round): void
|
||||||
{
|
{
|
||||||
@ -269,10 +267,10 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Gets a round by its number.
|
* Gets a round by its number.
|
||||||
*
|
*
|
||||||
* @param int $roundNo
|
* @param int $roundNo
|
||||||
* @return Round
|
* @return Round
|
||||||
*/
|
*/
|
||||||
public function RoundByNo(int $roundNo): Round
|
public function roundByNo(int $roundNo): Round
|
||||||
{
|
{
|
||||||
return $this->Rounds[$roundNo];
|
return $this->Rounds[$roundNo];
|
||||||
}
|
}
|
||||||
@ -281,7 +279,6 @@ class Tournament
|
|||||||
* Adds a pairing to the tournament
|
* Adds a pairing to the tournament
|
||||||
*
|
*
|
||||||
* @param Pairing $pairing
|
* @param Pairing $pairing
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function addPairing(Pairing $pairing): void
|
public function addPairing(Pairing $pairing): void
|
||||||
{
|
{
|
||||||
@ -295,7 +292,6 @@ class Tournament
|
|||||||
* Adds an arbiter to the tournament
|
* Adds an arbiter to the tournament
|
||||||
*
|
*
|
||||||
* @param string $Arbiter
|
* @param string $Arbiter
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function addArbiter(string $Arbiter): void
|
public function addArbiter(string $Arbiter): void
|
||||||
{
|
{
|
||||||
@ -306,35 +302,30 @@ class Tournament
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts pairings into games with a black and white player
|
* Converts pairings into games with a black and white player
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function pairingsToRounds(): void
|
public function pairingsToRounds(): void
|
||||||
{
|
{
|
||||||
/** @var Pairing[] $pairings */
|
|
||||||
$pairings = $this->Pairings;
|
$pairings = $this->Pairings;
|
||||||
|
|
||||||
/** @var Pairing[] */
|
/**
|
||||||
|
* @var Pairing[]
|
||||||
|
*/
|
||||||
$cache = array();
|
$cache = array();
|
||||||
|
|
||||||
/** @var int[] */
|
|
||||||
$lastboards;
|
|
||||||
|
|
||||||
/** @var Pairing $pairing */
|
|
||||||
foreach ($pairings as $pairing) {
|
foreach ($pairings as $pairing) {
|
||||||
// Add pairing to player
|
// Add pairing to player
|
||||||
$pairing->Player->addPairing($pairing);
|
$pairing->Player->addPairing($pairing);
|
||||||
$round = $pairing->Round;
|
$round = $pairing->Round;
|
||||||
$color = $pairing->Color;
|
$color = $pairing->Color;
|
||||||
|
|
||||||
$this->RoundByNo($round)->addPairing($pairing);
|
$this->roundByNo($round)->addPairing($pairing);
|
||||||
$opponent = null;
|
$opponent = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int $key
|
* @var int $key
|
||||||
* @var Pairing $cached
|
* @var Pairing $cached
|
||||||
*/
|
*/
|
||||||
foreach ($cache as $key=>$cached) {
|
foreach ($cache as $key => $cached) {
|
||||||
if (!is_null($cached)) {
|
if (!is_null($cached)) {
|
||||||
if (($cached->Opponent == $pairing->Player) && ($cached->Round == $pairing->Round)) {
|
if (($cached->Opponent == $pairing->Player) && ($cached->Round == $pairing->Round)) {
|
||||||
$opponent = $cached;
|
$opponent = $cached;
|
||||||
@ -344,33 +335,30 @@ class Tournament
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$game = new Game();
|
$game = new Game();
|
||||||
if ($color->getValue() == Color::White) {
|
if ($color->getValue() == Color::WHITE) {
|
||||||
$game->White = $pairing;
|
$game->White = $pairing;
|
||||||
$game->Black = $opponent;
|
$game->Black = $opponent;
|
||||||
} elseif ($color->getValue() == Color::Black) {
|
} elseif ($color->getValue() == Color::BLACK) {
|
||||||
$game->White = $opponent;
|
$game->White = $opponent;
|
||||||
$game->Black = $pairing;
|
$game->Black = $pairing;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($game->White) || is_null($game->Black)) {
|
if (is_null($game->White) || is_null($game->Black)) {
|
||||||
$cache[] = $pairing;
|
$cache[] = $pairing;
|
||||||
} else {
|
} elseif (!$this->gameExists($game, $round)) { // Check if game already exists
|
||||||
// Check if game already exists
|
$game->Board = $game->White->Board;
|
||||||
if (!$this->gameExists($game, $round)) {
|
// Add board if inexistent
|
||||||
$game->Board = $game->White->Board;
|
if ($game->Board == -1) {
|
||||||
// Add board if inexistent
|
if (isset($lastboards[$round])) {
|
||||||
if ($game->Board == -1) {
|
$lastboards[$round] += 1;
|
||||||
if (isset($lastboards[$round])) {
|
} else {
|
||||||
$lastboards[$round] += 1;
|
$lastboards[$round] = 0;
|
||||||
} else {
|
|
||||||
$lastboards[$round] = 0;
|
|
||||||
}
|
|
||||||
$game->Board = $lastboards[$round];
|
|
||||||
$game->White->Board = $lastboards[$round];
|
|
||||||
$game->Black->Board = $lastboards[$round];
|
|
||||||
}
|
}
|
||||||
$this->AddGame($game, $round);
|
$game->Board = $lastboards[$round];
|
||||||
|
$game->White->Board = $lastboards[$round];
|
||||||
|
$game->Black->Board = $lastboards[$round];
|
||||||
}
|
}
|
||||||
|
$this->AddGame($game, $round);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,8 +366,8 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Checks if a game already is already registered
|
* Checks if a game already is already registered
|
||||||
*
|
*
|
||||||
* @param Game $game
|
* @param Game $game
|
||||||
* @param int $round
|
* @param int $round
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function gameExists(Game $game, int $round = -1): bool
|
public function gameExists(Game $game, int $round = -1): bool
|
||||||
@ -414,8 +402,7 @@ class Tournament
|
|||||||
* Adds a game to the tournament
|
* Adds a game to the tournament
|
||||||
*
|
*
|
||||||
* @param Game $game
|
* @param Game $game
|
||||||
* @param int $round
|
* @param int $round
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function addGame(Game $game, int $round): void
|
public function addGame(Game $game, int $round): void
|
||||||
{
|
{
|
||||||
@ -425,7 +412,7 @@ class Tournament
|
|||||||
$this->addRound($roundObj);
|
$this->addRound($roundObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->RoundByNo($round)->addGame($game);
|
$this->roundByNo($round)->addGame($game);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -436,7 +423,7 @@ class Tournament
|
|||||||
private function ranking(): array
|
private function ranking(): array
|
||||||
{
|
{
|
||||||
$players = $this->Players;
|
$players = $this->Players;
|
||||||
foreach ($this->Tiebreaks as $tbkey=>$tiebreak) {
|
foreach ($this->Tiebreaks as $tbkey => $tiebreak) {
|
||||||
foreach ($players as $pkey => $player) {
|
foreach ($players as $pkey => $player) {
|
||||||
$break = $this->calculateTiebreak($tiebreak, $player, $tbkey);
|
$break = $this->calculateTiebreak($tiebreak, $player, $tbkey);
|
||||||
$tiebreaks = $player->Tiebreaks;
|
$tiebreaks = $player->Tiebreaks;
|
||||||
@ -446,11 +433,11 @@ class Tournament
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sortedplayers[0] = $players;
|
$sortedplayers[0] = $players;
|
||||||
foreach ($this->Tiebreaks as $tbkey=>$tiebreak) {
|
foreach ($this->Tiebreaks as $tbkey => $tiebreak) {
|
||||||
$newgroupkey = 0;
|
$newgroupkey = 0;
|
||||||
$tosortplayers = $sortedplayers;
|
$tosortplayers = $sortedplayers;
|
||||||
$sortedplayers = [];
|
$sortedplayers = [];
|
||||||
foreach ($tosortplayers as $groupkey=>$sortedplayerselem) {
|
foreach ($tosortplayers as $groupkey => $sortedplayerselem) {
|
||||||
usort($tosortplayers[$groupkey], $this->sortTiebreak($tbkey));
|
usort($tosortplayers[$groupkey], $this->sortTiebreak($tbkey));
|
||||||
foreach ($tosortplayers[$groupkey] as $playerkey => $player) {
|
foreach ($tosortplayers[$groupkey] as $playerkey => $player) {
|
||||||
if (!is_null($player->Tiebreaks[$tbkey])) {
|
if (!is_null($player->Tiebreaks[$tbkey])) {
|
||||||
@ -478,7 +465,7 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Sort by tiebreak
|
* Sort by tiebreak
|
||||||
*
|
*
|
||||||
* @param int $key
|
* @param int $key
|
||||||
* @return Closure
|
* @return Closure
|
||||||
*/
|
*/
|
||||||
private function sortTiebreak(int $key): Closure
|
private function sortTiebreak(int $key): Closure
|
||||||
@ -495,74 +482,54 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Calculates a specific tiebreak for $player
|
* Calculates a specific tiebreak for $player
|
||||||
*
|
*
|
||||||
* @param Tiebreak $tiebreak
|
* @param Tiebreak $tiebreak
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param int $tbkey
|
* @param int $tbkey
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateTiebreak(Tiebreak $tiebreak, Player $player, int $tbkey = 0): float
|
private function calculateTiebreak(Tiebreak $tiebreak, Player $player, int $tbkey = 0): float
|
||||||
{
|
{
|
||||||
switch ($tiebreak) {
|
switch ($tiebreak) {
|
||||||
case Tiebreak::Keizer:
|
case Tiebreak::KEIZER:
|
||||||
return $this->calculateKeizer($player);
|
return $this->calculateKeizer($player);
|
||||||
break;
|
case Tiebreak::POINTS:
|
||||||
case Tiebreak::Points:
|
|
||||||
return $this->calculatePoints($player);
|
return $this->calculatePoints($player);
|
||||||
break;
|
case Tiebreak::BAUMBACH:
|
||||||
case Tiebreak::Baumbach:
|
|
||||||
return $this->calculateBaumbach($player);
|
return $this->calculateBaumbach($player);
|
||||||
break;
|
case Tiebreak::BLACK_PLAYED:
|
||||||
case Tiebreak::BlackPlayed:
|
|
||||||
return $this->calculateBlackPlayed($player);
|
return $this->calculateBlackPlayed($player);
|
||||||
break;
|
case Tiebreak::BLACK_WIN:
|
||||||
case Tiebreak::BlackWin:
|
|
||||||
return $this->calculateBlackWin($player);
|
return $this->calculateBlackWin($player);
|
||||||
break;
|
case Tiebreak::BETWEEN:
|
||||||
case Tiebreak::Between:
|
|
||||||
return $this->calculateMutualResult($player, $this->Players, $tbkey);
|
return $this->calculateMutualResult($player, $this->Players, $tbkey);
|
||||||
break;
|
case Tiebreak::ARO:
|
||||||
case Tiebreak::Aro:
|
|
||||||
return $this->calculateAverageRating($player, $this->PriorityElo);
|
return $this->calculateAverageRating($player, $this->PriorityElo);
|
||||||
break;
|
case Tiebreak::AROCUT:
|
||||||
case Tiebreak::AroCut:
|
|
||||||
return $this->calculateAverageRating($player, $this->PriorityElo, 1);
|
return $this->calculateAverageRating($player, $this->PriorityElo, 1);
|
||||||
break;
|
case Tiebreak::KOYA:
|
||||||
case Tiebreak::Koya:
|
|
||||||
return $this->calculateKoya($player);
|
return $this->calculateKoya($player);
|
||||||
break;
|
case Tiebreak::BUCHHOLZ:
|
||||||
case Tiebreak::Buchholz:
|
|
||||||
return $this->calculateBuchholz($player);
|
return $this->calculateBuchholz($player);
|
||||||
break;
|
case Tiebreak::BUCHHOLZ_CUT:
|
||||||
case Tiebreak::BuchholzCut:
|
|
||||||
return $this->calculateBuchholz($player, 1);
|
return $this->calculateBuchholz($player, 1);
|
||||||
break;
|
case Tiebreak::BUCHHOLZ_MED:
|
||||||
case Tiebreak::BuchholzMed:
|
|
||||||
return $this->calculateBuchholz($player, 1, 1);
|
return $this->calculateBuchholz($player, 1, 1);
|
||||||
break;
|
case Tiebreak::BUCHHOLZ_CUT_2:
|
||||||
case Tiebreak::BuchholzCut2:
|
|
||||||
return $this->calculateBuchholz($player, 2);
|
return $this->calculateBuchholz($player, 2);
|
||||||
break;
|
case Tiebreak::BUCHHOLZ_MED_2:
|
||||||
case Tiebreak::BuchholzMed2:
|
|
||||||
return $this->calculateBuchholz($player, 2, 2);
|
return $this->calculateBuchholz($player, 2, 2);
|
||||||
break;
|
case Tiebreak::SONNEBORN:
|
||||||
case Tiebreak::Sonneborn:
|
|
||||||
return $this->calculateSonneborn($player);
|
return $this->calculateSonneborn($player);
|
||||||
break;
|
case Tiebreak::KASHDAN:
|
||||||
case Tiebreak::Kashdan:
|
|
||||||
return $this->calculateKashdan($player, ["Won" => 4, "Draw" => 2, "Lost" => 1, "NotPlayed" => 0]);
|
return $this->calculateKashdan($player, ["Won" => 4, "Draw" => 2, "Lost" => 1, "NotPlayed" => 0]);
|
||||||
break;
|
case Tiebreak::SOCCER_KASHDAN:
|
||||||
case Tiebreak::SoccerKashdan:
|
|
||||||
return $this->calculateKashdan($player, ["Won" => 3, "Draw" => 1, "Lost" => 0, "NotPlayed" => -1]);
|
return $this->calculateKashdan($player, ["Won" => 3, "Draw" => 1, "Lost" => 0, "NotPlayed" => -1]);
|
||||||
break;
|
case Tiebreak::CUMULATIVE:
|
||||||
case Tiebreak::Cumulative:
|
|
||||||
return $this->calculateCumulative($player);
|
return $this->calculateCumulative($player);
|
||||||
break;
|
case Tiebreak::AVERAGE_PERFORMANCE:
|
||||||
case Tiebreak::AveragePerformance:
|
|
||||||
return $this->calculateAveragePerformance($player, $this->PriorityElo);
|
return $this->calculateAveragePerformance($player, $this->PriorityElo);
|
||||||
break;
|
case Tiebreak::PERFORMANCE:
|
||||||
case Tiebreak::Performance:
|
|
||||||
return $player->Performance($this->PriorityElo, $this->NonRatedElo);
|
return $player->Performance($this->PriorityElo, $this->NonRatedElo);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -602,7 +569,7 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Points following keizer system
|
* Points following keizer system
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateKeizer(Player $player): float
|
private function calculateKeizer(Player $player): float
|
||||||
@ -613,7 +580,7 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Number of points
|
* Number of points
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculatePoints(Player $player): float
|
private function calculatePoints(Player $player): float
|
||||||
@ -625,15 +592,15 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Number of won games
|
* Number of won games
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateBaumbach(Player $player): float
|
private function calculateBaumbach(Player $player): float
|
||||||
{
|
{
|
||||||
$totalwins = 0;
|
$totalwins = 0;
|
||||||
foreach ($player->Pairings as $pairing) {
|
foreach ($player->Pairings as $pairing) {
|
||||||
if (array_search($pairing->Result, Constants::NotPlayed) === false) {
|
if (array_search($pairing->Result, Constants::NOTPLAYED) === false) {
|
||||||
if (array_search($pairing->Result, Constants::Won) !== false) {
|
if (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$totalwins++;
|
$totalwins++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -645,14 +612,14 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Number of played games with black
|
* Number of played games with black
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateBlackPlayed(Player $player): float
|
private function calculateBlackPlayed(Player $player): float
|
||||||
{
|
{
|
||||||
$totalwins = 0;
|
$totalwins = 0;
|
||||||
foreach ($player->Pairings as $pairing) {
|
foreach ($player->Pairings as $pairing) {
|
||||||
if (array_search($pairing->Color, Constants::Black) !== false) {
|
if (array_search($pairing->Color, Constants::BLACK) !== false) {
|
||||||
$totalwins++;
|
$totalwins++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -662,14 +629,14 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Number of won games with black
|
* Number of won games with black
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateBlackWin(Player $player): float
|
private function calculateBlackWin(Player $player): float
|
||||||
{
|
{
|
||||||
$totalwins = 0;
|
$totalwins = 0;
|
||||||
foreach ($player->Pairings as $pairing) {
|
foreach ($player->Pairings as $pairing) {
|
||||||
if (array_search($pairing->Color, Constants::Black) !== false && array_search($pairing->Result, Constants::Won) !== false) {
|
if (array_search($pairing->Color, Constants::BLACK) !== false && array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$totalwins++;
|
$totalwins++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -680,9 +647,9 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Result between the tied players
|
* Result between the tied players
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param array $opponents
|
* @param array $opponents
|
||||||
* @param int $key
|
* @param int $key
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateMutualResult(Player $player, array $opponents, int $key): float
|
private function calculateMutualResult(Player $player, array $opponents, int $key): float
|
||||||
@ -713,9 +680,9 @@ class Tournament
|
|||||||
$totalmatches = 0;
|
$totalmatches = 0;
|
||||||
foreach ($player->Pairings as $pairing) {
|
foreach ($player->Pairings as $pairing) {
|
||||||
if (array_search($pairing->Opponent, $interestingplayers) !== false) {
|
if (array_search($pairing->Opponent, $interestingplayers) !== false) {
|
||||||
if (array_search($pairing->Result, Constants::Won) !== false) {
|
if (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$points = $points + 1;
|
$points = $points + 1;
|
||||||
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
|
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||||
$points = $points + 0.5;
|
$points = $points + 0.5;
|
||||||
}
|
}
|
||||||
$totalmatches++;
|
$totalmatches++;
|
||||||
@ -731,9 +698,9 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* The average rating of the opponents
|
* The average rating of the opponents
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param int $cut
|
* @param int $cut
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateAverageRating(Player $player, string $type, int $cut = 0): float
|
private function calculateAverageRating(Player $player, string $type, int $cut = 0): float
|
||||||
@ -741,7 +708,7 @@ class Tournament
|
|||||||
$pairings = $player->Pairings;
|
$pairings = $player->Pairings;
|
||||||
$allratings = [];
|
$allratings = [];
|
||||||
foreach ($pairings as $pairing) {
|
foreach ($pairings as $pairing) {
|
||||||
if (array_search($pairing->Result, Constants::NotPlayed) === false) {
|
if (array_search($pairing->Result, Constants::NOTPLAYED) === false) {
|
||||||
$toadd = $pairing->Opponent->getElo($type);
|
$toadd = $pairing->Opponent->getElo($type);
|
||||||
if ($toadd != 0) {
|
if ($toadd != 0) {
|
||||||
$allratings[] = $toadd;
|
$allratings[] = $toadd;
|
||||||
@ -761,9 +728,9 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* The average performance of the opponents
|
* The average performance of the opponents
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param int $cut
|
* @param int $cut
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateAveragePerformance(Player $player, string $type, int $cut = 0): float
|
private function calculateAveragePerformance(Player $player, string $type, int $cut = 0): float
|
||||||
@ -771,7 +738,7 @@ class Tournament
|
|||||||
$pairings = $player->Pairings;
|
$pairings = $player->Pairings;
|
||||||
$allratings = [];
|
$allratings = [];
|
||||||
foreach ($pairings as $pairing) {
|
foreach ($pairings as $pairing) {
|
||||||
if (array_search($pairing->Result, Constants::NotPlayed) === false) {
|
if (array_search($pairing->Result, Constants::NOTPLAYED) === false) {
|
||||||
$toadd = $pairing->Opponent->Performance($type, $this->NonRatedElo);
|
$toadd = $pairing->Opponent->Performance($type, $this->NonRatedElo);
|
||||||
if ($toadd != 0) {
|
if ($toadd != 0) {
|
||||||
$allratings[] = $toadd;
|
$allratings[] = $toadd;
|
||||||
@ -787,8 +754,8 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Points against players who have more than $cut % points
|
* Points against players who have more than $cut % points
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param int $cut
|
* @param int $cut
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateKoya(Player $player, int $cut = 50): float
|
private function calculateKoya(Player $player, int $cut = 50): float
|
||||||
@ -796,9 +763,9 @@ class Tournament
|
|||||||
$tiebreak = 0;
|
$tiebreak = 0;
|
||||||
foreach ($player->Pairings as $plkey => $plpairing) {
|
foreach ($player->Pairings as $plkey => $plpairing) {
|
||||||
if (($plpairing->Opponent->calculatePoints() / count($plpairing->Opponent->Pairings) * 100) >= $cut) {
|
if (($plpairing->Opponent->calculatePoints() / count($plpairing->Opponent->Pairings) * 100) >= $cut) {
|
||||||
if (array_search($plpairing->Result, Constants::Won) !== false) {
|
if (array_search($plpairing->Result, Constants::WON) !== false) {
|
||||||
$tiebreak += 1;
|
$tiebreak += 1;
|
||||||
} elseif (array_search($plpairing->Result, Constants::Draw) !== false) {
|
} elseif (array_search($plpairing->Result, Constants::DRAW) !== false) {
|
||||||
$tiebreak += 0.5;
|
$tiebreak += 0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -809,9 +776,10 @@ class Tournament
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The combined points of the opponents
|
* The combined points of the opponents
|
||||||
* @param Player $player
|
*
|
||||||
* @param int $cutlowest
|
* @param Player $player
|
||||||
* @param int $cuthighest
|
* @param int $cutlowest
|
||||||
|
* @param int $cuthighest
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateBuchholz(Player $player, int $cutlowest = 0, int $cuthighest = 0): float
|
private function calculateBuchholz(Player $player, int $cutlowest = 0, int $cuthighest = 0): float
|
||||||
@ -822,27 +790,30 @@ class Tournament
|
|||||||
$intpairings = [];
|
$intpairings = [];
|
||||||
$curpoints = 0;
|
$curpoints = 0;
|
||||||
$curround = 1;
|
$curround = 1;
|
||||||
foreach ($intpairingsWithBye as $key=>$pairing) {
|
foreach ($intpairingsWithBye as $key => $pairing) {
|
||||||
$roundstoplay = (count($intpairingsWithBye)) - $curround;
|
$roundstoplay = (count($intpairingsWithBye)) - $curround;
|
||||||
if (is_null($pairing->Opponent)) {
|
if (is_null($pairing->Opponent)) {
|
||||||
$intpairings[] = $player->calculatePointsForVirtualPlayer($key);
|
$intpairings[] = $player->calculatePointsForVirtualPlayer($key);
|
||||||
} else {
|
} else {
|
||||||
$intpairings[] = $pairing->Opponent->calculatePointsForTiebreaks();
|
$intpairings[] = $pairing->Opponent->calculatePointsForTiebreaks();
|
||||||
if (array_search($pairing->Result, Constants::Won) !== false) {
|
if (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$curpoints += 1;
|
$curpoints += 1;
|
||||||
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
|
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||||
$curpoints += 0.5;
|
$curpoints += 0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$curround++;
|
$curround++;
|
||||||
}
|
}
|
||||||
|
|
||||||
usort($intpairings, function ($a, $b) {
|
usort(
|
||||||
if ($b == $a) {
|
$intpairings,
|
||||||
return 0;
|
function ($a, $b) {
|
||||||
|
if ($b == $a) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ($a > $b) ? 1 : -1;
|
||||||
}
|
}
|
||||||
return ($a > $b) ? 1 : -1;
|
);
|
||||||
});
|
|
||||||
|
|
||||||
$intpairings = array_slice($intpairings, $cutlowest);
|
$intpairings = array_slice($intpairings, $cutlowest);
|
||||||
$intpairings = array_slice($intpairings, 0 - $cuthighest);
|
$intpairings = array_slice($intpairings, 0 - $cuthighest);
|
||||||
@ -854,7 +825,7 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* The points of $player's opponents who $player won against, plus half of the points of $player's opponents who $player drew against
|
* The points of $player's opponents who $player won against, plus half of the points of $player's opponents who $player drew against
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateSonneborn(Player $player): float
|
private function calculateSonneborn(Player $player): float
|
||||||
@ -862,13 +833,13 @@ class Tournament
|
|||||||
$tiebreak = 0;
|
$tiebreak = 0;
|
||||||
foreach ($player->Pairings as $key => $pairing) {
|
foreach ($player->Pairings as $key => $pairing) {
|
||||||
if ($pairing->Opponent) {
|
if ($pairing->Opponent) {
|
||||||
if (array_search($pairing->Result, Constants::Won) !== false) {
|
if (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$tiebreak += $pairing->Opponent->calculatePointsForTiebreaks();
|
$tiebreak += $pairing->Opponent->calculatePointsForTiebreaks();
|
||||||
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
|
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||||
$tiebreak += $pairing->Opponent->calculatePointsForTiebreaks() / 2;
|
$tiebreak += $pairing->Opponent->calculatePointsForTiebreaks() / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (array_search($pairing->Result, Constants::NotPlayed) !== false) {
|
if (array_search($pairing->Result, Constants::NOTPLAYED) !== false) {
|
||||||
$tiebreak += $player->calculatePointsForVirtualPlayer($key);
|
$tiebreak += $player->calculatePointsForVirtualPlayer($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -879,8 +850,8 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* $points["Won"] points for each win, $points["Draw"] for each draw and $points["Lost"] point for losing. $points["NotPlayed"] points for not played games
|
* $points["Won"] points for each win, $points["Draw"] for each draw and $points["Lost"] point for losing. $points["NotPlayed"] points for not played games
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param int[] $points
|
* @param int[] $points
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateKashdan(Player $player, array $points): float
|
private function calculateKashdan(Player $player, array $points): float
|
||||||
@ -888,15 +859,15 @@ class Tournament
|
|||||||
$tiebreak = 0;
|
$tiebreak = 0;
|
||||||
foreach ($player->Pairings as $pairing) {
|
foreach ($player->Pairings as $pairing) {
|
||||||
$toadd = 0;
|
$toadd = 0;
|
||||||
if (array_search($pairing->Result, Constants::Won) !== false) {
|
if (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$toadd = $points["Won"];
|
$toadd = $points["Won"];
|
||||||
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
|
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||||
$toadd = $points["Draw"];
|
$toadd = $points["Draw"];
|
||||||
} elseif (array_search($pairing->Result, Constants::Lost) !== false) {
|
} elseif (array_search($pairing->Result, Constants::LOST) !== false) {
|
||||||
$toadd = $points["Lost"];
|
$toadd = $points["Lost"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search($pairing->Result, Constants::NotPlayed) !== false) {
|
if (array_search($pairing->Result, Constants::NOTPLAYED) !== false) {
|
||||||
$toadd = $points["NotPlayed"];
|
$toadd = $points["NotPlayed"];
|
||||||
}
|
}
|
||||||
$tiebreak += $toadd;
|
$tiebreak += $toadd;
|
||||||
@ -907,7 +878,7 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Combined score of $player after each round
|
* Combined score of $player after each round
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function calculateCumulative(Player $player): float
|
private function calculateCumulative(Player $player): float
|
||||||
@ -916,9 +887,9 @@ class Tournament
|
|||||||
$score = [];
|
$score = [];
|
||||||
foreach ($player->Pairings as $pairing) {
|
foreach ($player->Pairings as $pairing) {
|
||||||
$toadd = 0;
|
$toadd = 0;
|
||||||
if (array_search($pairing->Result, Constants::Won) !== false) {
|
if (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$toadd = 1;
|
$toadd = 1;
|
||||||
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
|
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||||
$toadd = 0.5;
|
$toadd = 0.5;
|
||||||
}
|
}
|
||||||
$tiebreak += $toadd;
|
$tiebreak += $toadd;
|
||||||
@ -930,7 +901,7 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
|
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return bool|DateTime|int|string|null
|
* @return bool|DateTime|int|string|null
|
||||||
*/
|
*/
|
||||||
public function __get(string $key)
|
public function __get(string $key)
|
||||||
@ -950,8 +921,8 @@ class Tournament
|
|||||||
/**
|
/**
|
||||||
* Sets binary data that is read out the pairing file but is not needed immediately
|
* Sets binary data that is read out the pairing file but is not needed immediately
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param bool|int|DateTime|string $value
|
* @param bool|int|DateTime|string $value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __set(string $key, $value): void
|
public function __set(string $key, $value): void
|
||||||
|
Loading…
Reference in New Issue
Block a user