mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-24 13:20:58 +01:00
Compare commits
No commits in common. "2ca18a32712b546a259d0a76211002dcaa48e3e3" and "9c7deea8ca022bdb3a1ad8b7d1def64ef744d7fe" have entirely different histories.
2ca18a3271
...
9c7deea8ca
@ -234,9 +234,7 @@ class Player
|
|||||||
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 ($pairing->Result == Result::WON_BYE) {
|
||||||
$points += (isset($custompoints[ 'bye' ])) ? $custompoints[ 'bye' ] : 1;
|
$points += (isset($this->CustomPoints[ 'bye' ])) ? $custompoints[ 'bye' ] : 1;
|
||||||
} else if ($pairing->Result == Result::ABSENT) {
|
|
||||||
$points += (isset($custompoints[ 'absent' ])) ? $custompoints[ 'absent' ] : 0;
|
|
||||||
} elseif (array_search($pairing->Result, Constants::WON) !== false) {
|
} elseif (array_search($pairing->Result, Constants::WON) !== false) {
|
||||||
$points += (isset($custompoints[ 'win' ])) ? $custompoints[ 'win' ] : 1;
|
$points += (isset($custompoints[ 'win' ])) ? $custompoints[ 'win' ] : 1;
|
||||||
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
|
||||||
@ -301,9 +299,9 @@ class Player
|
|||||||
*
|
*
|
||||||
* @return int
|
* @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
|
* @throws IncompatibleReaderException
|
||||||
*/
|
*/
|
||||||
public function read(string $filename, string $compatversion = ''): void
|
public function read(string $filename): void
|
||||||
{
|
{
|
||||||
$swshandle = fopen($filename, 'rb');
|
$swshandle = fopen($filename, 'rb');
|
||||||
|
|
||||||
$this->Release = $this->readData('String', $swshandle);
|
$this->Release = $this->readData('String', $swshandle);
|
||||||
|
|
||||||
if($compatversion != '') {
|
|
||||||
$this->Release == $compatversion;
|
|
||||||
}
|
|
||||||
if (array_search(substr($this->Release, 0, 3), self::COMPATIBLE_VERSIONS) === false) {
|
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();
|
$this->Tournament = new Tournament();
|
||||||
@ -441,7 +437,6 @@ class Swar5 implements ReaderInterface
|
|||||||
$pt = 0;
|
$pt = 0;
|
||||||
for ($i = 0; $i < $this->Tournament->NumberOfPlayers; $i++) {
|
for ($i = 0; $i < $this->Tournament->NumberOfPlayers; $i++) {
|
||||||
$player = new Player();
|
$player = new Player();
|
||||||
|
|
||||||
$player->Classement = $this->readData('Int', $swshandle);
|
$player->Classement = $this->readData('Int', $swshandle);
|
||||||
$player->Name = $this->readData('String', $swshandle);
|
$player->Name = $this->readData('String', $swshandle);
|
||||||
$inscriptionNos[ $this->readData('Int', $swshandle) ] = $i;
|
$inscriptionNos[ $this->readData('Int', $swshandle) ] = $i;
|
||||||
@ -516,8 +511,7 @@ class Swar5 implements ReaderInterface
|
|||||||
$player->Tiebreak = $tiebreaks;
|
$player->Tiebreak = $tiebreaks;
|
||||||
$player->Performance = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
$player->Performance = $this->readData('Int', $swshandle); // To Calculate by libpairtwo
|
||||||
$player->Absent = $this->readData('Int', $swshandle);
|
$player->Absent = $this->readData('Int', $swshandle);
|
||||||
$player->AbsentRounds = $this->readData('Int', $swshandle);
|
$player->AbsentRounds = $this->readData('String', $swshandle);
|
||||||
if(version_compare($this->Release, '5.53', "<=")) $player->Paid = $this->readData('Int', $swshandle);
|
|
||||||
$player->ExtraPoints = $this->readData('Int', $swshandle);
|
$player->ExtraPoints = $this->readData('Int', $swshandle);
|
||||||
$player->SpecialPoints = $this->readData('Int', $swshandle);
|
$player->SpecialPoints = $this->readData('Int', $swshandle);
|
||||||
$player->AllocatedRounds = $this->readData('Int', $swshandle);
|
$player->AllocatedRounds = $this->readData('Int', $swshandle);
|
||||||
@ -537,7 +531,6 @@ class Swar5 implements ReaderInterface
|
|||||||
|
|
||||||
$pt++;
|
$pt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Tournament->Pairing = $pairing;
|
$this->Tournament->Pairing = $pairing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ namespace JeroenED\Libpairtwo;
|
|||||||
use Closure;
|
use Closure;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use JeroenED\Libpairtwo\Enums\Color;
|
use JeroenED\Libpairtwo\Enums\Color;
|
||||||
use JeroenED\Libpairtwo\Enums\Result;
|
|
||||||
use JeroenED\Libpairtwo\Enums\Tiebreak;
|
use JeroenED\Libpairtwo\Enums\Tiebreak;
|
||||||
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
||||||
|
|
||||||
@ -729,7 +728,7 @@ class Tournament
|
|||||||
$tiebreak += $pairing->Opponent->calculatePointsForTiebreaks() / 2;
|
$tiebreak += $pairing->Opponent->calculatePointsForTiebreaks() / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($pairing->Result == Result::WON_BYE) {
|
if (array_search($pairing->Result, Constants::NOTPLAYED) !== false) {
|
||||||
$tiebreak += $player->calculatePointsForVirtualPlayer($key);
|
$tiebreak += $player->calculatePointsForVirtualPlayer($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user