mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-12-23 21:00:58 +01:00
Reading playernames
This commit is contained in:
parent
491004a604
commit
e5fc94aca8
13
src/Sws.php
13
src/Sws.php
@ -338,15 +338,20 @@ class Sws extends SwsModel
|
||||
|
||||
$sws->getTournament()->addPlayer($player);
|
||||
}
|
||||
/* $length = 68 * $sws->getBinaryData("NewPlayer");
|
||||
$sws->setBinaryData("Players", self::ReadData('String', substr($swscontents, $offset, $length)));
|
||||
$offset += $length;*/
|
||||
|
||||
// PlayerNames
|
||||
$length = (Integer)$sws->getBinaryData("NewNamePos") + 0;
|
||||
$sws->setBinaryData("PlayerNames", self::ReadData('String', substr($swscontents, $offset, $length)));
|
||||
$offset += $length;
|
||||
|
||||
for ($i = 0; $i < $sws->getBinaryData("NewPlayer"); $i++) {
|
||||
$namelength = $sws->getBinaryData("Players($i)_NameLength");
|
||||
$nameoffset = $sws->getBinaryData("Players($i)_NamePos");
|
||||
$player = $sws->getTournament()->getPlayerById($i);
|
||||
$player->setName(self::ReadData("String", substr($sws->getBinaryData("PlayerNames"), $nameoffset, $namelength)));
|
||||
|
||||
$sws->getTournament()->updatePlayer($i, $player);
|
||||
}
|
||||
|
||||
// TournamentName
|
||||
$length = 80;
|
||||
$sws->getTournament()->setName(self::ReadData('String', substr($swscontents, $offset, $length)));
|
||||
|
@ -30,4 +30,15 @@ class Tournament extends TournamentModel
|
||||
$newArray[] = $Player;
|
||||
$this->setPlayers($newArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param Player $player
|
||||
*/
|
||||
public function updatePlayer($id, Player $player)
|
||||
{
|
||||
$newArray = $this->GetPlayers();
|
||||
$newArray[$id] = $player;
|
||||
$this->setPlayers($newArray);
|
||||
}
|
||||
}
|
||||
|
@ -50,5 +50,8 @@ echo "Fide Elo P3: " . $sws->getTournament()->getPlayerById(2)->getFideElo() .
|
||||
echo "KBSB Elo P1: " . $sws->getTournament()->getPlayerById(0)->getKbsbElo() . PHP_EOL;
|
||||
echo "KBSB Elo P2: " . $sws->getTournament()->getPlayerById(1)->getKbsbElo() . PHP_EOL;
|
||||
echo "KBSB Elo P3: " . $sws->getTournament()->getPlayerById(2)->getKbsbElo() . PHP_EOL;
|
||||
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 $sws->getBinaryData("Tournament");
|
||||
//echo $sws->getBinaryData("Players");*/
|
||||
|
Loading…
Reference in New Issue
Block a user