1: <?php
2: /**
3: * Represents a Dedicated TrackMania Server Player
4: * ManiaLive - TrackMania dedicated server manager in PHP
5: *
6: * @copyright Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
7: * @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
8: * @version $Revision: 425 $:
9: * @author $Author: melot.philippe $:
10: * @date $Date: 2012-07-18 12:36:36 +0200 (mer., 18 juil. 2012) $:
11: */
12: namespace DedicatedApi\Structures;
13:
14: class Player extends AbstractStructure
15: {
16: public $playerId;
17: public $login;
18: public $nickName;
19: public $teamId;
20: public $path;
21: public $language;
22: public $clientVersion;
23: public $clientName;
24: public $iPAddress;
25: public $downloadRate;
26: public $uploadRate;
27: public $isSpectator;
28: public $isInOfficialMode;
29: public $avatar;
30: public $skins;
31: public $ladderStats;
32: public $hoursSinceZoneInscription;
33: public $onlineRights;
34: public $rank;
35: public $bestTime;
36: public $bestCheckpoints;
37: public $score;
38: public $nbrLapsFinished;
39: public $ladderScore;
40: public $stateUpdateLatency;
41: public $stateUpdatePeriod;
42: public $latestNetworkActivity;
43: public $packetLossRate;
44: public $spectatorStatus;
45: public $ladderRanking;
46: public $flags;
47: public $isConnected = true;
48:
49: //Flags details
50: public $forceSpectator;
51: public $isReferee;
52: public $isPodiumReady;
53: public $isUsingStereoscopy;
54: public $isManagedByAnOtherServer;
55: public $isServer;
56: public $hasPlayerSlot;
57:
58: //SpectatorStatus details
59: public $spectator;
60: public $temporarySpectator;
61: public $pureSpectator;
62: public $autoTarget;
63: public $currentTargetId;
64:
65: function getArrayFromPath()
66: {
67: return explode('|', $this->path);
68: }
69:
70: /**
71: * @return Player
72: */
73: static public function fromArray($array)
74: {
75: $object = parent::fromArray($array);
76:
77: $object->skins = Skin::fromArrayOfArray($object->skins);
78: //Detail flags
79: $object->forceSpectator = $object->flags % 10; // 0, 1 or 2
80: $object->isReferee = (bool) (intval($object->flags / 10) % 10);
81: $object->isPodiumReady = (bool) (intval($object->flags / 100) % 10);
82: $object->isUsingStereoscopy = (bool) (intval($object->flags / 1000) % 10);
83: $object->isManagedByAnOtherServer = (bool) (intval($object->flags / 10000) % 10);
84: $object->isServer = (bool) (intval($object->flags / 100000) % 10);
85: $object->hasPlayerSlot = (bool) (intval($object->flags / 1000000) % 10);
86: //Details spectatorStatus
87: $object->spectator = (bool) ($object->spectatorStatus % 10);
88: $object->temporarySpectator = (bool) (intval($object->spectatorStatus / 10) % 10);
89: $object->pureSpectator = (bool) (intval($object->spectatorStatus / 100) % 10);
90: $object->autoTarget = (bool) (intval($object->spectatorStatus / 1000) % 10);
91: $object->currentTargetId = intval($object->spectatorStatus / 10000);
92:
93: return $object;
94: }
95: }
96: ?>