mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-22 06:26:57 +01:00
BUGFIX: Tiebreaks were not read in swar-4 reader
This commit is contained in:
parent
3c3b8c8b92
commit
fefb089018
@ -14,7 +14,6 @@ namespace JeroenED\Libpairtwo\Enums;
|
|||||||
|
|
||||||
use MyCLabs\Enum\Enum;
|
use MyCLabs\Enum\Enum;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum Gender
|
* Enum Gender
|
||||||
*
|
*
|
||||||
|
@ -33,6 +33,8 @@ class Tiebreak extends Enum
|
|||||||
const Buchholz = "Buchholz";
|
const Buchholz = "Buchholz";
|
||||||
const BuchholzMed = "Buchholz Median";
|
const BuchholzMed = "Buchholz Median";
|
||||||
const BuchholzCut = "Buchholz Cut";
|
const BuchholzCut = "Buchholz Cut";
|
||||||
|
const BuchholzMed2 = "Buchholz Median 2";
|
||||||
|
const BuchholzCut2 = "Buchholz Cut 2";
|
||||||
const Sonneborn = "Sonneborn-Berger";
|
const Sonneborn = "Sonneborn-Berger";
|
||||||
const Kashdan = "Kashdan";
|
const Kashdan = "Kashdan";
|
||||||
const SoccerKashdan = "Soccer Kashdan";
|
const SoccerKashdan = "Soccer Kashdan";
|
||||||
|
@ -15,6 +15,7 @@ namespace JeroenED\Libpairtwo\Readers;
|
|||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use JeroenED\Libpairtwo\Enums\Color;
|
use JeroenED\Libpairtwo\Enums\Color;
|
||||||
|
use JeroenED\Libpairtwo\Enums\Tiebreak;
|
||||||
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
||||||
use JeroenED\Libpairtwo\Exceptions\IncompatibleReaderException;
|
use JeroenED\Libpairtwo\Exceptions\IncompatibleReaderException;
|
||||||
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
|
use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
|
||||||
@ -234,9 +235,62 @@ class Swar4 implements ReaderInterface
|
|||||||
|
|
||||||
$this->getTournament()->setBinaryData('[TIE_BREAK]', $this->readData('String', $swshandle));
|
$this->getTournament()->setBinaryData('[TIE_BREAK]', $this->readData('String', $swshandle));
|
||||||
|
|
||||||
|
$tiebreaks = [];
|
||||||
for ($i = 0; $i < 5; $i++) {
|
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('[EXCLUSION]', $this->readData('String', $swshandle));
|
||||||
$this->getTournament()->setBinaryData('ExclusionType', $this->readData('Int', $swshandle));
|
$this->getTournament()->setBinaryData('ExclusionType', $this->readData('Int', $swshandle));
|
||||||
@ -372,7 +426,7 @@ class Swar4 implements ReaderInterface
|
|||||||
|
|
||||||
$pairing->setPlayer($this->getTournament()->getPlayerById($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_player')));
|
$pairing->setPlayer($this->getTournament()->getPlayerById($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_player')));
|
||||||
$pairing->setRound($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_round'));
|
$pairing->setRound($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_round'));
|
||||||
if($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_opponent') != 4294967294) {
|
if ($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_opponent') != 4294967294) {
|
||||||
$pairing->setOpponent($this->getTournament()->getPlayerById($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_opponent')));
|
$pairing->setOpponent($this->getTournament()->getPlayerById($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_opponent')));
|
||||||
}
|
}
|
||||||
//echo $ptn . ' ' . $this->getTournament()->getBinaryData('Pairing_' . $ptn . '_round') . ' ' . $pairing->getPlayer()->getName() . ' - ' . $opponent . ' ' . $this->getTournament()->getBinaryData('Pairing_' . $ptn . '_result') . PHP_EOL;
|
//echo $ptn . ' ' . $this->getTournament()->getBinaryData('Pairing_' . $ptn . '_round') . ' ' . $pairing->getPlayer()->getName() . ' - ' . $opponent . ' ' . $this->getTournament()->getBinaryData('Pairing_' . $ptn . '_result') . PHP_EOL;
|
||||||
@ -423,6 +477,7 @@ class Swar4 implements ReaderInterface
|
|||||||
}
|
}
|
||||||
fclose($swshandle);
|
fclose($swshandle);
|
||||||
$this->getTournament()->pairingsToRounds();
|
$this->getTournament()->pairingsToRounds();
|
||||||
|
$this->addTiebreaks();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -565,4 +620,24 @@ class Swar4 implements ReaderInterface
|
|||||||
return DateTime::createFromFormat('Ymd', $string);
|
return DateTime::createFromFormat('Ymd', $string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
private function addTiebreaks(): Swar4
|
||||||
|
{
|
||||||
|
switch ($this->getTournament()->getSystem()) {
|
||||||
|
case TournamentSystem::American:
|
||||||
|
$firstElement = new Tiebreak(Tiebreak::American);
|
||||||
|
break;
|
||||||
|
case TournamentSystem::Closed:
|
||||||
|
case TournamentSystem::Swiss:
|
||||||
|
default:
|
||||||
|
$firstElement = new Tiebreak(Tiebreak::Points);
|
||||||
|
}
|
||||||
|
$tiebreaks = $this->getTournament()->getTiebreaks();
|
||||||
|
array_unshift($tiebreaks, $firstElement);
|
||||||
|
$this->getTournament()->setTiebreaks($tiebreaks);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,6 +421,12 @@ class Tournament
|
|||||||
case Tiebreak::BuchholzMed:
|
case Tiebreak::BuchholzMed:
|
||||||
return $this->calculateBuchholz($player, 1, 1);
|
return $this->calculateBuchholz($player, 1, 1);
|
||||||
break;
|
break;
|
||||||
|
case Tiebreak::BuchholzCut2:
|
||||||
|
return $this->calculateBuchholz($player, 2);
|
||||||
|
break;
|
||||||
|
case Tiebreak::BuchholzMed2:
|
||||||
|
return $this->calculateBuchholz($player, 2, 2);
|
||||||
|
break;
|
||||||
case Tiebreak::Sonneborn:
|
case Tiebreak::Sonneborn:
|
||||||
return $this->calculateSonneborn($player);
|
return $this->calculateSonneborn($player);
|
||||||
break;
|
break;
|
||||||
@ -428,7 +434,7 @@ class Tournament
|
|||||||
return $this->calculateKashdan($player, ["Won" => 4, "Draw" => 2, "Lost" => 1, "NotPlayed" => 0]);
|
return $this->calculateKashdan($player, ["Won" => 4, "Draw" => 2, "Lost" => 1, "NotPlayed" => 0]);
|
||||||
break;
|
break;
|
||||||
case Tiebreak::SoccerKashdan:
|
case Tiebreak::SoccerKashdan:
|
||||||
return $this->calculateKashdan($player, ["Won" => 3, "Draw" => 1, "Lost" => 0, "NotPlayed" => -1]);
|
return $this->calculateKashdan($player, ["Won" => 3, "Draw" => 1, "Lost" => 0, "NotPlayed" => -1]);
|
||||||
break;
|
break;
|
||||||
case Tiebreak::Cumulative:
|
case Tiebreak::Cumulative:
|
||||||
return $this->calculateCumulative($player);
|
return $this->calculateCumulative($player);
|
||||||
|
Loading…
Reference in New Issue
Block a user