Swar-4 reader ready for beta-testing

This commit is contained in:
Jeroen De Meerleer 2019-09-25 16:30:19 +02:00
parent 802f0d12c1
commit 5dbdf92a97
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 52 additions and 5 deletions

View File

@ -154,7 +154,26 @@ class Swar4 implements ReaderInterface
$this->getTournament()->setBinaryData('FideEmail', $this->readData('String', $swshandle));
$this->getTournament()->setBinaryData('FideRemarques', $this->readData('String', $swshandle));
$typeIndex = $this->readData('Int', $swshandle);// Tournament System
switch ($this->readData('Int', $swshandle)) {
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->getTournament()->setSystem(new TournamentSystem($system));
$this->getTournament()->setBinaryData('Dummy1', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('Dummy2', $this->readData('Int', $swshandle));
@ -174,7 +193,34 @@ class Swar4 implements ReaderInterface
$this->getTournament()->setBinaryData('ByeValue', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('AbsValue', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('FF_Value', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('Federation', $this->readData('Int', $swshandle));
switch ($this->readData('Int', $swshandle)) {
case 0:
default:
$federation = '';
break;
case 1:
$federation = 'FRBE';
break;
case 2:
$federation = 'KBSB';
break;
case 3:
$federation = 'FEFB';
break;
case 4:
$federation = 'VSF';
break;
case 5:
$federation = 'SVDB';
break;
case 6:
$federation = 'FIDE';
break;
}
$this->getTournament()->setFederation($federation);
$this->getTournament()->setNonRatedElo(0);
$this->getTournament()->setOrganiserClubNo(0);
$this->getTournament()->setBinaryData('[DATES]', $this->readData('String', $swshandle));
$this->getTournament()->setTempo(Self::Tempos[$this->getTournament()->getBinaryData('TournoiStd')][$this->getTournament()->getBinaryData('TempoIndex')]);
@ -305,7 +351,7 @@ class Swar4 implements ReaderInterface
if ($player->getBinaryData('AllocatedRounds') != 0) {
for ($j = 0; $j < $player->getBinaryData('AllocatedRounds'); $j++) {
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_player', $i);
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_round', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_round', $this->readData('Int', $swshandle) - 1);
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_table', $this->readData('Int', $swshandle));
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_opponent', $this->readData('Int', $swshandle) - 1);
$this->getTournament()->setBinaryData('Pairing_' . $pt . '_result', $this->readData('Hex', $swshandle));

View File

@ -33,11 +33,12 @@ $sws->read('../res/testswar.swar');
echo "Release: " . $sws->getRelease() . PHP_EOL;
echo "Name: " . $sws->getTournament()->getName() . PHP_EOL;
echo "Organiser: " . $sws->getTournament()->getOrganiser(). PHP_EOL;
echo "TempoIndex: " . $sws->getTournament()->getBinaryData('TempoIndex') . PHP_EOL;
echo "TempoType: " . $sws->getTournament()->getBinaryData('TournoiStd') . PHP_EOL;
echo "Tempo: " . $sws->getTournament()->getTempo() . PHP_EOL;
echo "Country: " . $sws->getTournament()->getOrganiserCountry() . PHP_EOL;
echo "Place: " . $sws->getTournament()->getOrganiserPlace() . PHP_EOL;
echo "Arbiter: " . $sws->getTournament()->getArbiter() . PHP_EOL;
echo "Rounds: " . $sws->getTournament()->getNoOfRounds() . PHP_EOL;
echo "Participants: " . $sws->getTournament()->getNoOfRounds() . PHP_EOL;
echo "Fidehomol: " . $sws->getTournament()->getFideHomol() . PHP_EOL;
echo "Start-Date: " . $sws->getTournament()->getStartDate()->format('d/m/Y') . PHP_EOL;
echo "End-Date: " . $sws->getTournament()->getEndDate()->format('d/m/Y') . PHP_EOL;