mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-29 09:46:42 +01:00
Replaced Pairtwo Color Values for generic Values
This commit is contained in:
parent
6794e44275
commit
bbff18e64f
@ -12,9 +12,7 @@ use MyCLabs\Enum\Enum;
|
|||||||
|
|
||||||
class Color extends Enum
|
class Color extends Enum
|
||||||
{
|
{
|
||||||
const black = 255; // Implementing two's-complement for these values only is not worth the trick
|
const black = 'B';
|
||||||
const black3 = 253; // Especially if you can just do unsigned
|
const white = 'W';
|
||||||
const white = 1;
|
const none = '*';
|
||||||
const white3 = 3;
|
|
||||||
const none = 0;
|
|
||||||
}
|
}
|
||||||
|
21
src/Sws.php
21
src/Sws.php
@ -34,7 +34,6 @@ use JeroenED\Libpairtwo\Models\Sws as SwsModel;
|
|||||||
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class reads a SWS file
|
* This class reads a SWS file
|
||||||
*
|
*
|
||||||
@ -505,12 +504,26 @@ class Sws extends SwsModel
|
|||||||
$offset += $length;
|
$offset += $length;
|
||||||
|
|
||||||
$length = 1;
|
$length = 1;
|
||||||
$pairing->setColor(new Color(self::ReadData('Int', substr($swscontents, $offset, $length))));
|
|
||||||
|
switch (self::ReadData('Int', substr($swscontents, $offset, $length))) {
|
||||||
|
case 255:
|
||||||
|
case 253:
|
||||||
|
$color = 'B';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 3:
|
||||||
|
$color = 'W';
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
$color = '*';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$pairing->setColor(new Color($color));
|
||||||
$offset += $length;
|
$offset += $length;
|
||||||
|
|
||||||
$length = 1;
|
$length = 1;
|
||||||
Switch(self::ReadData('Int', substr($swscontents, $offset, $length)))
|
switch (self::ReadData('Int', substr($swscontents, $offset, $length))) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
$result = '*';
|
$result = '*';
|
||||||
break;
|
break;
|
||||||
|
@ -89,7 +89,7 @@ class Tournament extends TournamentModel
|
|||||||
$result = $pairing->getResult();
|
$result = $pairing->getResult();
|
||||||
|
|
||||||
$game = new Game();
|
$game = new Game();
|
||||||
if ($color->getValue() == Color::white || $color->getValue() == Color::white3) {
|
if ($color->getValue() == Color::white) {
|
||||||
if(! is_null($player)) $game->setWhite($player);
|
if(! is_null($player)) $game->setWhite($player);
|
||||||
if(! is_null($opponent)) $game->setBlack($opponent);
|
if(! is_null($opponent)) $game->setBlack($opponent);
|
||||||
switch ($result->getValue()) {
|
switch ($result->getValue()) {
|
||||||
@ -115,7 +115,7 @@ class Tournament extends TournamentModel
|
|||||||
default:
|
default:
|
||||||
$game->setResult(new Gameresult('-')); break;
|
$game->setResult(new Gameresult('-')); break;
|
||||||
}
|
}
|
||||||
} elseif ($color->getValue() == Color::black || $color->getValue() == Color::black3) {
|
} elseif ($color->getValue() == Color::black) {
|
||||||
if(! is_null($player)) $game->setBlack($player);
|
if(! is_null($player)) $game->setBlack($player);
|
||||||
if(! is_null($opponent)) $game->setWhite($opponent);
|
if(! is_null($opponent)) $game->setWhite($opponent);
|
||||||
switch ($result->getValue()) {
|
switch ($result->getValue()) {
|
||||||
|
@ -62,4 +62,10 @@ echo "Absent P3: " . $sws->getTournament()->getPlayerById(2)->getAbsent() . P
|
|||||||
echo "Date Round 1: " . $sws->getTournament()->getRoundByNo(0)->getDate()->format('d/m/Y') . PHP_EOL;
|
echo "Date Round 1: " . $sws->getTournament()->getRoundByNo(0)->getDate()->format('d/m/Y') . PHP_EOL;
|
||||||
echo "Date Round 2: " . $sws->getTournament()->getRoundByNo(1)->getDate()->format('d/m/Y') . PHP_EOL;
|
echo "Date Round 2: " . $sws->getTournament()->getRoundByNo(1)->getDate()->format('d/m/Y') . PHP_EOL;
|
||||||
echo "Date Round 3: " . $sws->getTournament()->getRoundByNo(2)->getDate()->format('d/m/Y') . PHP_EOL;
|
echo "Date Round 3: " . $sws->getTournament()->getRoundByNo(2)->getDate()->format('d/m/Y') . PHP_EOL;
|
||||||
|
echo "Color Pairing 1: " . $sws->getTournament()->getPairings()[1]->getColor()->getKey() . PHP_EOL;
|
||||||
|
echo "Color Pairing 2: " . $sws->getTournament()->getPairings()[2]->getColor()->getKey() . PHP_EOL;
|
||||||
|
echo "Color Pairing 3: " . $sws->getTournament()->getPairings()[3]->getColor()->getKey() . PHP_EOL;
|
||||||
|
echo "Player Pairing 1: " . $sws->getTournament()->getPairings()[0]->getPlayer()->getName() . PHP_EOL;
|
||||||
|
echo "Player Pairing 2: " . $sws->getTournament()->getPairings()[1]->getPlayer()->getName() . PHP_EOL;
|
||||||
|
echo "Player Pairing 3: " . $sws->getTournament()->getPairings()[2]->getPlayer()->getName() . PHP_EOL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user