mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-24 13:20:58 +01:00
Compare commits
No commits in common. "c49ea32f08283afbb92563a5fd376522cf443a8e" and "c3b2e840f74009c44ed7c2713fd311c072333b7a" have entirely different histories.
c49ea32f08
...
c3b2e840f7
@ -15,7 +15,6 @@ namespace JeroenED\Libpairtwo;
|
||||
|
||||
use DateTime;
|
||||
use JeroenED\Libpairtwo\Enums\Gender;
|
||||
use JeroenED\Libpairtwo\Enums\Result;
|
||||
use JeroenED\Libpairtwo\Enums\Title;
|
||||
|
||||
/**
|
||||
@ -228,19 +227,15 @@ class Player
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function calculatePoints(int $round = -1, array $custompoints = []): float
|
||||
public function calculatePoints(int $round = -1): float
|
||||
{
|
||||
$points = 0;
|
||||
foreach ($this->Pairings as $key => $pairing) {
|
||||
if ($key < $round || $round == -1) {
|
||||
if ($pairing->Result == Result::WON_BYE) {
|
||||
$points += (isset($this->CustomPoints[ 'bye' ])) ? $custompoints[ 'bye' ] : 1;
|
||||
} elseif (array_search($pairing->Result, Constants::WON) !== false) {
|
||||
$points += (isset($custompoints[ 'win' ])) ? $custompoints[ 'win' ] : 1;
|
||||
if (array_search($pairing->Result, Constants::WON) !== false) {
|
||||
$points = $points + 1;
|
||||
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||
$points += (isset($custompoints[ 'draw' ])) ? $custompoints[ 'draw' ] : 0.5;
|
||||
} elseif (array_search($pairing->Result, Constants::LOST) !== false) {
|
||||
$points += (isset($custompoints[ 'loss' ])) ? $custompoints[ 'loss' ] : 0;
|
||||
$points = $points + 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,34 +242,19 @@ class Swar5 implements ReaderInterface
|
||||
|
||||
$this->Tournament->FideHomol = $this->readData('Int', $swshandle);
|
||||
|
||||
if (version_compare($this->Release, '5.24', ">=")) {
|
||||
$this->Tournament->FideId = $this->readData('Int', $swshandle);
|
||||
} else {
|
||||
for ($i = 0; $i <= 15; $i++) {
|
||||
// First round
|
||||
$this->readData('Int', $swshandle);
|
||||
//last round
|
||||
$this->readData('Int', $swshandle);
|
||||
//fide ID
|
||||
$this->readData('Int', $swshandle);
|
||||
}
|
||||
}
|
||||
$this->Tournament->FideId = $this->readData('String', $swshandle);
|
||||
$this->Tournament->FideArbitre1 = $this->readData('String', $swshandle);
|
||||
$this->Tournament->FideArbitre2 = $this->readData('String', $swshandle);
|
||||
$this->Tournament->FideEmail = $this->readData('String', $swshandle);
|
||||
$this->Tournament->FideRemarques = $this->readData('String', $swshandle);
|
||||
|
||||
$applycustompoints = false;
|
||||
switch ($this->readData('Int', $swshandle)) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
default:
|
||||
$system = TournamentSystem::SWISS;
|
||||
break;
|
||||
case 4:
|
||||
$applycustompoints = true;
|
||||
default:
|
||||
$system = TournamentSystem::SWISS;
|
||||
break;
|
||||
case 5:
|
||||
@ -289,12 +274,11 @@ class Swar5 implements ReaderInterface
|
||||
$this->Tournament->SW_AmerPresence = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->Plusieurs = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->FirstTable = $this->readData('Int', $swshandle);
|
||||
$custompoints['win'] = $this->readData('Int', $swshandle) / 4;
|
||||
$custompoints['draw'] = $this->readData('Int', $swshandle) / 4;
|
||||
$custompoints['loss'] = $this->readData('Int', $swshandle) / 4;
|
||||
$custompoints['bye'] = $this->readData('Int', $swshandle) / 4;
|
||||
$custompoints['absent'] = $this->readData('Int', $swshandle) / 4;
|
||||
if($applycustompoints) $this->Tournament->CustomPoints = $custompoints;
|
||||
$this->Tournament->SW321_Win = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->SW321_Nul = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->SW321_Los = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->SW321_Bye = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->SW321_Pre = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->EloUsed = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->TournoiStd = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->TbPersonel = $this->readData('Int', $swshandle);
|
||||
|
@ -204,13 +204,6 @@ class Tournament
|
||||
*/
|
||||
public $Tiebreaks = [];
|
||||
|
||||
/**
|
||||
* Custom points for the tournament
|
||||
*
|
||||
* @var float[]
|
||||
*/
|
||||
public $CustomPoints = ['win' => 1, 'draw' => 0.5, 'loss' => 0, 'bye' => 1, 'absent' => 0];
|
||||
|
||||
/**
|
||||
* The year or season the tournament is held or is count for
|
||||
*
|
||||
@ -705,7 +698,7 @@ class Tournament
|
||||
*/
|
||||
private function calculatePoints(Player $player): float
|
||||
{
|
||||
return $player->calculatePoints(-1, $this->CustomPoints);
|
||||
return $player->calculatePoints();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user