mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-22 06:26:57 +01:00
Merge branch 'task/phpdoc' into develop
This commit is contained in:
commit
358dfc8a92
@ -3,8 +3,10 @@
|
||||
## vx.x.x (Released: xx-xxx-xx)
|
||||
* NEW FEATURE: Libpairtwo distribution releases (use these if you don't have knowledge of composer or dependency management)
|
||||
* NEW FEATURE: Soccer Kashdan (aka: kashdan using 3-1-0 scoring)
|
||||
* MAJOR CHANGE: Model Classes has been removed
|
||||
* CHANGE: Deprecated `sws::class` was removed
|
||||
* CHANGE: Added a logo to the project
|
||||
* CHANGE: Replaced PhpDoc with Doxygen
|
||||
* BUGFIX: `Tournament::getParticipants()` did not return a correct value
|
||||
|
||||
## v1.0.2 (Released: 05-jun-2019)
|
||||
|
10
Makefile
10
Makefile
@ -14,10 +14,7 @@ view-coverage: ## Shows the code coverage report
|
||||
open build/coverage/index.html
|
||||
|
||||
api: ## Generates api-docs
|
||||
mkdir -p vendor/bin/
|
||||
wget -O vendor/bin/phpdoc http://www.phpdoc.org/phpDocumentor.phar
|
||||
chmod +x vendor/bin/phpdoc
|
||||
vendor/bin/phpdoc
|
||||
doxygen
|
||||
|
||||
dist: ## Generates distribution
|
||||
touch .libpairtwo-dist
|
||||
@ -29,10 +26,7 @@ dist: ## Generates distribution
|
||||
rm dist/composer.json
|
||||
rm dist/composer.lock
|
||||
mv dist/composer-dist-installed.json dist/composer.json
|
||||
mkdir -p vendor/bin/
|
||||
wget -O vendor/bin/phpdoc http://www.phpdoc.org/phpDocumentor.phar
|
||||
chmod +x vendor/bin/phpdoc
|
||||
vendor/bin/phpdoc
|
||||
doxygen
|
||||
mkdir -p dist/doc
|
||||
cp -r doc/api dist/doc
|
||||
cd dist && zip -r ../libpairtwo-dist *
|
||||
|
4
dist/boilerplate.php
vendored
4
dist/boilerplate.php
vendored
@ -10,8 +10,8 @@ require_once 'vendor/autoload.php';
|
||||
$pairingfile = 'your pairing-file.sws';
|
||||
|
||||
|
||||
if(!file_exists($pairingfile)) {
|
||||
trigger_error('Your file is not set or doesn\'t exist! Edit the file: ' . __FILE__ . ' and try again', E_USER_ERROR);
|
||||
if (!file_exists($pairingfile)) {
|
||||
trigger_error('Your file is not set or doesn\'t exist! Edit the file: ' . __FILE__ . ' and try again', E_USER_ERROR);
|
||||
}
|
||||
|
||||
$reader = IOFactory::createReader('Pairtwo-6');
|
||||
|
12
phpdoc.xml
12
phpdoc.xml
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<phpdoc>
|
||||
<parser>
|
||||
<target>doc/api</target>
|
||||
</parser>
|
||||
<transformer>
|
||||
<target>doc/api</target>
|
||||
</transformer>
|
||||
<files>
|
||||
<directory>src/</directory>
|
||||
</files>
|
||||
</phpdoc>
|
BIN
res/logo-darkback-96px.png
Normal file
BIN
res/logo-darkback-96px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
BIN
res/logo-lightback-96px.png
Normal file
BIN
res/logo-lightback-96px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
@ -1,11 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class Constants
|
||||
*
|
||||
* Static class for constants
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Color;
|
||||
use JeroenED\Libpairtwo\Enums\Result;
|
||||
|
||||
/**
|
||||
* Class Constants
|
||||
*
|
||||
* Static class for constants
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Constants
|
||||
{
|
||||
const Won = [ Result::won, Result::wonforfait, Result::wonbye, Result::wonadjourned ];
|
||||
|
@ -1,15 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 11/02/19
|
||||
* Time: 14:51
|
||||
* Enum Color
|
||||
*
|
||||
* List of all compatible colors
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Enums;
|
||||
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
/**
|
||||
* Enum Color
|
||||
*
|
||||
* List of all compatible colors
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Color extends Enum
|
||||
{
|
||||
const black = 'B';
|
||||
|
@ -1,15 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 11/02/19
|
||||
* Time: 21:28
|
||||
* Enum Gameresult
|
||||
*
|
||||
* List of all compatible gameresults
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Enums;
|
||||
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
/**
|
||||
* Enum Gameresult
|
||||
*
|
||||
* List of all compatible gameresults
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Gameresult extends Enum
|
||||
{
|
||||
const None = '-';
|
||||
|
@ -1,15 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 25/01/19
|
||||
* Time: 15:56
|
||||
* Enum Gender
|
||||
*
|
||||
* List of all compatible genders
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Enums;
|
||||
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
|
||||
/**
|
||||
* Enum Gender
|
||||
*
|
||||
* List of all compatible genders
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Gender extends Enum
|
||||
{
|
||||
const Neutral = 'X'; // Unforturnately, Incompatible with Pairtwo (Dinos)
|
||||
|
@ -1,15 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 11/02/19
|
||||
* Time: 16:03
|
||||
* Enum Result
|
||||
*
|
||||
* List of all compatible results
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Enums;
|
||||
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
/**
|
||||
* Enum Result
|
||||
*
|
||||
* List of all compatible results
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Result extends Enum
|
||||
{
|
||||
const none = '*';
|
||||
|
@ -1,10 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Enum Tiebreak
|
||||
*
|
||||
* List of all compatible tiebreaks
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Enums;
|
||||
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
/**
|
||||
* Enum Tiebreak
|
||||
*
|
||||
* List of all compatible tiebreaks
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Tiebreak extends Enum
|
||||
{
|
||||
const None = "";
|
||||
|
@ -1,15 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 25/01/19
|
||||
* Time: 17:10
|
||||
* Enum Title
|
||||
*
|
||||
* List of all compatible titles
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Enums;
|
||||
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
/**
|
||||
* Enum Title
|
||||
*
|
||||
* List of all compatible titles
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Title extends Enum
|
||||
{
|
||||
const NONE = '*';
|
||||
|
@ -1,15 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 19/01/19
|
||||
* Time: 12:23
|
||||
* Enum TournamentSystem
|
||||
*
|
||||
* List of all compatible tournament systems
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Enums;
|
||||
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
/**
|
||||
* Enum TournamentSystem
|
||||
*
|
||||
* List of all compatible tournament systems
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class TournamentSystem extends Enum
|
||||
{
|
||||
const Swiss = 'Swiss';
|
||||
|
@ -1,8 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Exception IncompatibleReaderException
|
||||
*
|
||||
* Exception to be raised when a reader is used that is incompatible
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Exceptions;
|
||||
|
||||
/**
|
||||
* Exception IncompatibleReaderException
|
||||
*
|
||||
* Exception to be raised when a reader is used that is incompatible
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class IncompatibleReaderException extends LibpairtwoException
|
||||
{
|
||||
}
|
||||
|
@ -1,8 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Exception LibpairtwoException
|
||||
*
|
||||
* General exception when something goes wrong with libpairtwo
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Exceptions;
|
||||
|
||||
/**
|
||||
* Exception LibpairtwoException
|
||||
*
|
||||
* General exception when something goes wrong with libpairtwo
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class LibpairtwoException extends \Exception
|
||||
{
|
||||
}
|
||||
|
167
src/Game.php
167
src/Game.php
@ -1,20 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 1/02/19
|
||||
* Time: 17:17
|
||||
* Class Games
|
||||
*
|
||||
* Class for a game of the tournament
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use DateTime;
|
||||
use JeroenED\Libpairtwo\Enums\Gameresult;
|
||||
use JeroenED\Libpairtwo\Models\Game as GameModel;
|
||||
use JeroenED\Libpairtwo\Models\Round;
|
||||
use JeroenED\Libpairtwo\Pairing;
|
||||
|
||||
class Game extends GameModel
|
||||
/**
|
||||
* Class Games
|
||||
*
|
||||
* Class for a game of the tournament
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Game
|
||||
{
|
||||
/** @var Pairing|null */
|
||||
private $white;
|
||||
|
||||
/** @var Pairing|null */
|
||||
private $black;
|
||||
|
||||
/** @var GameResult|null */
|
||||
private $result;
|
||||
|
||||
/**
|
||||
* This function gets the result from the game
|
||||
*
|
||||
* @return Gameresult
|
||||
*/
|
||||
public function getResult(): Gameresult
|
||||
{
|
||||
@ -46,4 +73,132 @@ class Game extends GameModel
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets pairing for white player
|
||||
*
|
||||
* @return Pairing|null
|
||||
*/
|
||||
public function getWhite(): ?Pairing
|
||||
{
|
||||
return $this->white;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets pairing for white player
|
||||
*
|
||||
* @param Pairing|null $white
|
||||
* @return Game
|
||||
*/
|
||||
public function setWhite(?Pairing $white): Game
|
||||
{
|
||||
$this->white = $white;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets pairing for black player
|
||||
*
|
||||
* @return Pairing|null
|
||||
*/
|
||||
public function getBlack(): ?Pairing
|
||||
{
|
||||
return $this->black;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets pairing for black player
|
||||
*
|
||||
* @param Pairing|null $black
|
||||
* @return Game
|
||||
*/
|
||||
public function setBlack(?Pairing $black): Game
|
||||
{
|
||||
$this->black = $black;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets result for game
|
||||
*
|
||||
* @param Gameresult|null $result
|
||||
* @return Game
|
||||
*/
|
||||
public function setResult(?Gameresult $result): Game
|
||||
{
|
||||
$this->result = $result;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getDate(): DateTime
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $date
|
||||
* @return Round
|
||||
*/
|
||||
public function setDate(DateTime $date): Round
|
||||
{
|
||||
$this->date = $date;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Game[]
|
||||
*/
|
||||
public function getGames(): array
|
||||
{
|
||||
return $this->games;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Game[] $games
|
||||
* @return Round
|
||||
*/
|
||||
public function setGames(array $games): Round
|
||||
{
|
||||
$this->games = $games;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRoundNo(): int
|
||||
{
|
||||
return $this->roundNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $roundNo
|
||||
* @return Round
|
||||
*/
|
||||
public function setRoundNo(int $roundNo): Round
|
||||
{
|
||||
$this->roundNo = $roundNo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pairing[]
|
||||
*/
|
||||
public function getPairings(): array
|
||||
{
|
||||
return $this->pairings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pairing[] $pairings
|
||||
* @return Round
|
||||
*/
|
||||
public function setPairings(array $pairings): Round
|
||||
{
|
||||
$this->pairings = $pairings;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class IOFactory
|
||||
*
|
||||
* Class for creating readers for pairing files
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
@ -7,8 +16,23 @@ use JeroenED\LibPairtwo\Exceptions\LibpairtwoException;
|
||||
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
|
||||
use JeroenED\Libpairtwo\Readers\Pairtwo6;
|
||||
|
||||
/**
|
||||
* Class IOFactory
|
||||
*
|
||||
* Class for creating readers for pairing files
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
abstract class IOFactory
|
||||
{
|
||||
/**
|
||||
* Compatible readers
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $readers = [
|
||||
'Pairtwo-6' => Readers\Pairtwo6::class,
|
||||
'Pairtwo-5' => Readers\Pairtwo6::class // File structure identical
|
||||
|
@ -1,12 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Interface ReaderInterface
|
||||
*
|
||||
* Sets the methods a reader needs to implement
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Interfaces;
|
||||
|
||||
use JeroenED\Libpairtwo\Tournament;
|
||||
|
||||
/**
|
||||
* Interface ReaderInterface
|
||||
*
|
||||
* Sets the methods a reader needs to implement
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
interface ReaderInterface
|
||||
{
|
||||
public function read($filename): ReaderInterface;
|
||||
/**
|
||||
* Reads out $filename
|
||||
*
|
||||
* @param $filename
|
||||
* @return ReaderInterface
|
||||
*/
|
||||
public function read(string $filename): ReaderInterface;
|
||||
|
||||
/**
|
||||
* Gets the tournament out of $filename
|
||||
*
|
||||
* @return Tournament
|
||||
*/
|
||||
public function getTournament(): Tournament;
|
||||
}
|
||||
|
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 1/02/19
|
||||
* Time: 17:16
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Models;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Gameresult;
|
||||
use JeroenED\Libpairtwo\Pairing;
|
||||
|
||||
abstract class Game
|
||||
{
|
||||
/** @var Pairing|null */
|
||||
private $white;
|
||||
|
||||
/** @var Pairing|null */
|
||||
private $black;
|
||||
|
||||
/** @var GameResult|null */
|
||||
private $result;
|
||||
|
||||
/**
|
||||
* @return Pairing|null
|
||||
*/
|
||||
public function getWhite(): ?Pairing
|
||||
{
|
||||
return $this->white;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pairing|null $white
|
||||
* @return Game
|
||||
*/
|
||||
public function setWhite(?Pairing $white): Game
|
||||
{
|
||||
$this->white = $white;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pairing|null
|
||||
*/
|
||||
public function getBlack(): ?Pairing
|
||||
{
|
||||
return $this->black;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pairing|null $black
|
||||
* @return Game
|
||||
*/
|
||||
public function setBlack(?Pairing $black): Game
|
||||
{
|
||||
$this->black = $black;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gameresult|null
|
||||
*/
|
||||
public function getResult(): ?Gameresult
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Gameresult|null $result
|
||||
* @return Game
|
||||
*/
|
||||
public function setResult(?Gameresult $result): Game
|
||||
{
|
||||
$this->result = $result;
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 11/02/19
|
||||
* Time: 14:48
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Models;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Color;
|
||||
use JeroenED\Libpairtwo\Enums\Result;
|
||||
use JeroenED\Libpairtwo\Player;
|
||||
|
||||
abstract class Pairing
|
||||
{
|
||||
/** @var Player|null */
|
||||
private $Player;
|
||||
|
||||
/** @var Player|null */
|
||||
private $Opponent;
|
||||
|
||||
/** @var Color */
|
||||
private $Color;
|
||||
|
||||
/** @var Result */
|
||||
private $Result;
|
||||
|
||||
/** @var int */
|
||||
private $Round;
|
||||
|
||||
/**
|
||||
* @return Player|null
|
||||
*/
|
||||
public function getPlayer(): ?Player
|
||||
{
|
||||
return $this->Player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player|null $Player
|
||||
* @return Pairing
|
||||
*/
|
||||
public function setPlayer(?Player $Player): Pairing
|
||||
{
|
||||
$this->Player = $Player;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player|null
|
||||
*/
|
||||
public function getOpponent(): ?Player
|
||||
{
|
||||
return $this->Opponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player|null $Opponent
|
||||
* @return Pairing
|
||||
*/
|
||||
public function setOpponent(?Player $Opponent): Pairing
|
||||
{
|
||||
$this->Opponent = $Opponent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Color
|
||||
*/
|
||||
public function getColor(): Color
|
||||
{
|
||||
return $this->Color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Color $Color
|
||||
* @return Pairing
|
||||
*/
|
||||
public function setColor(Color $Color): Pairing
|
||||
{
|
||||
$this->Color = $Color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Result
|
||||
*/
|
||||
public function getResult(): Result
|
||||
{
|
||||
return $this->Result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Result $Result
|
||||
* @return Pairing
|
||||
*/
|
||||
public function setResult(Result $Result): Pairing
|
||||
{
|
||||
$this->Result = $Result;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRound(): int
|
||||
{
|
||||
return $this->Round;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $Round
|
||||
* @return Pairing
|
||||
*/
|
||||
public function setRound(int $Round): Pairing
|
||||
{
|
||||
$this->Round = $Round;
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -1,255 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 19/01/19
|
||||
* Time: 14:14
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Models;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Title;
|
||||
use JeroenED\Libpairtwo\Enums\Gender;
|
||||
use JeroenED\Libpairtwo\Pairing;
|
||||
use DateTime;
|
||||
|
||||
abstract class Player
|
||||
{
|
||||
/** @var string */
|
||||
private $Name;
|
||||
|
||||
/** @var int[] */
|
||||
private $Ids;
|
||||
|
||||
/** @var int[] */
|
||||
private $Elos;
|
||||
|
||||
/** @var DateTime */
|
||||
private $DateOfBirth;
|
||||
|
||||
/** @var float[] */
|
||||
private $Tiebreaks = [];
|
||||
|
||||
/** @var string */
|
||||
private $Nation;
|
||||
|
||||
// TODO: Implement categories
|
||||
/** @var string */
|
||||
private $Category;
|
||||
|
||||
/** @var Title */
|
||||
private $Title;
|
||||
|
||||
/** @var Gender */
|
||||
private $Gender;
|
||||
|
||||
/** @var Pairing[] */
|
||||
private $Pairings = [];
|
||||
|
||||
/** @var bool|DateTime|int|string[] */
|
||||
private $BinaryData;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->Name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Name
|
||||
* @return Player
|
||||
*/
|
||||
public function setName(string $Name): Player
|
||||
{
|
||||
$this->Name = $Name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getIds(): ?array
|
||||
{
|
||||
return $this->Ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $Ids
|
||||
* @return Player
|
||||
*/
|
||||
public function setIds(array $Ids): Player
|
||||
{
|
||||
$this->Ids = $Ids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function getElos(): ?array
|
||||
{
|
||||
return $this->Elos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[] $Elos
|
||||
* @return Player
|
||||
*/
|
||||
public function setElos(array $Elos): Player
|
||||
{
|
||||
$this->Elos = $Elos;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateOfBirth(): \DateTime
|
||||
{
|
||||
return $this->DateOfBirth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $DateOfBirth
|
||||
* @return Player
|
||||
*/
|
||||
public function setDateOfBirth(\DateTime $DateOfBirth): Player
|
||||
{
|
||||
$this->DateOfBirth = $DateOfBirth;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float[]
|
||||
*/
|
||||
public function getTiebreaks(): array
|
||||
{
|
||||
return $this->Tiebreaks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float[] $Tiebreaks
|
||||
* @return Player
|
||||
*/
|
||||
public function setTiebreaks(array $Tiebreaks): Player
|
||||
{
|
||||
$this->Tiebreaks = $Tiebreaks;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* example value: BEL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNation(): string
|
||||
{
|
||||
return $this->Nation;
|
||||
}
|
||||
|
||||
/**
|
||||
* example value: BEL
|
||||
*
|
||||
* @param string $Nation
|
||||
* @return Player
|
||||
*/
|
||||
public function setNation(string $Nation): Player
|
||||
{
|
||||
$this->Nation = $Nation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory(): string
|
||||
{
|
||||
return $this->Category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Category
|
||||
* @return Player
|
||||
*/
|
||||
public function setCategory(string $Category): Player
|
||||
{
|
||||
$this->Category = $Category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Title
|
||||
*/
|
||||
public function getTitle(): Title
|
||||
{
|
||||
return $this->Title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Title $Title
|
||||
* @return Player
|
||||
*/
|
||||
public function setTitle(Title $Title): Player
|
||||
{
|
||||
$this->Title = $Title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gender
|
||||
*/
|
||||
public function getGender(): Gender
|
||||
{
|
||||
return $this->Gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Gender $Gender
|
||||
* @return Player
|
||||
*/
|
||||
public function setGender(Gender $Gender): Player
|
||||
{
|
||||
$this->Gender = $Gender;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pairing[]
|
||||
*/
|
||||
public function getPairings(): array
|
||||
{
|
||||
return $this->Pairings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pairing[] $Pairings
|
||||
* @return Player
|
||||
*/
|
||||
public function setPairings(array $Pairings): Player
|
||||
{
|
||||
$this->Pairings = $Pairings;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Key
|
||||
* @return bool|DateTime|int|string
|
||||
*/
|
||||
public function getBinaryData(string $Key)
|
||||
{
|
||||
return $this->BinaryData[$Key];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Key
|
||||
* @param bool|int|DateTime|string $Value
|
||||
* @return Player
|
||||
*/
|
||||
public function setBinaryData(string $Key, $Value): Player
|
||||
{
|
||||
$this->BinaryData[$Key] = $Value;
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 1/02/19
|
||||
* Time: 17:13
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Models;
|
||||
|
||||
use DateTime;
|
||||
use JeroenED\Libpairtwo\Game;
|
||||
use JeroenED\Libpairtwo\Pairing;
|
||||
|
||||
abstract class Round
|
||||
{
|
||||
/** @var DateTime */
|
||||
private $date;
|
||||
|
||||
/** @var Game[] */
|
||||
private $games = [];
|
||||
|
||||
/** @var int */
|
||||
private $roundNo;
|
||||
|
||||
/** @var Pairing[] */
|
||||
private $pairings = [];
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getDate(): DateTime
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $date
|
||||
* @return Round
|
||||
*/
|
||||
public function setDate(DateTime $date): Round
|
||||
{
|
||||
$this->date = $date;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Game[]
|
||||
*/
|
||||
public function getGames(): array
|
||||
{
|
||||
return $this->games;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Game[] $games
|
||||
* @return Round
|
||||
*/
|
||||
public function setGames(array $games): Round
|
||||
{
|
||||
$this->games = $games;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRoundNo(): int
|
||||
{
|
||||
return $this->roundNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $roundNo
|
||||
* @return Round
|
||||
*/
|
||||
public function setRoundNo(int $roundNo): Round
|
||||
{
|
||||
$this->roundNo = $roundNo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pairing[]
|
||||
*/
|
||||
public function getPairings(): array
|
||||
{
|
||||
return $this->pairings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pairing[] $pairings
|
||||
* @return Round
|
||||
*/
|
||||
public function setPairings(array $pairings): Round
|
||||
{
|
||||
$this->pairings = $pairings;
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -1,543 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2019 Jeroen De Meerleer <schaak@jeroened.be>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo\Models;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Tiebreak;
|
||||
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
||||
use JeroenED\Libpairtwo\Player;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* Description of Sws
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
abstract class Tournament
|
||||
{
|
||||
/** @var string */
|
||||
private $Name;
|
||||
|
||||
/** @var string */
|
||||
private $Organiser;
|
||||
|
||||
/** @var int */
|
||||
private $OrganiserClubNo;
|
||||
|
||||
/** @var string */
|
||||
private $OrganiserClub;
|
||||
|
||||
/** @var string */
|
||||
private $OrganiserPlace;
|
||||
|
||||
/** @var string */
|
||||
private $OrganiserCountry;
|
||||
|
||||
/** @var int */
|
||||
private $FideHomol;
|
||||
|
||||
/** @var DateTime */
|
||||
private $StartDate;
|
||||
|
||||
/** @var DateTime */
|
||||
private $EndDate;
|
||||
|
||||
/** @var string */
|
||||
private $Arbiter;
|
||||
|
||||
/** @var int */
|
||||
private $NoOfRounds;
|
||||
|
||||
/** @var Round[] */
|
||||
private $Rounds = [];
|
||||
|
||||
/** @var string */
|
||||
private $Tempo;
|
||||
|
||||
/** @var int */
|
||||
private $NonRatedElo;
|
||||
|
||||
/** @var TournamentSystem */
|
||||
private $System;
|
||||
|
||||
/** @var string */
|
||||
private $FirstPeriod;
|
||||
|
||||
/** @var string */
|
||||
private $SecondPeriod;
|
||||
|
||||
/** @var string */
|
||||
private $Federation;
|
||||
|
||||
/** @var Player[] */
|
||||
private $Players = [];
|
||||
|
||||
/** @var int */
|
||||
private $Year;
|
||||
|
||||
/** @var Pairing[] */
|
||||
private $Pairings = [];
|
||||
|
||||
/** @var Tiebreak[] */
|
||||
private $Tiebreaks = [];
|
||||
|
||||
/** @var string */
|
||||
private $PriorityElo = 'Fide';
|
||||
|
||||
/** @var string */
|
||||
private $PriorityId = 'Nation';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->Name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Name
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setName(string $Name): Tournament
|
||||
{
|
||||
$this->Name = $Name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrganiser(): string
|
||||
{
|
||||
return $this->Organiser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Organiser
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setOrganiser(string $Organiser): Tournament
|
||||
{
|
||||
$this->Organiser = $Organiser;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOrganiserClubNo(): int
|
||||
{
|
||||
return $this->OrganiserClubNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $OrganiserClubNo
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setOrganiserClubNo(int $OrganiserClubNo): Tournament
|
||||
{
|
||||
$this->OrganiserClubNo = $OrganiserClubNo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrganiserClub(): string
|
||||
{
|
||||
return $this->OrganiserClub;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $OrganiserClub
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setOrganiserClub(string $OrganiserClub): Tournament
|
||||
{
|
||||
$this->OrganiserClub = $OrganiserClub;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrganiserPlace(): string
|
||||
{
|
||||
return $this->OrganiserPlace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $OrganiserPlace
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setOrganiserPlace(string $OrganiserPlace): Tournament
|
||||
{
|
||||
$this->OrganiserPlace = $OrganiserPlace;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrganiserCountry(): string
|
||||
{
|
||||
return $this->OrganiserCountry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $OrganiserCountry
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setOrganiserCountry(string $OrganiserCountry): Tournament
|
||||
{
|
||||
$this->OrganiserCountry = $OrganiserCountry;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFideHomol(): int
|
||||
{
|
||||
return $this->FideHomol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $FideHomol
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setFideHomol(int $FideHomol): Tournament
|
||||
{
|
||||
$this->FideHomol = $FideHomol;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getStartDate(): DateTime
|
||||
{
|
||||
return $this->StartDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $StartDate
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setStartDate(DateTime $StartDate): Tournament
|
||||
{
|
||||
$this->StartDate = $StartDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getEndDate(): DateTime
|
||||
{
|
||||
return $this->EndDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $EndDate
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setEndDate(DateTime $EndDate): Tournament
|
||||
{
|
||||
$this->EndDate = $EndDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArbiter(): string
|
||||
{
|
||||
return $this->Arbiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Arbiter
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setArbiter(string $Arbiter): Tournament
|
||||
{
|
||||
$this->Arbiter = $Arbiter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNoOfRounds(): int
|
||||
{
|
||||
return $this->NoOfRounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $NoOfRounds
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setNoOfRounds(int $NoOfRounds): Tournament
|
||||
{
|
||||
$this->NoOfRounds = $NoOfRounds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Round[]
|
||||
*/
|
||||
public function getRounds(): array
|
||||
{
|
||||
return $this->Rounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Round[] $Rounds
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setRounds(array $Rounds): Tournament
|
||||
{
|
||||
$this->Rounds = $Rounds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTempo(): string
|
||||
{
|
||||
return $this->Tempo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Tempo
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setTempo(string $Tempo): Tournament
|
||||
{
|
||||
$this->Tempo = $Tempo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNonRatedElo(): int
|
||||
{
|
||||
return $this->NonRatedElo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $NonRatedElo
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setNonRatedElo(int $NonRatedElo): Tournament
|
||||
{
|
||||
$this->NonRatedElo = $NonRatedElo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TournamentSystem
|
||||
*/
|
||||
public function getSystem(): TournamentSystem
|
||||
{
|
||||
return $this->System;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TournamentSystem $System
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setSystem(TournamentSystem $System): Tournament
|
||||
{
|
||||
$this->System = $System;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstPeriod(): string
|
||||
{
|
||||
return $this->FirstPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $FirstPeriod
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setFirstPeriod(string $FirstPeriod): Tournament
|
||||
{
|
||||
$this->FirstPeriod = $FirstPeriod;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSecondPeriod(): string
|
||||
{
|
||||
return $this->SecondPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $SecondPeriod
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setSecondPeriod(string $SecondPeriod): Tournament
|
||||
{
|
||||
$this->SecondPeriod = $SecondPeriod;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFederation(): string
|
||||
{
|
||||
return $this->Federation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Federation
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setFederation(string $Federation): Tournament
|
||||
{
|
||||
$this->Federation = $Federation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getPlayers(): array
|
||||
{
|
||||
return $this->Players;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player[] $Players
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setPlayers(array $Players): Tournament
|
||||
{
|
||||
$this->Players = $Players;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getYear(): int
|
||||
{
|
||||
return $this->Year;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $Year
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setYear(int $Year): Tournament
|
||||
{
|
||||
$this->Year = $Year;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pairing[]
|
||||
*/
|
||||
public function getPairings(): array
|
||||
{
|
||||
return $this->Pairings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pairing[] $Pairings
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setPairings(array $Pairings): Tournament
|
||||
{
|
||||
$this->Pairings = $Pairings;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Tiebreak[]
|
||||
*/
|
||||
public function getTiebreaks(): array
|
||||
{
|
||||
return $this->Tiebreaks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tiebreak[] $Tiebreaks
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setTiebreaks(array $Tiebreaks): Tournament
|
||||
{
|
||||
$this->Tiebreaks = $Tiebreaks;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPriorityElo(): string
|
||||
{
|
||||
return $this->PriorityElo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $PriorityElo
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setPriorityElo(string $PriorityElo): Tournament
|
||||
{
|
||||
$this->PriorityElo = $PriorityElo;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPriorityId(): string
|
||||
{
|
||||
return $this->PriorityId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $PriorityId
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setPriorityId(string $PriorityId): Tournament
|
||||
{
|
||||
$this->PriorityId = $PriorityId;
|
||||
return $this;
|
||||
}
|
||||
}
|
131
src/Pairing.php
131
src/Pairing.php
@ -1,15 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 11/02/19
|
||||
* Time: 15:56
|
||||
* Class Pairing
|
||||
*
|
||||
* Class for a pairing of the tournament
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use JeroenED\Libpairtwo\Models\Pairing as PairingModel;
|
||||
use JeroenED\Libpairtwo\Enums\Color;
|
||||
use JeroenED\Libpairtwo\Enums\Result;
|
||||
|
||||
class Pairing extends PairingModel
|
||||
/**
|
||||
* Class Pairing
|
||||
*
|
||||
* Class for a pairing of the tournament
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Pairing
|
||||
{
|
||||
/** @var Player|null */
|
||||
private $Player;
|
||||
|
||||
/** @var Player|null */
|
||||
private $Opponent;
|
||||
|
||||
/** @var Color */
|
||||
private $Color;
|
||||
|
||||
/** @var Result */
|
||||
private $Result;
|
||||
|
||||
/** @var int */
|
||||
private $Round;
|
||||
|
||||
/**
|
||||
* @return Player|null
|
||||
*/
|
||||
public function getPlayer(): ?Player
|
||||
{
|
||||
return $this->Player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player|null $Player
|
||||
* @return Pairing
|
||||
*/
|
||||
public function setPlayer(?Player $Player): Pairing
|
||||
{
|
||||
$this->Player = $Player;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player|null
|
||||
*/
|
||||
public function getOpponent(): ?Player
|
||||
{
|
||||
return $this->Opponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player|null $Opponent
|
||||
* @return Pairing
|
||||
*/
|
||||
public function setOpponent(?Player $Opponent): Pairing
|
||||
{
|
||||
$this->Opponent = $Opponent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Color
|
||||
*/
|
||||
public function getColor(): Color
|
||||
{
|
||||
return $this->Color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Color $Color
|
||||
* @return Pairing
|
||||
*/
|
||||
public function setColor(Color $Color): Pairing
|
||||
{
|
||||
$this->Color = $Color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Result
|
||||
*/
|
||||
public function getResult(): Result
|
||||
{
|
||||
return $this->Result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Result $Result
|
||||
* @return Pairing
|
||||
*/
|
||||
public function setResult(Result $Result): Pairing
|
||||
{
|
||||
$this->Result = $Result;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRound(): int
|
||||
{
|
||||
return $this->Round;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $Round
|
||||
* @return Pairing
|
||||
*/
|
||||
public function setRound(int $Round): Pairing
|
||||
{
|
||||
$this->Round = $Round;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
265
src/Player.php
265
src/Player.php
@ -1,22 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 1/02/19
|
||||
* Time: 11:26
|
||||
* Class Player
|
||||
*
|
||||
* Class for a player of the tournament
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use JeroenED\Libpairtwo\Models\Player as PlayerModel;
|
||||
use JeroenED\Libpairtwo\Enums\Title;
|
||||
use JeroenED\Libpairtwo\Enums\Gender;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* Class Player
|
||||
* @package JeroenED\Libpairtwo
|
||||
*
|
||||
* Class for a player of the tournament
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Player extends PlayerModel
|
||||
class Player
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $Name;
|
||||
|
||||
/** @var int[] */
|
||||
private $Ids;
|
||||
|
||||
/** @var int[] */
|
||||
private $Elos;
|
||||
|
||||
/** @var DateTime */
|
||||
private $DateOfBirth;
|
||||
|
||||
/** @var float[] */
|
||||
private $Tiebreaks = [];
|
||||
|
||||
/** @var string */
|
||||
private $Nation;
|
||||
|
||||
// TODO: Implement categories
|
||||
/** @var string */
|
||||
private $Category;
|
||||
|
||||
/** @var Title */
|
||||
private $Title;
|
||||
|
||||
/** @var Gender */
|
||||
private $Gender;
|
||||
|
||||
/** @var Pairing[] */
|
||||
private $Pairings = [];
|
||||
|
||||
/** @var bool|DateTime|int|string[] */
|
||||
private $BinaryData;
|
||||
|
||||
/**
|
||||
* Adds a pairing to the tournament
|
||||
*
|
||||
@ -166,4 +211,208 @@ class Player extends PlayerModel
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->Name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Name
|
||||
* @return \JeroenED\Libpairtwo\Models\Player
|
||||
*/
|
||||
public function setName(string $Name): Player
|
||||
{
|
||||
$this->Name = $Name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getIds(): ?array
|
||||
{
|
||||
return $this->Ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $Ids
|
||||
* @return Player
|
||||
*/
|
||||
public function setIds(array $Ids): Player
|
||||
{
|
||||
$this->Ids = $Ids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function getElos(): ?array
|
||||
{
|
||||
return $this->Elos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[] $Elos
|
||||
* @return Player
|
||||
*/
|
||||
public function setElos(array $Elos): Player
|
||||
{
|
||||
$this->Elos = $Elos;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateOfBirth(): \DateTime
|
||||
{
|
||||
return $this->DateOfBirth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $DateOfBirth
|
||||
* @return Player
|
||||
*/
|
||||
public function setDateOfBirth(\DateTime $DateOfBirth): Player
|
||||
{
|
||||
$this->DateOfBirth = $DateOfBirth;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float[]
|
||||
*/
|
||||
public function getTiebreaks(): array
|
||||
{
|
||||
return $this->Tiebreaks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float[] $Tiebreaks
|
||||
* @return Player
|
||||
*/
|
||||
public function setTiebreaks(array $Tiebreaks): Player
|
||||
{
|
||||
$this->Tiebreaks = $Tiebreaks;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* example value: BEL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNation(): string
|
||||
{
|
||||
return $this->Nation;
|
||||
}
|
||||
|
||||
/**
|
||||
* example value: BEL
|
||||
*
|
||||
* @param string $Nation
|
||||
* @return Player
|
||||
*/
|
||||
public function setNation(string $Nation): Player
|
||||
{
|
||||
$this->Nation = $Nation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory(): string
|
||||
{
|
||||
return $this->Category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Category
|
||||
* @return Player
|
||||
*/
|
||||
public function setCategory(string $Category): Player
|
||||
{
|
||||
$this->Category = $Category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Title
|
||||
*/
|
||||
public function getTitle(): Title
|
||||
{
|
||||
return $this->Title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Title $Title
|
||||
* @return Player
|
||||
*/
|
||||
public function setTitle(Title $Title): Player
|
||||
{
|
||||
$this->Title = $Title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gender
|
||||
*/
|
||||
public function getGender(): Gender
|
||||
{
|
||||
return $this->Gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Gender $Gender
|
||||
* @return Player
|
||||
*/
|
||||
public function setGender(Gender $Gender): Player
|
||||
{
|
||||
$this->Gender = $Gender;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pairing[]
|
||||
*/
|
||||
public function getPairings(): array
|
||||
{
|
||||
return $this->Pairings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pairing[] $Pairings
|
||||
* @return Player
|
||||
*/
|
||||
public function setPairings(array $Pairings): Player
|
||||
{
|
||||
$this->Pairings = $Pairings;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Key
|
||||
* @return bool|DateTime|int|string
|
||||
*/
|
||||
public function getBinaryData(string $Key)
|
||||
{
|
||||
return $this->BinaryData[$Key];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Key
|
||||
* @param bool|int|DateTime|string $Value
|
||||
* @return Player
|
||||
*/
|
||||
public function setBinaryData(string $Key, $Value): Player
|
||||
{
|
||||
$this->BinaryData[$Key] = $Value;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace JeroenED\Libpairtwo\Readers\Models;
|
||||
|
||||
use JeroenED\Libpairtwo\Tournament;
|
||||
|
||||
abstract class Pairtwo6
|
||||
{
|
||||
/** @var string */
|
||||
private $Release;
|
||||
|
||||
/** @var tournament */
|
||||
private $Tournament;
|
||||
|
||||
/** @var bool|DateTime|int|string[] */
|
||||
private $BinaryData;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRelease(): string
|
||||
{
|
||||
return $this->Release;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Release
|
||||
* @return Pairtwo6
|
||||
*/
|
||||
public function setRelease(string $Release): Pairtwo6
|
||||
{
|
||||
$this->Release = $Release;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Tournament
|
||||
*/
|
||||
public function getTournament(): Tournament
|
||||
{
|
||||
return $this->Tournament;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tournament $Tournament
|
||||
* @return Pairtwo6
|
||||
*/
|
||||
public function setTournament(Tournament $Tournament): Pairtwo6
|
||||
{
|
||||
$this->Tournament = $Tournament;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $Key
|
||||
* @return bool|DateTime|int|string
|
||||
*/
|
||||
public function getBinaryData(string $Key)
|
||||
{
|
||||
return $this->BinaryData[$Key];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $Key
|
||||
* @param bool|int|DateTime|string $Value
|
||||
* @return Pairtwo6
|
||||
*/
|
||||
public function setBinaryData(string $Key, $Value): Pairtwo6
|
||||
{
|
||||
$this->BinaryData[$Key] = $Value;
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -1,29 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
/**
|
||||
* Reader Pairtwo6
|
||||
*
|
||||
* Copyright 2019 Jeroen De Meerleer <schaak@jeroened.be>.
|
||||
* Reads out Pairtwo-6 files
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
|
||||
namespace JeroenED\Libpairtwo\Readers;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Tiebreak;
|
||||
@ -37,16 +24,20 @@ use JeroenED\Libpairtwo\Player;
|
||||
use JeroenED\Libpairtwo\Round;
|
||||
use JeroenED\Libpairtwo\Pairing;
|
||||
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
|
||||
use JeroenED\Libpairtwo\Readers\Models\Pairtwo6 as Pairtwo6Model;
|
||||
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* This class reads a SWS file
|
||||
* Reader Pairtwo6
|
||||
*
|
||||
* @author Jeroen De Meerleer
|
||||
* Reads out Pairtwo-6 files
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
|
||||
class Pairtwo6 implements ReaderInterface
|
||||
{
|
||||
private const PT_DAYFACTOR = 32;
|
||||
private const PT_MONTHFACTOR = 16;
|
||||
@ -54,11 +45,79 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
|
||||
private const PT_PASTOFFSET = 117;
|
||||
private const CompatibleVersions = ['6.', '5.'];
|
||||
|
||||
/** @var string */
|
||||
private $Release;
|
||||
|
||||
/** @var Tournament */
|
||||
private $Tournament;
|
||||
|
||||
/** @var bool|DateTime|int|string[] */
|
||||
private $BinaryData;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRelease(): string
|
||||
{
|
||||
return $this->Release;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Release
|
||||
* @return \JeroenED\Libpairtwo\Readers\Models\Pairtwo6
|
||||
*/
|
||||
public function setRelease(string $Release): Pairtwo6
|
||||
{
|
||||
$this->Release = $Release;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Tournament
|
||||
*/
|
||||
public function getTournament(): Tournament
|
||||
{
|
||||
return $this->Tournament;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tournament $Tournament
|
||||
* @return Pairtwo6
|
||||
*/
|
||||
public function setTournament(Tournament $Tournament): Pairtwo6
|
||||
{
|
||||
$this->Tournament = $Tournament;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $Key
|
||||
* @return bool|DateTime|int|string
|
||||
*/
|
||||
public function getBinaryData(string $Key)
|
||||
{
|
||||
return $this->BinaryData[$Key];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $Key
|
||||
* @param bool|int|DateTime|string $Value
|
||||
* @return Pairtwo6
|
||||
*/
|
||||
public function setBinaryData(string $Key, $Value): Pairtwo6
|
||||
{
|
||||
$this->BinaryData[$Key] = $Value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads out $swsfile and returns a Pairtwo6 class object
|
||||
*
|
||||
* @param string $filename
|
||||
* @return Pairtwo6
|
||||
* @throws IncompatibleReaderException
|
||||
*/
|
||||
public function read($filename): ReaderInterface
|
||||
{
|
||||
@ -507,7 +566,7 @@ class Pairtwo6 extends Pairtwo6Model implements ReaderInterface
|
||||
|
||||
// Participants
|
||||
$length = 4;
|
||||
$this->getTournament()->setBinaryData('Participants', $this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$this->setBinaryData('Participants', $this->readData('Int', substr($swscontents, $offset, $length)));
|
||||
$offset += $length;
|
||||
|
||||
// Fidehomol
|
||||
|
143
src/Round.php
143
src/Round.php
@ -1,42 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 1/02/19
|
||||
* Time: 17:16
|
||||
* Class Round
|
||||
*
|
||||
* Class for a round of the tournament
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use DateTime;
|
||||
use JeroenED\Libpairtwo\Enums\Result;
|
||||
use JeroenED\Libpairtwo\Models\Round as RoundModel;
|
||||
use JeroenED\Libpairtwo\Game;
|
||||
use JeroenED\Libpairtwo\Pairing;
|
||||
|
||||
class Round extends RoundModel
|
||||
/**
|
||||
* Class Round
|
||||
*
|
||||
* Class for a round of the tournament
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Round
|
||||
{
|
||||
/**
|
||||
* Date of the round
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
private $date;
|
||||
|
||||
/**
|
||||
* Array of all games
|
||||
*
|
||||
* @var Game[]
|
||||
*/
|
||||
private $games = [];
|
||||
|
||||
/**
|
||||
* Number of the round
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $roundNo;
|
||||
|
||||
/**
|
||||
* Array of all pairings for this round
|
||||
*
|
||||
* @var Pairing[]
|
||||
*/
|
||||
private $pairings = [];
|
||||
|
||||
/**
|
||||
* Adds a game to the round
|
||||
*
|
||||
* @param Game $game
|
||||
* @return Round
|
||||
*/
|
||||
public function addGame(Game $game)
|
||||
public function addGame(Game $game): Round
|
||||
{
|
||||
$newarray = $this->getGames();
|
||||
$newarray[] = $game;
|
||||
$this->setGames($newarray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a pairing to the round
|
||||
*
|
||||
* @param Pairing $pairing
|
||||
* @return Round
|
||||
*/
|
||||
public function addPairing(Pairing $pairing)
|
||||
public function addPairing(Pairing $pairing): Round
|
||||
{
|
||||
$newarray = $this->getPairings();
|
||||
$newarray[] = $pairing;
|
||||
$this->setPairings($newarray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@ -74,4 +120,85 @@ class Round extends RoundModel
|
||||
}
|
||||
return $absentPairings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date of the round
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getDate(): DateTime
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
/**
|
||||
* Sets the date of the round
|
||||
*
|
||||
* @param DateTime $date
|
||||
* @return Round
|
||||
*/
|
||||
public function setDate(DateTime $date): Round
|
||||
{
|
||||
$this->date = $date;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns an array of all games in the tournament
|
||||
*
|
||||
* @return Game[]
|
||||
*/
|
||||
public function getGames(): array
|
||||
{
|
||||
return $this->games;
|
||||
}
|
||||
/**
|
||||
* Sets Round::games to $games
|
||||
*
|
||||
* @param Game[] $games
|
||||
* @return Round
|
||||
*/
|
||||
public function setGames(array $games): Round
|
||||
{
|
||||
$this->games = $games;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns the round number
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRoundNo(): int
|
||||
{
|
||||
return $this->roundNo;
|
||||
}
|
||||
/**
|
||||
* Sets the round number
|
||||
*
|
||||
* @param int $roundNo
|
||||
* @return Round
|
||||
*/
|
||||
public function setRoundNo(int $roundNo): Round
|
||||
{
|
||||
$this->roundNo = $roundNo;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns an array of all pairings for this round
|
||||
*
|
||||
* @return Pairing[]
|
||||
*/
|
||||
public function getPairings(): array
|
||||
{
|
||||
return $this->pairings;
|
||||
}
|
||||
/**
|
||||
* Sets Round::Pairings to $pairings
|
||||
*
|
||||
* @param Pairing[] $pairings
|
||||
* @return Round
|
||||
*/
|
||||
public function setPairings(array $pairings): Round
|
||||
{
|
||||
$this->pairings = $pairings;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -1,325 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Color;
|
||||
use JeroenED\Libpairtwo\Models\Tournament;
|
||||
use JeroenED\Libpairtwo\Enums\Result;
|
||||
|
||||
abstract class Tiebreaks extends Tournament
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateKeizer(Player $player): ?float
|
||||
{
|
||||
return $player->getBinaryData('ScoreAmerican');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateAmerican(Player $player): ?float
|
||||
{
|
||||
return $player->getBinaryData('ScoreAmerican');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculatePoints(Player $player): ?float
|
||||
{
|
||||
return $player->getPoints();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateBaumbach(Player $player): ?float
|
||||
{
|
||||
$totalwins = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$totalwins++;
|
||||
}
|
||||
}
|
||||
return $totalwins;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateBlackPlayed(Player $player): ?float
|
||||
{
|
||||
$totalwins = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getColor(), Constants::Black) !== false) {
|
||||
$totalwins++;
|
||||
}
|
||||
}
|
||||
return $totalwins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateBlackWin(Player $player): ?float
|
||||
{
|
||||
$totalwins = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getColor(), Constants::Black) !== false && array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$totalwins++;
|
||||
}
|
||||
}
|
||||
return $totalwins;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param array $opponents
|
||||
* @param int $key
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateMutualResult(Player $player, array $opponents, int $key): ?float
|
||||
{
|
||||
$interestingplayers = $opponents;
|
||||
if ($key != 0) {
|
||||
$interestingplayers = [];
|
||||
$playerstiebreaks = $player->getTiebreaks();
|
||||
array_splice($playerstiebreaks, $key);
|
||||
foreach ($opponents as $opponent) {
|
||||
$opponenttiebreaks = $opponent->getTiebreaks();
|
||||
array_splice($opponenttiebreaks, $key);
|
||||
if (($playerstiebreaks == $opponenttiebreaks) && ($player != $opponent)) {
|
||||
$interestingplayers[] = $opponent;
|
||||
}
|
||||
}
|
||||
}
|
||||
$points = 0;
|
||||
$totalmatches = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getOpponent(), $interestingplayers) !== false) {
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$points = $points + 1;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$points = $points + 0.5;
|
||||
}
|
||||
$totalmatches++;
|
||||
}
|
||||
}
|
||||
if ($totalmatches != count($interestingplayers)) {
|
||||
$points = null;
|
||||
}
|
||||
return $points;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param int $cut
|
||||
* @return float
|
||||
*/
|
||||
protected function calculateAverageRating(Player $player, string $type, int $cut = 0): ?float
|
||||
{
|
||||
$pairings = $player->getPairings();
|
||||
$allratings = [];
|
||||
foreach ($pairings as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
|
||||
$toadd = $pairing->getOpponent()->getElo($type);
|
||||
if ($toadd != 0) {
|
||||
$allratings[] = $toadd;
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($allratings);
|
||||
$allratings = array_slice($allratings, $cut);
|
||||
return round(array_sum($allratings) / count($allratings));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param int $cut
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateAveragePerformance(Player $player, string $type, int $cut = 0): ?float
|
||||
{
|
||||
$pairings = $player->getPairings();
|
||||
$allratings = [];
|
||||
foreach ($pairings as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
|
||||
$toadd = $pairing->getOpponent()->getPerformance($type, $this->getNonRatedElo());
|
||||
if ($toadd != 0) {
|
||||
$allratings[] = $toadd;
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($allratings);
|
||||
$allratings = array_slice($allratings, $cut);
|
||||
return round(array_sum($allratings) / count($allratings));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param int $cut
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateKoya(Player $player, int $cut = 50): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $plkey => $plpairing) {
|
||||
if (($plpairing->getOpponent()->getPoints() / count($plpairing->getOpponent()->getPairings()) * 100) >= $cut) {
|
||||
if (array_search($plpairing->getResult(), Constants::Won) !== false) {
|
||||
$tiebreak += 1;
|
||||
} elseif (array_search($plpairing->getResult(), Constants::Draw) !== false) {
|
||||
$tiebreak += 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tiebreak;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param int $cutlowest
|
||||
* @param int $cuthighest
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateBuchholz(Player $player, int $cutlowest = 0, int $cuthighest = 0): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
$intpairings = $player->getPairings();
|
||||
|
||||
usort($intpairings, function ($a, $b) {
|
||||
if (is_null($a->getOpponent())) {
|
||||
return -1;
|
||||
}
|
||||
if (is_null($b->getOpponent())) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($b->getOpponent()->getPoints() == $a->getOpponent()->getPoints()) {
|
||||
return 0;
|
||||
}
|
||||
return ($a->getOpponent()->getPoints() > $b->getOpponent()->getPoints()) ? 1 : -1;
|
||||
});
|
||||
|
||||
$intpairings = array_slice($intpairings, $cutlowest);
|
||||
$intpairings = array_slice($intpairings, 0 - $cuthighest);
|
||||
|
||||
foreach ($intpairings as $intkey => $intpairing) {
|
||||
if (!is_null($intpairing->getOpponent())) {
|
||||
$tiebreak += $intpairing->getOpponent()->getPoints();
|
||||
}
|
||||
}
|
||||
return $tiebreak;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateSonneborn(Player $player): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $key => $pairing) {
|
||||
if ($pairing->getOpponent()) {
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$tiebreak += $pairing->getOpponent()->getPoints();
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$tiebreak += $pairing->getOpponent()->getPoints() / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tiebreak;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateSoccerKashdan(Player $player): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
$toadd = 0;
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$toadd = 3;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$toadd = 1;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Lost) !== false) {
|
||||
$toadd = 0;
|
||||
}
|
||||
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) !== false) {
|
||||
$toadd = -1;
|
||||
}
|
||||
$tiebreak += $toadd;
|
||||
}
|
||||
return $tiebreak; // - $player->getNoOfWins();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateKashdan(Player $player): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
$toadd = 0;
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$toadd = 4;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$toadd = 2;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Lost) !== false) {
|
||||
$toadd = 1;
|
||||
}
|
||||
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) !== false) {
|
||||
$toadd = 0;
|
||||
}
|
||||
$tiebreak += $toadd;
|
||||
}
|
||||
return $tiebreak; // - $player->getNoOfWins();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
protected function calculateCumulative(Player $player): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
$score = [];
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
$toadd = 0;
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$toadd = 1;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$toadd = 0.5;
|
||||
}
|
||||
$tiebreak += $toadd;
|
||||
$score[] = $tiebreak;
|
||||
}
|
||||
return array_sum($score);
|
||||
}
|
||||
}
|
@ -1,18 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jeroen
|
||||
* Date: 1/02/19
|
||||
* Time: 11:18
|
||||
* Class Tournament
|
||||
*
|
||||
* Class for the tournament from the pairing file
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use DateTime;
|
||||
use JeroenED\Libpairtwo\Enums\Tiebreak;
|
||||
use JeroenED\Libpairtwo\Enums\Color;
|
||||
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
||||
|
||||
class Tournament extends Tiebreaks
|
||||
/**
|
||||
* Class Tournament
|
||||
*
|
||||
* Class for the tournament from the pairing file
|
||||
*
|
||||
* @author Jeroen De Meerleer <schaak@jeroened.be>
|
||||
* @category Main
|
||||
* @package Libpairtwo
|
||||
* @copyright Copyright (c) 2018-2019 Jeroen De Meerleer <schaak@jeroened.be>
|
||||
*/
|
||||
class Tournament
|
||||
{
|
||||
/** @var string */
|
||||
private $Name;
|
||||
|
||||
/** @var string */
|
||||
private $Organiser;
|
||||
|
||||
/** @var int */
|
||||
private $OrganiserClubNo;
|
||||
|
||||
/** @var string */
|
||||
private $OrganiserClub;
|
||||
|
||||
/** @var string */
|
||||
private $OrganiserPlace;
|
||||
|
||||
/** @var string */
|
||||
private $OrganiserCountry;
|
||||
|
||||
/** @var int */
|
||||
private $FideHomol;
|
||||
|
||||
/** @var DateTime */
|
||||
private $StartDate;
|
||||
|
||||
/** @var DateTime */
|
||||
private $EndDate;
|
||||
|
||||
/** @var string */
|
||||
private $Arbiter;
|
||||
|
||||
/** @var int */
|
||||
private $NoOfRounds;
|
||||
|
||||
/** @var Round[] */
|
||||
private $Rounds = [];
|
||||
|
||||
/** @var string */
|
||||
private $Tempo;
|
||||
|
||||
/** @var int */
|
||||
private $NonRatedElo;
|
||||
|
||||
/** @var TournamentSystem */
|
||||
private $System;
|
||||
|
||||
/** @var string */
|
||||
private $FirstPeriod;
|
||||
|
||||
/** @var string */
|
||||
private $SecondPeriod;
|
||||
|
||||
/** @var string */
|
||||
private $Federation;
|
||||
|
||||
/** @var Player[] */
|
||||
private $Players = [];
|
||||
|
||||
/** @var int */
|
||||
private $Year;
|
||||
|
||||
/** @var Pairing[] */
|
||||
private $Pairings = [];
|
||||
|
||||
/** @var Tiebreak[] */
|
||||
private $Tiebreaks = [];
|
||||
|
||||
/** @var string */
|
||||
private $PriorityElo = 'Fide';
|
||||
|
||||
/** @var string */
|
||||
private $PriorityId = 'Nation';
|
||||
|
||||
/**
|
||||
* Gets a player by its ID
|
||||
*
|
||||
@ -357,7 +445,751 @@ class Tournament extends Tiebreaks
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getParticipants(): int {
|
||||
public function getParticipants(): int
|
||||
{
|
||||
return count($this->getPlayers());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateKeizer(Player $player): ?float
|
||||
{
|
||||
return $player->getBinaryData('ScoreAmerican');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateAmerican(Player $player): ?float
|
||||
{
|
||||
return $player->getBinaryData('ScoreAmerican');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculatePoints(Player $player): ?float
|
||||
{
|
||||
return $player->getPoints();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateBaumbach(Player $player): ?float
|
||||
{
|
||||
$totalwins = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$totalwins++;
|
||||
}
|
||||
}
|
||||
return $totalwins;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateBlackPlayed(Player $player): ?float
|
||||
{
|
||||
$totalwins = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getColor(), Constants::Black) !== false) {
|
||||
$totalwins++;
|
||||
}
|
||||
}
|
||||
return $totalwins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateBlackWin(Player $player): ?float
|
||||
{
|
||||
$totalwins = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getColor(), Constants::Black) !== false && array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$totalwins++;
|
||||
}
|
||||
}
|
||||
return $totalwins;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param array $opponents
|
||||
* @param int $key
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateMutualResult(Player $player, array $opponents, int $key): ?float
|
||||
{
|
||||
$interestingplayers = $opponents;
|
||||
if ($key != 0) {
|
||||
$interestingplayers = [];
|
||||
$playerstiebreaks = $player->getTiebreaks();
|
||||
array_splice($playerstiebreaks, $key);
|
||||
foreach ($opponents as $opponent) {
|
||||
$opponenttiebreaks = $opponent->getTiebreaks();
|
||||
array_splice($opponenttiebreaks, $key);
|
||||
if (($playerstiebreaks == $opponenttiebreaks) && ($player != $opponent)) {
|
||||
$interestingplayers[] = $opponent;
|
||||
}
|
||||
}
|
||||
}
|
||||
$points = 0;
|
||||
$totalmatches = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
if (array_search($pairing->getOpponent(), $interestingplayers) !== false) {
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$points = $points + 1;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$points = $points + 0.5;
|
||||
}
|
||||
$totalmatches++;
|
||||
}
|
||||
}
|
||||
if ($totalmatches != count($interestingplayers)) {
|
||||
$points = null;
|
||||
}
|
||||
return $points;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param int $cut
|
||||
* @return float
|
||||
*/
|
||||
private function calculateAverageRating(Player $player, string $type, int $cut = 0): ?float
|
||||
{
|
||||
$pairings = $player->getPairings();
|
||||
$allratings = [];
|
||||
foreach ($pairings as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
|
||||
$toadd = $pairing->getOpponent()->getElo($type);
|
||||
if ($toadd != 0) {
|
||||
$allratings[] = $toadd;
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($allratings);
|
||||
$allratings = array_slice($allratings, $cut);
|
||||
return round(array_sum($allratings) / count($allratings));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param int $cut
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateAveragePerformance(Player $player, string $type, int $cut = 0): ?float
|
||||
{
|
||||
$pairings = $player->getPairings();
|
||||
$allratings = [];
|
||||
foreach ($pairings as $pairing) {
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) === false) {
|
||||
$toadd = $pairing->getOpponent()->getPerformance($type, $this->getNonRatedElo());
|
||||
if ($toadd != 0) {
|
||||
$allratings[] = $toadd;
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($allratings);
|
||||
$allratings = array_slice($allratings, $cut);
|
||||
return round(array_sum($allratings) / count($allratings));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param int $cut
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateKoya(Player $player, int $cut = 50): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $plkey => $plpairing) {
|
||||
if (($plpairing->getOpponent()->getPoints() / count($plpairing->getOpponent()->getPairings()) * 100) >= $cut) {
|
||||
if (array_search($plpairing->getResult(), Constants::Won) !== false) {
|
||||
$tiebreak += 1;
|
||||
} elseif (array_search($plpairing->getResult(), Constants::Draw) !== false) {
|
||||
$tiebreak += 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tiebreak;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param int $cutlowest
|
||||
* @param int $cuthighest
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateBuchholz(Player $player, int $cutlowest = 0, int $cuthighest = 0): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
$intpairings = $player->getPairings();
|
||||
|
||||
usort($intpairings, function ($a, $b) {
|
||||
if (is_null($a->getOpponent())) {
|
||||
return -1;
|
||||
}
|
||||
if (is_null($b->getOpponent())) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($b->getOpponent()->getPoints() == $a->getOpponent()->getPoints()) {
|
||||
return 0;
|
||||
}
|
||||
return ($a->getOpponent()->getPoints() > $b->getOpponent()->getPoints()) ? 1 : -1;
|
||||
});
|
||||
|
||||
$intpairings = array_slice($intpairings, $cutlowest);
|
||||
$intpairings = array_slice($intpairings, 0 - $cuthighest);
|
||||
|
||||
foreach ($intpairings as $intkey => $intpairing) {
|
||||
if (!is_null($intpairing->getOpponent())) {
|
||||
$tiebreak += $intpairing->getOpponent()->getPoints();
|
||||
}
|
||||
}
|
||||
return $tiebreak;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateSonneborn(Player $player): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $key => $pairing) {
|
||||
if ($pairing->getOpponent()) {
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$tiebreak += $pairing->getOpponent()->getPoints();
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$tiebreak += $pairing->getOpponent()->getPoints() / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tiebreak;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateSoccerKashdan(Player $player): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
$toadd = 0;
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$toadd = 3;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$toadd = 1;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Lost) !== false) {
|
||||
$toadd = 0;
|
||||
}
|
||||
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) !== false) {
|
||||
$toadd = -1;
|
||||
}
|
||||
$tiebreak += $toadd;
|
||||
}
|
||||
return $tiebreak; // - $player->getNoOfWins();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateKashdan(Player $player): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
$toadd = 0;
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$toadd = 4;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$toadd = 2;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Lost) !== false) {
|
||||
$toadd = 1;
|
||||
}
|
||||
|
||||
if (array_search($pairing->getResult(), Constants::NotPlayed) !== false) {
|
||||
$toadd = 0;
|
||||
}
|
||||
$tiebreak += $toadd;
|
||||
}
|
||||
return $tiebreak; // - $player->getNoOfWins();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @return float|null
|
||||
*/
|
||||
private function calculateCumulative(Player $player): ?float
|
||||
{
|
||||
$tiebreak = 0;
|
||||
$score = [];
|
||||
foreach ($player->getPairings() as $pairing) {
|
||||
$toadd = 0;
|
||||
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||
$toadd = 1;
|
||||
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
|
||||
$toadd = 0.5;
|
||||
}
|
||||
$tiebreak += $toadd;
|
||||
$score[] = $tiebreak;
|
||||
}
|
||||
return array_sum($score);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->Name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Name
|
||||
* @return \JeroenED\Libpairtwo\Models\Tournament
|
||||
*/
|
||||
public function setName(string $Name): Tournament
|
||||
{
|
||||
$this->Name = $Name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrganiser(): string
|
||||
{
|
||||
return $this->Organiser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Organiser
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setOrganiser(string $Organiser): Tournament
|
||||
{
|
||||
$this->Organiser = $Organiser;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOrganiserClubNo(): int
|
||||
{
|
||||
return $this->OrganiserClubNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $OrganiserClubNo
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setOrganiserClubNo(int $OrganiserClubNo): Tournament
|
||||
{
|
||||
$this->OrganiserClubNo = $OrganiserClubNo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrganiserClub(): string
|
||||
{
|
||||
return $this->OrganiserClub;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $OrganiserClub
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setOrganiserClub(string $OrganiserClub): Tournament
|
||||
{
|
||||
$this->OrganiserClub = $OrganiserClub;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrganiserPlace(): string
|
||||
{
|
||||
return $this->OrganiserPlace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $OrganiserPlace
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setOrganiserPlace(string $OrganiserPlace): Tournament
|
||||
{
|
||||
$this->OrganiserPlace = $OrganiserPlace;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrganiserCountry(): string
|
||||
{
|
||||
return $this->OrganiserCountry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $OrganiserCountry
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setOrganiserCountry(string $OrganiserCountry): Tournament
|
||||
{
|
||||
$this->OrganiserCountry = $OrganiserCountry;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFideHomol(): int
|
||||
{
|
||||
return $this->FideHomol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $FideHomol
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setFideHomol(int $FideHomol): Tournament
|
||||
{
|
||||
$this->FideHomol = $FideHomol;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getStartDate(): DateTime
|
||||
{
|
||||
return $this->StartDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $StartDate
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setStartDate(DateTime $StartDate): Tournament
|
||||
{
|
||||
$this->StartDate = $StartDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getEndDate(): DateTime
|
||||
{
|
||||
return $this->EndDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $EndDate
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setEndDate(DateTime $EndDate): Tournament
|
||||
{
|
||||
$this->EndDate = $EndDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArbiter(): string
|
||||
{
|
||||
return $this->Arbiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Arbiter
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setArbiter(string $Arbiter): Tournament
|
||||
{
|
||||
$this->Arbiter = $Arbiter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNoOfRounds(): int
|
||||
{
|
||||
return $this->NoOfRounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $NoOfRounds
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setNoOfRounds(int $NoOfRounds): Tournament
|
||||
{
|
||||
$this->NoOfRounds = $NoOfRounds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Round[]
|
||||
*/
|
||||
public function getRounds(): array
|
||||
{
|
||||
return $this->Rounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Round[] $Rounds
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setRounds(array $Rounds): Tournament
|
||||
{
|
||||
$this->Rounds = $Rounds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTempo(): string
|
||||
{
|
||||
return $this->Tempo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Tempo
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setTempo(string $Tempo): Tournament
|
||||
{
|
||||
$this->Tempo = $Tempo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNonRatedElo(): int
|
||||
{
|
||||
return $this->NonRatedElo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $NonRatedElo
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setNonRatedElo(int $NonRatedElo): Tournament
|
||||
{
|
||||
$this->NonRatedElo = $NonRatedElo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TournamentSystem
|
||||
*/
|
||||
public function getSystem(): TournamentSystem
|
||||
{
|
||||
return $this->System;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TournamentSystem $System
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setSystem(TournamentSystem $System): Tournament
|
||||
{
|
||||
$this->System = $System;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstPeriod(): string
|
||||
{
|
||||
return $this->FirstPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $FirstPeriod
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setFirstPeriod(string $FirstPeriod): Tournament
|
||||
{
|
||||
$this->FirstPeriod = $FirstPeriod;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSecondPeriod(): string
|
||||
{
|
||||
return $this->SecondPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $SecondPeriod
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setSecondPeriod(string $SecondPeriod): Tournament
|
||||
{
|
||||
$this->SecondPeriod = $SecondPeriod;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFederation(): string
|
||||
{
|
||||
return $this->Federation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Federation
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setFederation(string $Federation): Tournament
|
||||
{
|
||||
$this->Federation = $Federation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getPlayers(): array
|
||||
{
|
||||
return $this->Players;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player[] $Players
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setPlayers(array $Players): Tournament
|
||||
{
|
||||
$this->Players = $Players;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getYear(): int
|
||||
{
|
||||
return $this->Year;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $Year
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setYear(int $Year): Tournament
|
||||
{
|
||||
$this->Year = $Year;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Pairing[]
|
||||
*/
|
||||
public function getPairings(): array
|
||||
{
|
||||
return $this->Pairings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pairing[] $Pairings
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setPairings(array $Pairings): Tournament
|
||||
{
|
||||
$this->Pairings = $Pairings;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Tiebreak[]
|
||||
*/
|
||||
public function getTiebreaks(): array
|
||||
{
|
||||
return $this->Tiebreaks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tiebreak[] $Tiebreaks
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setTiebreaks(array $Tiebreaks): Tournament
|
||||
{
|
||||
$this->Tiebreaks = $Tiebreaks;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPriorityElo(): string
|
||||
{
|
||||
return $this->PriorityElo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $PriorityElo
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setPriorityElo(string $PriorityElo): Tournament
|
||||
{
|
||||
$this->PriorityElo = $PriorityElo;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPriorityId(): string
|
||||
{
|
||||
return $this->PriorityId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $PriorityId
|
||||
* @return Tournament
|
||||
*/
|
||||
public function setPriorityId(string $PriorityId): Tournament
|
||||
{
|
||||
$this->PriorityId = $PriorityId;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user