From 96eaa77b97d8bd6c585f8102f496ec9ce4d21ba6 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 9 Nov 2013 23:01:54 +0100 Subject: [PATCH] improved player class --- application/.idea/workspace.xml | 197 +++++++++++++++-------------- application/core/player.php | 7 + application/core/playerHandler.php | 13 +- application/core/plugin.php | 2 +- application/core/server.php | 1 + 5 files changed, 123 insertions(+), 97 deletions(-) diff --git a/application/.idea/workspace.xml b/application/.idea/workspace.xml index 0a7d7e65..741ff3a2 100644 --- a/application/.idea/workspace.xml +++ b/application/.idea/workspace.xml @@ -23,10 +23,19 @@ + + + + + + + + + - + @@ -37,7 +46,16 @@ - + + + + + + + + + + @@ -55,7 +73,7 @@ - + @@ -70,19 +88,10 @@ - - + + - - - - - - - - - - + @@ -121,24 +130,24 @@ - @@ -318,7 +327,7 @@ - + @@ -377,34 +386,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -419,36 +400,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -463,20 +414,6 @@ - - - - - - - - - - - - - - @@ -484,9 +421,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/application/core/player.php b/application/core/player.php index 5eabe333..ac26162c 100644 --- a/application/core/player.php +++ b/application/core/player.php @@ -35,10 +35,13 @@ class Player { public $ladderscore; public $created; + public $rightLevel; + //TODO: usefull construct player without rpc info? //TODO: isBot properti //TODO: add all attributes like, allies, clublink ... just make vardump on rpc infos + //TODO: READ ADDITIONAL INFOS FROM DATABASE public function __construct($rpc_infos = null){ if ($rpc_infos) { @@ -98,6 +101,10 @@ class Player { $this->ladderscore = 0; $this->created = 0; } + + + //rightlevels, 0 = user, 1 = operator, 2 = admin, 3 = superadmin, 4 = headadmin (from config) + $this->rightLevel = 0; } } diff --git a/application/core/playerHandler.php b/application/core/playerHandler.php index 36b25f20..0fadfb8e 100644 --- a/application/core/playerHandler.php +++ b/application/core/playerHandler.php @@ -14,12 +14,18 @@ namespace ManiaControl; * @package ManiaControl */ class playerHandler { + /** * Private properties */ private $playerList; private $mc; + /** + * Public properties + */ + public $rightLevels = array(0 => 'Player', 1 => 'Operator', 2 => 'Admin', 3 => 'MasterAdmin', 4 => 'MasterAdmin'); + public function __construct(ManiaControl $mc){ $this->mc = $mc; $this->playerList = array(); @@ -29,7 +35,7 @@ class playerHandler { /** - * initializes a Whole Playerlist + * initializes a Whole PlayerList * @param $players */ public function addPlayerList($players){ @@ -43,11 +49,14 @@ class playerHandler { */ public function playerConnect($player){ //TODO: Welcome Message?, on mc restart not all players listed, no relay support yet + //TODO: Add Rights + //TODO: Database $this->mc->client->query('GetDetailedPlayerInfo', $player[0]); $this->addPlayer(new Player($this->mc->client->getResponse())); $player = $this->playerList[$player[0]]; if($player->pid != 0){ //Player 0 = server - $this->mc->chat->sendChat('$ff0New Player: '. $player->nickname . '$z $ff0Nation:$fff ' . $player->nation . ' $ff0Ladder: $fff' . $player->ladderrank); + $string = array(0 => 'New Player', 1 => 'Operator', 2 => 'Admin', 3 => 'MasterAdmin', 4 => 'MasterAdmin'); + $this->mc->chat->sendChat('$ff0'.$string[$player->rightLevel].': '. $player->nickname . '$z $ff0Nation:$fff ' . $player->nation . ' $ff0Ladder: $fff' . $player->ladderrank); } } diff --git a/application/core/plugin.php b/application/core/plugin.php index 12e664aa..75e51564 100644 --- a/application/core/plugin.php +++ b/application/core/plugin.php @@ -60,7 +60,7 @@ namespace ManiaControl; */ public function disablePlugin() { - $this->active = true; + $this->active = false; } /** diff --git a/application/core/server.php b/application/core/server.php index ff918498..bed14fc9 100644 --- a/application/core/server.php +++ b/application/core/server.php @@ -227,6 +227,7 @@ class Server { return $gameMode; } + //TODO: remove getPlayer / getPlayers -> methods now in playerHandler handeld, but should be improved more /** * Fetch player info *