mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-22 04:11:22 +01:00
Implemented tiebreaks
This commit is contained in:
parent
5dbdf92a97
commit
3ea12b0377
@ -33,6 +33,8 @@ class Tiebreak extends Enum
|
||||
const Buchholz = "Buchholz";
|
||||
const BuchholzMed = "Buchholz Median";
|
||||
const BuchholzCut = "Buchholz Cut";
|
||||
const BuchholzMed2 = "Buchholz Median 2";
|
||||
const BuchholzCut2 = "Buchholz Cut 2";
|
||||
const Sonneborn = "Sonneborn-Berger";
|
||||
const Kashdan = "Kashdan";
|
||||
const SoccerKashdan = "Soccer Kashdan";
|
||||
|
@ -15,6 +15,7 @@ namespace JeroenED\Libpairtwo\Readers;
|
||||
|
||||
use DateTime;
|
||||
use JeroenED\Libpairtwo\Enums\Color;
|
||||
use JeroenED\Libpairtwo\Enums\Tiebreak;
|
||||
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
||||
use JeroenED\Libpairtwo\Exceptions\IncompatibleReaderException;
|
||||
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
|
||||
@ -234,9 +235,62 @@ class Swar4 implements ReaderInterface
|
||||
|
||||
$this->getTournament()->setBinaryData('[TIE_BREAK]', $this->readData('String', $swshandle));
|
||||
|
||||
$tiebreaks = [];
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$this->getTournament()->setBinaryData('Tiebreak_' . $i, $this->readData('Int', $swshandle));
|
||||
switch($this->readData('Int', $swshandle)) {
|
||||
case 0:
|
||||
default:
|
||||
$tiebreak = Tiebreak::None;
|
||||
break;
|
||||
case 1:
|
||||
$tiebreak = Tiebreak::Buchholz;
|
||||
break;
|
||||
case 2:
|
||||
$tiebreak = Tiebreak::BuchholzMed;
|
||||
break;
|
||||
case 3:
|
||||
$tiebreak = Tiebreak::BuchholzMed2;
|
||||
break;
|
||||
case 4:
|
||||
$tiebreak = Tiebreak::BuchholzCut;
|
||||
break;
|
||||
case 5:
|
||||
$tiebreak = Tiebreak::BuchholzCut2;
|
||||
break;
|
||||
case 6:
|
||||
$tiebreak = Tiebreak::Sonneborn;
|
||||
break;
|
||||
case 7:
|
||||
$tiebreak = Tiebreak::Cumulative;
|
||||
break;
|
||||
case 8:
|
||||
$tiebreak = Tiebreak::Between;
|
||||
break;
|
||||
case 9:
|
||||
$tiebreak = Tiebreak::Koya;
|
||||
break;
|
||||
case 10:
|
||||
$tiebreak = Tiebreak::Baumbach;
|
||||
break;
|
||||
case 11:
|
||||
$tiebreak = Tiebreak::AveragePerformance;
|
||||
break;
|
||||
case 12:
|
||||
$tiebreak = Tiebreak::Aro;
|
||||
break;
|
||||
case 13:
|
||||
$tiebreak = Tiebreak::AroCut;
|
||||
break;
|
||||
case 14:
|
||||
$tiebreak = Tiebreak::BlackPlayed;
|
||||
break;
|
||||
case 15:
|
||||
$tiebreak = Tiebreak::BlackWin;
|
||||
break;
|
||||
}
|
||||
$tiebreaks[] = new Tiebreak($tiebreak);
|
||||
}
|
||||
$this->getTournament()->setTiebreaks($tiebreaks);
|
||||
|
||||
$this->getTournament()->setBinaryData('[EXCLUSION]', $this->readData('String', $swshandle));
|
||||
$this->getTournament()->setBinaryData('ExclusionType', $this->readData('Int', $swshandle));
|
||||
|
@ -421,6 +421,12 @@ class Tournament
|
||||
case Tiebreak::BuchholzMed:
|
||||
return $this->calculateBuchholz($player, 1, 1);
|
||||
break;
|
||||
case Tiebreak::BuchholzCut2:
|
||||
return $this->calculateBuchholz($player, 2);
|
||||
break;
|
||||
case Tiebreak::BuchholzMed2:
|
||||
return $this->calculateBuchholz($player, 2, 2);
|
||||
break;
|
||||
case Tiebreak::Sonneborn:
|
||||
return $this->calculateSonneborn($player);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user