ManiaControl property in player class
This commit is contained in:
parent
49f3953abf
commit
e8bcae081a
@ -3,6 +3,7 @@
|
|||||||
namespace ManiaControl\Players;
|
namespace ManiaControl\Players;
|
||||||
|
|
||||||
use ManiaControl\Formatter;
|
use ManiaControl\Formatter;
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player Model Class
|
* Player Model Class
|
||||||
@ -58,13 +59,20 @@ class Player {
|
|||||||
public $autoTarget = false;
|
public $autoTarget = false;
|
||||||
public $currentTargetId = 0;
|
public $currentTargetId = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Private Properties
|
||||||
|
*/
|
||||||
|
private $maniaControl = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Construct a new Player
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
* @param bool $connected
|
* @param bool $connected
|
||||||
*/
|
*/
|
||||||
public function __construct($connected)
|
public function __construct(ManiaControl $maniaControl, $connected) {
|
||||||
{
|
$this->maniaControl = $maniaControl;
|
||||||
$this->isConnected = $connected;
|
$this->isConnected = (bool)$connected;
|
||||||
|
|
||||||
if ($connected) {
|
if ($connected) {
|
||||||
$this->joinTime = time();
|
$this->joinTime = time();
|
||||||
}
|
}
|
||||||
@ -72,16 +80,16 @@ class Player {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update from ManiaPlanet PlayerInfo structure
|
* Update from ManiaPlanet PlayerInfo structure
|
||||||
|
*
|
||||||
* @param \Maniaplanet\DedicatedServer\Structures\PlayerInfo $mpPlayer
|
* @param \Maniaplanet\DedicatedServer\Structures\PlayerInfo $mpPlayer
|
||||||
*/
|
*/
|
||||||
public function setInfo($mpPlayer)
|
public function setInfo($mpPlayer) {
|
||||||
{
|
$this->pid = $mpPlayer->playerId;
|
||||||
$this->pid = $mpPlayer->playerId;
|
$this->login = $mpPlayer->login;
|
||||||
$this->login = $mpPlayer->login;
|
$this->nickname = Formatter::stripDirtyCodes($mpPlayer->nickName);
|
||||||
$this->nickname = Formatter::stripDirtyCodes($mpPlayer->nickName);
|
$this->rawNickname = $mpPlayer->nickName;
|
||||||
$this->rawNickname = $mpPlayer->nickName;
|
$this->teamId = $mpPlayer->teamId;
|
||||||
$this->teamId = $mpPlayer->teamId;
|
$this->isOfficial = $mpPlayer->isInOfficialMode;
|
||||||
$this->isOfficial = $mpPlayer->isInOfficialMode;
|
|
||||||
|
|
||||||
//Flag Details
|
//Flag Details
|
||||||
$this->forcedSpectatorState = $mpPlayer->forceSpectator;
|
$this->forcedSpectatorState = $mpPlayer->forceSpectator;
|
||||||
@ -108,10 +116,10 @@ class Player {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update from ManiaPlanet PlayerDetailedInfo structure
|
* Update from ManiaPlanet PlayerDetailedInfo structure
|
||||||
|
*
|
||||||
* @param \Maniaplanet\DedicatedServer\Structures\PlayerDetailedInfo $mpPlayer
|
* @param \Maniaplanet\DedicatedServer\Structures\PlayerDetailedInfo $mpPlayer
|
||||||
*/
|
*/
|
||||||
public function setDetailedInfo($mpPlayer)
|
public function setDetailedInfo($mpPlayer) {
|
||||||
{
|
|
||||||
$this->pid = $mpPlayer->playerId;
|
$this->pid = $mpPlayer->playerId;
|
||||||
$this->login = $mpPlayer->login;
|
$this->login = $mpPlayer->login;
|
||||||
$this->nickname = Formatter::stripDirtyCodes($mpPlayer->nickName);
|
$this->nickname = Formatter::stripDirtyCodes($mpPlayer->nickName);
|
||||||
@ -156,6 +164,22 @@ class Player {
|
|||||||
return $this->getPathPart(3);
|
return $this->getPathPart(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the specified Part of the Path
|
||||||
|
*
|
||||||
|
* @param int $partNumber
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPathPart($partNumber) {
|
||||||
|
$pathParts = explode('|', $this->path);
|
||||||
|
for ($partIndex = $partNumber; $partIndex >= 0; $partIndex--) {
|
||||||
|
if (isset($pathParts[$partIndex])) {
|
||||||
|
return $pathParts[$partIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Country
|
* Get Country
|
||||||
*
|
*
|
||||||
@ -174,22 +198,6 @@ class Player {
|
|||||||
return $this->getPathPart(1);
|
return $this->getPathPart(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the specified Part of the Path
|
|
||||||
*
|
|
||||||
* @param int $partNumber
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getPathPart($partNumber) {
|
|
||||||
$pathParts = explode('|', $this->path);
|
|
||||||
for ($partIndex = $partNumber; $partIndex >= 0; $partIndex--) {
|
|
||||||
if (isset($pathParts[$partIndex])) {
|
|
||||||
return $pathParts[$partIndex];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $this->path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the Flags of the Player
|
* Update the Flags of the Player
|
||||||
*
|
*
|
||||||
|
@ -125,7 +125,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
|||||||
$this->maniaControl->server->setTeamMode(true);
|
$this->maniaControl->server->setTeamMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$player = new Player(true);
|
$player = new Player($this->maniaControl, true);
|
||||||
$player->setInfo($playerItem);
|
$player->setInfo($playerItem);
|
||||||
$player->setDetailedInfo($detailedPlayerInfo);
|
$player->setDetailedInfo($detailedPlayerInfo);
|
||||||
$player->hasJoinedGame = true;
|
$player->hasJoinedGame = true;
|
||||||
@ -212,7 +212,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
|||||||
$login = $callback[1][0];
|
$login = $callback[1][0];
|
||||||
try {
|
try {
|
||||||
$playerInfo = $this->maniaControl->client->getDetailedPlayerInfo($login);
|
$playerInfo = $this->maniaControl->client->getDetailedPlayerInfo($login);
|
||||||
$player = new Player(true);
|
$player = new Player($this->maniaControl, true);
|
||||||
$player->setDetailedInfo($playerInfo);
|
$player->setDetailedInfo($playerInfo);
|
||||||
|
|
||||||
$this->addPlayer($player);
|
$this->addPlayer($player);
|
||||||
@ -394,7 +394,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$player = new Player(false);
|
$player = new Player($this->maniaControl, false);
|
||||||
$player->index = $row->index;
|
$player->index = $row->index;
|
||||||
$player->login = $row->login;
|
$player->login = $row->login;
|
||||||
$player->rawNickname = $row->nickname;
|
$player->rawNickname = $row->nickname;
|
||||||
@ -479,7 +479,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$player = new Player(false);
|
$player = new Player($this->maniaControl, false);
|
||||||
$player->index = $playerIndex;
|
$player->index = $playerIndex;
|
||||||
$player->login = $row->login;
|
$player->login = $row->login;
|
||||||
$player->rawNickname = $row->nickname;
|
$player->rawNickname = $row->nickname;
|
||||||
|
Loading…
Reference in New Issue
Block a user