Compare commits

..

No commits in common. "c49ea32f08283afbb92563a5fd376522cf443a8e" and "c3b2e840f74009c44ed7c2713fd311c072333b7a" have entirely different histories.

3 changed files with 12 additions and 40 deletions

View File

@ -15,7 +15,6 @@ namespace JeroenED\Libpairtwo;
use DateTime; use DateTime;
use JeroenED\Libpairtwo\Enums\Gender; use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\Libpairtwo\Enums\Title; use JeroenED\Libpairtwo\Enums\Title;
/** /**
@ -228,19 +227,15 @@ class Player
* *
* @return float * @return float
*/ */
public function calculatePoints(int $round = -1, array $custompoints = []): float public function calculatePoints(int $round = -1): float
{ {
$points = 0; $points = 0;
foreach ($this->Pairings as $key => $pairing) { foreach ($this->Pairings as $key => $pairing) {
if ($key < $round || $round == -1) { if ($key < $round || $round == -1) {
if ($pairing->Result == Result::WON_BYE) { if (array_search($pairing->Result, Constants::WON) !== false) {
$points += (isset($this->CustomPoints[ 'bye' ])) ? $custompoints[ 'bye' ] : 1; $points = $points + 1;
} elseif (array_search($pairing->Result, Constants::WON) !== false) {
$points += (isset($custompoints[ 'win' ])) ? $custompoints[ 'win' ] : 1;
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) { } elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$points += (isset($custompoints[ 'draw' ])) ? $custompoints[ 'draw' ] : 0.5; $points = $points + 0.5;
} elseif (array_search($pairing->Result, Constants::LOST) !== false) {
$points += (isset($custompoints[ 'loss' ])) ? $custompoints[ 'loss' ] : 0;
} }
} }
} }

View File

@ -242,34 +242,19 @@ class Swar5 implements ReaderInterface
$this->Tournament->FideHomol = $this->readData('Int', $swshandle); $this->Tournament->FideHomol = $this->readData('Int', $swshandle);
if (version_compare($this->Release, '5.24', ">=")) { $this->Tournament->FideId = $this->readData('String', $swshandle);
$this->Tournament->FideId = $this->readData('Int', $swshandle);
} else {
for ($i = 0; $i <= 15; $i++) {
// First round
$this->readData('Int', $swshandle);
//last round
$this->readData('Int', $swshandle);
//fide ID
$this->readData('Int', $swshandle);
}
}
$this->Tournament->FideArbitre1 = $this->readData('String', $swshandle); $this->Tournament->FideArbitre1 = $this->readData('String', $swshandle);
$this->Tournament->FideArbitre2 = $this->readData('String', $swshandle); $this->Tournament->FideArbitre2 = $this->readData('String', $swshandle);
$this->Tournament->FideEmail = $this->readData('String', $swshandle); $this->Tournament->FideEmail = $this->readData('String', $swshandle);
$this->Tournament->FideRemarques = $this->readData('String', $swshandle); $this->Tournament->FideRemarques = $this->readData('String', $swshandle);
$applycustompoints = false;
switch ($this->readData('Int', $swshandle)) { switch ($this->readData('Int', $swshandle)) {
case 0: case 0:
case 1: case 1:
case 2: case 2:
case 3: case 3:
default:
$system = TournamentSystem::SWISS;
break;
case 4: case 4:
$applycustompoints = true; default:
$system = TournamentSystem::SWISS; $system = TournamentSystem::SWISS;
break; break;
case 5: case 5:
@ -289,12 +274,11 @@ class Swar5 implements ReaderInterface
$this->Tournament->SW_AmerPresence = $this->readData('Int', $swshandle); $this->Tournament->SW_AmerPresence = $this->readData('Int', $swshandle);
$this->Tournament->Plusieurs = $this->readData('Int', $swshandle); $this->Tournament->Plusieurs = $this->readData('Int', $swshandle);
$this->Tournament->FirstTable = $this->readData('Int', $swshandle); $this->Tournament->FirstTable = $this->readData('Int', $swshandle);
$custompoints['win'] = $this->readData('Int', $swshandle) / 4; $this->Tournament->SW321_Win = $this->readData('Int', $swshandle);
$custompoints['draw'] = $this->readData('Int', $swshandle) / 4; $this->Tournament->SW321_Nul = $this->readData('Int', $swshandle);
$custompoints['loss'] = $this->readData('Int', $swshandle) / 4; $this->Tournament->SW321_Los = $this->readData('Int', $swshandle);
$custompoints['bye'] = $this->readData('Int', $swshandle) / 4; $this->Tournament->SW321_Bye = $this->readData('Int', $swshandle);
$custompoints['absent'] = $this->readData('Int', $swshandle) / 4; $this->Tournament->SW321_Pre = $this->readData('Int', $swshandle);
if($applycustompoints) $this->Tournament->CustomPoints = $custompoints;
$this->Tournament->EloUsed = $this->readData('Int', $swshandle); $this->Tournament->EloUsed = $this->readData('Int', $swshandle);
$this->Tournament->TournoiStd = $this->readData('Int', $swshandle); $this->Tournament->TournoiStd = $this->readData('Int', $swshandle);
$this->Tournament->TbPersonel = $this->readData('Int', $swshandle); $this->Tournament->TbPersonel = $this->readData('Int', $swshandle);

View File

@ -204,13 +204,6 @@ class Tournament
*/ */
public $Tiebreaks = []; 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 * The year or season the tournament is held or is count for
* *
@ -705,7 +698,7 @@ class Tournament
*/ */
private function calculatePoints(Player $player): float private function calculatePoints(Player $player): float
{ {
return $player->calculatePoints(-1, $this->CustomPoints); return $player->calculatePoints();
} }
/** /**