mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-23 04:40:59 +01:00
Compare commits
1 Commits
5a1187a47a
...
31bd9e8a53
Author | SHA1 | Date | |
---|---|---|---|
|
31bd9e8a53 |
@ -234,9 +234,7 @@ class Player
|
||||
foreach ($this->Pairings as $key => $pairing) {
|
||||
if ($key < $round || $round == -1) {
|
||||
if ($pairing->Result == Result::WON_BYE) {
|
||||
$points += (isset($custompoints[ 'bye' ])) ? $custompoints[ 'bye' ] : 1;
|
||||
} else if ($pairing->Result == Result::ABSENT) {
|
||||
$points += (isset($custompoints[ 'absent' ])) ? $custompoints[ 'absent' ] : 0;
|
||||
$points += (isset($this->CustomPoints[ 'bye' ])) ? $custompoints[ 'bye' ] : 1;
|
||||
} elseif (array_search($pairing->Result, Constants::WON) !== false) {
|
||||
$points += (isset($custompoints[ 'win' ])) ? $custompoints[ 'win' ] : 1;
|
||||
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||
@ -301,9 +299,9 @@ class Player
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getElo(string $type): ?int
|
||||
public function getElo(string $type): int
|
||||
{
|
||||
return isset($this->Elos[ $type ]) ? $this->Elos[ $type ] : null;
|
||||
return $this->Elos[ $type ];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,17 +199,13 @@ class Swar5 implements ReaderInterface
|
||||
*
|
||||
* @throws IncompatibleReaderException
|
||||
*/
|
||||
public function read(string $filename, string $compatversion = ''): void
|
||||
public function read(string $filename): void
|
||||
{
|
||||
$swshandle = fopen($filename, 'rb');
|
||||
|
||||
$this->Release = $this->readData('String', $swshandle);
|
||||
|
||||
if($compatversion != '') {
|
||||
$this->Release == $compatversion;
|
||||
}
|
||||
if (array_search(substr($this->Release, 0, 3), self::COMPATIBLE_VERSIONS) === false) {
|
||||
throw new IncompatibleReaderException("This file was not created with Swar 5");
|
||||
throw new IncompatibleReaderException("This file was not created with Swar 4");
|
||||
}
|
||||
|
||||
$this->Tournament = new Tournament();
|
||||
@ -246,42 +242,30 @@ 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 4:
|
||||
case 5:
|
||||
case 6:
|
||||
$system = TournamentSystem::CLOSED;
|
||||
break;
|
||||
case 7:
|
||||
case 8:
|
||||
$system = TournamentSystem::AMERICAN;
|
||||
break;
|
||||
case 3:
|
||||
$applycustompoints = true;
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
default:
|
||||
$system = TournamentSystem::SWISS;
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
$system = TournamentSystem::CLOSED;
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
$system = TournamentSystem::AMERICAN;
|
||||
break;
|
||||
}
|
||||
$this->Tournament->System = new TournamentSystem($system);
|
||||
|
||||
@ -290,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->CustomPoints['win'] = $this->readData('Int', $swshandle) / 4;
|
||||
$this->Tournament->CustomPoints['draw'] = $this->readData('Int', $swshandle) / 4;
|
||||
$this->Tournament->CustomPoints['loss'] = $this->readData('Int', $swshandle) / 4;
|
||||
$this->Tournament->CustomPoints['bye'] = $this->readData('Int', $swshandle) / 4;
|
||||
$this->Tournament->CustomPoints['absent'] = $this->readData('Int', $swshandle) / 4;
|
||||
$this->Tournament->EloUsed = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->TournoiStd = $this->readData('Int', $swshandle);
|
||||
$this->Tournament->TbPersonel = $this->readData('Int', $swshandle);
|
||||
@ -441,7 +424,6 @@ class Swar5 implements ReaderInterface
|
||||
$pt = 0;
|
||||
for ($i = 0; $i < $this->Tournament->NumberOfPlayers; $i++) {
|
||||
$player = new Player();
|
||||
|
||||
$player->Classement = $this->readData('Int', $swshandle);
|
||||
$player->Name = $this->readData('String', $swshandle);
|
||||
$inscriptionNos[ $this->readData('Int', $swshandle) ] = $i;
|
||||
@ -516,8 +498,7 @@ class Swar5 implements ReaderInterface
|
||||
$player->Tiebreak = $tiebreaks;
|
||||
$player->Performance = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
||||
$player->Absent = $this->readData('Int', $swshandle);
|
||||
$player->AbsentRounds = $this->readData('Int', $swshandle);
|
||||
if(version_compare($this->Release, '5.53', "<=")) $player->Paid = $this->readData('Int', $swshandle);
|
||||
$player->AbsentRounds = $this->readData('String', $swshandle);
|
||||
$player->ExtraPoints = $this->readData('Int', $swshandle);
|
||||
$player->SpecialPoints = $this->readData('Int', $swshandle);
|
||||
$player->AllocatedRounds = $this->readData('Int', $swshandle);
|
||||
@ -537,7 +518,6 @@ class Swar5 implements ReaderInterface
|
||||
|
||||
$pt++;
|
||||
}
|
||||
|
||||
$this->Tournament->Pairing = $pairing;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ namespace JeroenED\Libpairtwo;
|
||||
use Closure;
|
||||
use DateTime;
|
||||
use JeroenED\Libpairtwo\Enums\Color;
|
||||
use JeroenED\Libpairtwo\Enums\Result;
|
||||
use JeroenED\Libpairtwo\Enums\Tiebreak;
|
||||
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
||||
|
||||
@ -729,7 +728,7 @@ class Tournament
|
||||
$tiebreak += $pairing->Opponent->calculatePointsForTiebreaks() / 2;
|
||||
}
|
||||
}
|
||||
if ($pairing->Result == Result::WON_BYE) {
|
||||
if (array_search($pairing->Result, Constants::NOTPLAYED) !== false) {
|
||||
$tiebreak += $player->calculatePointsForVirtualPlayer($key);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user