Renamed Sex to Gender

This commit is contained in:
Jeroen De Meerleer 2019-03-04 11:51:06 +01:00
parent ce6e501043
commit 7fb94aaf00
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
4 changed files with 28 additions and 14 deletions

View File

@ -10,9 +10,9 @@ namespace JeroenED\Libpairtwo\Enums;
use MyCLabs\Enum\Enum;
class Sex extends Enum
class Gender extends Enum
{
const Neutral = 0; // Unforturnately, Incompatible with Pairtwo (Dinos)
const Male = 1;
const Female = 2;
const Neutral = 'X'; // Unforturnately, Incompatible with Pairtwo (Dinos)
const Male = 'M';
const Female = 'F';
}

View File

@ -9,7 +9,7 @@
namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Enums\Title;
use JeroenED\Libpairtwo\Enums\Sex;
use JeroenED\Libpairtwo\Enums\Gender;
use DateTime;
class Player
@ -29,7 +29,7 @@ class Player
private $Nation;
private $Category;
private $Title;
private $Sex;
private $Gender;
private $NumberOfTies;
private $Absent;
@ -276,19 +276,19 @@ class Player
}
/**
* @return Sex
* @return Gender
*/
public function getSex(): Sex
public function getGender(): Gender
{
return $this->Sex;
return $this->Gender;
}
/**
* @param Sex $Sex
* @param Gender $Gender
*/
public function setSex(Sex $Sex): void
public function setGender(Gender $Gender): void
{
$this->Sex = $Sex;
$this->Gender = $Gender;
}
/**

View File

@ -27,7 +27,7 @@
namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Enums\Title;
use JeroenED\Libpairtwo\Enums\Sex;
use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\Libpairtwo\Models\Sws as SwsModel;
@ -304,7 +304,18 @@ class Sws extends SwsModel
$offset += $length;
$length = 1;
$player->setSex(new Sex(self::ReadData('Int', substr($swscontents, $offset, $length))));
switch (self::ReadData('Int', substr($swscontents, $offset, $length))) {
case 1:
$gender = 'M';
break;
case 2:
$gender = "F";
break;
default:
$gender = "X";
break;
}
$player->setGender(new Gender($gender));
$offset += $length;
$length = 1;

View File

@ -53,6 +53,9 @@ echo "KBSB Elo P3: " . $sws->getTournament()->getPlayerById(2)->getKbsbElo() .
echo "Name P1: " . $sws->getTournament()->getPlayerById(0)->getName() . PHP_EOL;
echo "Name P2: " . $sws->getTournament()->getPlayerById(1)->getName() . PHP_EOL;
echo "Name P3: " . $sws->getTournament()->getPlayerById(2)->getName() . PHP_EOL;
echo "Gender P1: " . $sws->getTournament()->getPlayerById(0)->getGender()->getKey() . PHP_EOL;
echo "Gender P2: " . $sws->getTournament()->getPlayerById(1)->getGender()->getKey() . PHP_EOL;
echo "Gender P3: " . $sws->getTournament()->getPlayerById(2)->getGender()->getKey() . PHP_EOL;
echo "Absent P1: " . $sws->getTournament()->getPlayerById(0)->getAbsent() . PHP_EOL;
echo "Absent P2: " . $sws->getTournament()->getPlayerById(1)->getAbsent() . PHP_EOL;
echo "Absent P3: " . $sws->getTournament()->getPlayerById(2)->getAbsent() . PHP_EOL;