mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-24 07:21:01 +01:00
Reading playernames
This commit is contained in:
parent
5bc8e006dc
commit
830b21afa2
13
src/Sws.php
13
src/Sws.php
@ -338,15 +338,20 @@ class Sws extends SwsModel
|
|||||||
|
|
||||||
$sws->getTournament()->addPlayer($player);
|
$sws->getTournament()->addPlayer($player);
|
||||||
}
|
}
|
||||||
/* $length = 68 * $sws->getBinaryData("NewPlayer");
|
|
||||||
$sws->setBinaryData("Players", self::ReadData('String', substr($swscontents, $offset, $length)));
|
|
||||||
$offset += $length;*/
|
|
||||||
|
|
||||||
// PlayerNames
|
// PlayerNames
|
||||||
$length = (Integer)$sws->getBinaryData("NewNamePos") + 0;
|
$length = (Integer)$sws->getBinaryData("NewNamePos") + 0;
|
||||||
$sws->setBinaryData("PlayerNames", self::ReadData('String', substr($swscontents, $offset, $length)));
|
$sws->setBinaryData("PlayerNames", self::ReadData('String', substr($swscontents, $offset, $length)));
|
||||||
$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
|
// TournamentName
|
||||||
$length = 80;
|
$length = 80;
|
||||||
$sws->getTournament()->setName(self::ReadData('String', substr($swscontents, $offset, $length)));
|
$sws->getTournament()->setName(self::ReadData('String', substr($swscontents, $offset, $length)));
|
||||||
|
@ -30,4 +30,15 @@ class Tournament extends TournamentModel
|
|||||||
$newArray[] = $Player;
|
$newArray[] = $Player;
|
||||||
$this->setPlayers($newArray);
|
$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 P1: " . $sws->getTournament()->getPlayerById(0)->getKbsbElo() . PHP_EOL;
|
||||||
echo "KBSB Elo P2: " . $sws->getTournament()->getPlayerById(1)->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 "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("Tournament");
|
||||||
//echo $sws->getBinaryData("Players");*/
|
//echo $sws->getBinaryData("Players");*/
|
||||||
|
Loading…
Reference in New Issue
Block a user