Added some more fields

This commit is contained in:
Jeroen De Meerleer 2019-02-01 15:55:34 +01:00
parent 35f47f268f
commit 17c924b45c
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
3 changed files with 162 additions and 8 deletions

View File

@ -30,6 +30,7 @@ class Player
private $Category;
private $Title;
private $Sex;
private $NumberOfTies;
private $Absent;
/**
@ -294,6 +295,22 @@ class Player
$this->Sex = $Sex;
}
/**
* @return mixed
*/
public function getNumberOfTies()
{
return $this->NumberOfTies;
}
/**
* @param mixed $NumberOfTies
*/
public function setNumberOfTies($NumberOfTies): void
{
$this->NumberOfTies = $NumberOfTies;
}
/**
* @return mixed
*/
@ -309,7 +326,4 @@ class Player
{
$this->Absent = $Absent;
}
}
}

View File

@ -25,6 +25,8 @@
*/
namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Enums\TournamentSystem;
/**
* Description of Sws
@ -51,6 +53,7 @@ class Tournament
private $FirstPeriod;
private $SecondPeriod;
private $Federation;
private $Players;
/**
* @return string
@ -340,5 +343,20 @@ class Tournament
$this->Federation = $Federation;
}
/**
* @return array
*/
public function getPlayers()
{
return $this->Players;
}
/**
* @param array $Players
*/
public function setPlayers($Players): void
{
$this->Players = $Players;
}
}

View File

@ -41,7 +41,6 @@ class Sws extends SwsModel
private const PT_DAYFACTOR = 32;
private const PT_MONTHFACTOR = 16;
private const PT_YEARFACTOR = 512;
private const PT_SYSTEMYEAR = 1900;
private const PT_PASTOFFSET = 117;
@ -226,12 +225,125 @@ class Sws extends SwsModel
$offset += $length;
// Players
$length = 68 * $sws->getBinaryData("NewPlayer");
for ($i = 0; $i < $sws->getBinaryData("NewPlayer"); $i++) {
$player = new Player();
$length = 4;
$player->SetRank(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$sws->setBinaryData("Players($i)_NamePos", self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->SetFideId(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->SetExtraPts(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->SetKbsbElo(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->SetDateOfBirth(self::ReadData('Date', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->setKbsbID(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->setPoints(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->setClubNr(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->setScoreBucholtz(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->setScoreAmerican(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$sws->setBinaryData("Players($i)_HelpValue", self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 4;
$player->setFideElo(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$sws->setBinaryData("Players($i)_NameLength", self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 3;
$player->setNation(self::ReadData('String', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$player->setCategory(self::ReadData('String', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$player->setTitle(new Title(self::ReadData('Int', substr($swscontents, $offset, $length))));
$offset += $length;
$length = 1;
$player->setSex(new Sex(self::ReadData('Int', substr($swscontents, $offset, $length))));
$offset += $length;
$length = 1;
$player->setNumberOfTies(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$player->setAbsent(self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$sws->setBinaryData("Players($i)_ColorDiff", self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$sws->setBinaryData("Players($i)_ColorPref", self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$sws->setBinaryData("Players($i)_Paired", self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$sws->setBinaryData("Players($i)_Float", self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$sws->setBinaryData("Players($i)_FloatPrev", self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$sws->setBinaryData("Players($i)_FloatBefore", self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$length = 1;
$sws->setBinaryData("Players($i)_TieMatch", self::ReadData('Int', substr($swscontents, $offset, $length)));
$offset += $length;
$sws->getTournament()->addPlayer($player);
}
/* $length = 68 * $sws->getBinaryData("NewPlayer");
$sws->setBinaryData("Players", self::ReadData('String', substr($swscontents, $offset, $length)));
$offset += $length;
$offset += $length;*/
// PlayerNames
$length = $sws->getBinaryData("NewNamePos");
$length = (Integer)$sws->getBinaryData("NewNamePos") + 0;
$sws->setBinaryData("PlayerNames", self::ReadData('String', substr($swscontents, $offset, $length)));
$offset += $length;
@ -344,6 +456,11 @@ class Sws extends SwsModel
return $sws;
}
/**
* @param String $type
* @param String $data
* @return array|bool|\DateTime|float|int|string
*/
private static function ReadData(String $type, String $data)
{
switch ($type) {
@ -378,8 +495,13 @@ class Sws extends SwsModel
break;
}
return false;
}
/**
* @param $date
* @return bool|\DateTime
*/
private static function UIntToTimestamp($date)
{
$curyear = date('Y');