mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-21 22:17:41 +01:00
Moved tiebreaks to own class
This commit is contained in:
parent
74688ac8b8
commit
865893b30f
45
src/Tiebreaks.php
Normal file
45
src/Tiebreaks.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use JeroenED\Libpairtwo\Models\Tournament;
|
||||
|
||||
abstract class Tiebreaks extends Tournament
|
||||
{
|
||||
/**
|
||||
* @param int $key
|
||||
*/
|
||||
protected function calculateKeizer(int $key)
|
||||
{
|
||||
foreach ($this->getPlayers() as $player) {
|
||||
$currentTiebreaks = $player->getTiebreaks();
|
||||
$currentTiebreaks[$key] = $player->getBinaryData('ScoreAmerican');
|
||||
$player->setTiebreaks($currentTiebreaks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
*/
|
||||
protected function calculateAmerican(int $key)
|
||||
{
|
||||
foreach ($this->getPlayers() as $player) {
|
||||
$currentTiebreaks = $player->getTiebreaks();
|
||||
$currentTiebreaks[$key] = $player->getBinaryData('ScoreAmerican');
|
||||
$player->setTiebreaks($currentTiebreaks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
*/
|
||||
protected function calculatePoints(int $key)
|
||||
{
|
||||
foreach ($this->getPlayers() as $player) {
|
||||
$currentTiebreaks = $player->getTiebreaks();
|
||||
$currentTiebreaks[$key] = $player->getBinaryData('Points');
|
||||
$player->setTiebreaks($currentTiebreaks);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,10 +9,9 @@
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Tiebreak;
|
||||
use JeroenED\Libpairtwo\Models\Tournament as TournamentModel;
|
||||
use JeroenED\Libpairtwo\Enums\Color;
|
||||
|
||||
class Tournament extends TournamentModel
|
||||
class Tournament extends Tiebreaks
|
||||
{
|
||||
/**
|
||||
* Gets a player by its ID
|
||||
@ -246,40 +245,4 @@ class Tournament extends TournamentModel
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
*/
|
||||
private function calculateKeizer(int $key)
|
||||
{
|
||||
foreach ($this->getPlayers() as $player) {
|
||||
$currentTiebreaks = $player->getTiebreaks();
|
||||
$currentTiebreaks[$key] = $player->getBinaryData('ScoreAmerican');
|
||||
$player->setTiebreaks($currentTiebreaks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
*/
|
||||
private function calculateAmerican(int $key)
|
||||
{
|
||||
foreach ($this->getPlayers() as $player) {
|
||||
$currentTiebreaks = $player->getTiebreaks();
|
||||
$currentTiebreaks[$key] = $player->getBinaryData('ScoreAmerican');
|
||||
$player->setTiebreaks($currentTiebreaks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
*/
|
||||
private function calculatePoints(int $key)
|
||||
{
|
||||
foreach ($this->getPlayers() as $player) {
|
||||
$currentTiebreaks = $player->getTiebreaks();
|
||||
$currentTiebreaks[$key] = $player->getBinaryData('Points');
|
||||
$player->setTiebreaks($currentTiebreaks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user