From e0da8a71cdc695c52db70489d7b49f05a6cbc421 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Tue, 19 Mar 2019 16:30:59 +0100 Subject: [PATCH] Replaced Pairtwo Title Values for generic Values --- src/Enums/Title.php | 26 +++++++++++++------------- src/Sws.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/Enums/Title.php b/src/Enums/Title.php index 17bd96f..1533a42 100644 --- a/src/Enums/Title.php +++ b/src/Enums/Title.php @@ -12,17 +12,17 @@ use MyCLabs\Enum\Enum; class Title extends Enum { - const NONE = 0; - const ELO = 1; - const NM = 2; // National Master - const WCM = 3; // Woman Candidate Master - const WFM = 4; // Women Fide Master - const CM = 5; // Candidate Master - const WIM = 6; // Woman International Master - const FM = 7; // Fide Master - const WGM = 8; // Woman Grand Master - const HM = 9; // Honorary International master - const IM = 10; // International Master - const HG = 11; // Honorary Grand Master - const GM = 12; // Grand Master + const NONE = '*'; + const ELO = 'Elo'; + const NM = 'National Master'; + const WCM = 'Woman Candidate Master'; + const WFM = 'Woman Fide Master'; + const CM = 'Candidate Master'; + const WIM = 'Woman International Master'; + const FM = 'Fide Master'; + const WGM = 'Woman Grand Master'; + const HM = 'Honorary International Master'; + const IM = 'International Master'; + const HG = 'Honorary Grand Master'; + const GM = 'Grand Master'; } diff --git a/src/Sws.php b/src/Sws.php index cf17cad..7a43ba0 100644 --- a/src/Sws.php +++ b/src/Sws.php @@ -299,7 +299,49 @@ class Sws extends SwsModel $offset += $length; $length = 1; - $player->setTitle(new Title(self::ReadData('Int', substr($swscontents, $offset, $length)))); + switch (self::ReadData('Int', substr($swscontents, $offset, $length))) { + case 1: + $title = Title::ELO; + break; + case 2: + $title = Title::NM; + break; + case 3: + $title = Title::WCM; + break; + case 4: + $title = Title::WFM; + break; + case 5: + $title = Title::CM; + break; + case 6: + $title = Title::WIM; + break; + case 7: + $title = Title::FM; + break; + case 8: + $title = Title::WGM; + break; + case 9: + $title = Title::HM; + break; + case 10: + $title = Title::IM; + break; + case 11: + $title = Title::HG; + break; + case 12: + $title = Title::GM; + break; + case 0: + default: + $title = Title::NONE; + break; + } + $player->setTitle(new Title($title)); $offset += $length; $length = 1;