improved player class

This commit is contained in:
kremsy 2013-11-09 23:01:54 +01:00
parent c9ab3fe799
commit 96eaa77b97
5 changed files with 123 additions and 97 deletions

View File

@ -23,10 +23,19 @@
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="plugin.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/plugin.php">
<provider selected="true" editor-type-id="text-editor">
<state line="58" column="22" selection-start="1179" selection-end="1179" vertical-scroll-proportion="-32.03846" vertical-offset="153" max-vertical-offset="2703">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="player.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/player.php">
<provider selected="true" editor-type-id="text-editor">
<state line="83" column="27" selection-start="2805" selection-end="2805" vertical-scroll-proportion="-4.6578946" vertical-offset="1057" max-vertical-offset="1853">
<state line="103" column="0" selection-start="3396" selection-end="3396" vertical-scroll-proportion="-7.5657897" vertical-offset="1176" max-vertical-offset="1972">
<folding>
<element signature="e#6#85#0" expanded="true" />
</folding>
@ -37,7 +46,16 @@
<file leaf-file-name="playerHandler.php" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/core/playerHandler.php">
<provider selected="true" editor-type-id="text-editor">
<state line="68" column="7" selection-start="1941" selection-end="1941" vertical-scroll-proportion="0.7234042" vertical-offset="459" max-vertical-offset="1768">
<state line="57" column="118" selection-start="1645" selection-end="1645" vertical-scroll-proportion="0.5177305" vertical-offset="446" max-vertical-offset="1921">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="authentication.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/authentication.php">
<provider selected="true" editor-type-id="text-editor">
<state line="12" column="16" selection-start="146" selection-end="146" vertical-scroll-proportion="-5.8846154" vertical-offset="51" max-vertical-offset="1853">
<folding />
</state>
</provider>
@ -55,7 +73,7 @@
<file leaf-file-name="database.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/database.php">
<provider selected="true" editor-type-id="text-editor">
<state line="21" column="0" selection-start="264" selection-end="296" vertical-scroll-proportion="-13.730769" vertical-offset="0" max-vertical-offset="6919">
<state line="319" column="19" selection-start="9044" selection-end="9044" vertical-scroll-proportion="-1.25" vertical-offset="5328" max-vertical-offset="6919">
<folding />
</state>
</provider>
@ -70,19 +88,10 @@
</provider>
</entry>
</file>
<file leaf-file-name="commands.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/commands.php">
<file leaf-file-name="server.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/server.php">
<provider selected="true" editor-type-id="text-editor">
<state line="99" column="27" selection-start="2928" selection-end="2928" vertical-scroll-proportion="170.65384" vertical-offset="6120" max-vertical-offset="11730">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="stats.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/stats.php">
<provider selected="true" editor-type-id="text-editor">
<state line="20" column="0" selection-start="268" selection-end="268" vertical-scroll-proportion="152.5" vertical-offset="4305" max-vertical-offset="5151">
<state line="229" column="110" selection-start="5463" selection-end="5463" vertical-scroll-proportion="-5.730769" vertical-offset="3744" max-vertical-offset="6596">
<folding />
</state>
</provider>
@ -121,24 +130,24 @@
<option value="$PROJECT_DIR$/core/core.ManiaControl.php" />
<option value="$PROJECT_DIR$/configs/plugins.ManiaControl.xml" />
<option value="$PROJECT_DIR$/core/pluginHandler.php" />
<option value="$PROJECT_DIR$/core/plugin.php" />
<option value="$PROJECT_DIR$/core/server.php" />
<option value="$PROJECT_DIR$/ManiaControl.php" />
<option value="$PROJECT_DIR$/core/commands.php" />
<option value="$PROJECT_DIR$/core/stats.php" />
<option value="$PROJECT_DIR$/core/callbacks.php" />
<option value="$PROJECT_DIR$/core/chat.php" />
<option value="$PROJECT_DIR$/core/core.php" />
<option value="$PROJECT_DIR$/core/tools.php" />
<option value="$PROJECT_DIR$/core/server.php" />
<option value="$PROJECT_DIR$/core/player.php" />
<option value="$PROJECT_DIR$/core/playerHandler.php" />
<option value="$PROJECT_DIR$/core/tools.php" />
<option value="$PROJECT_DIR$/core/plugin.php" />
</list>
</option>
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds">
<option name="x" value="247" />
<option name="y" value="29" />
<option name="x" value="542" />
<option name="y" value="216" />
<option name="width" value="1936" />
<option name="height" value="1056" />
</component>
@ -318,7 +327,7 @@
<servers />
</component>
<component name="ToolWindowManager">
<frame x="247" y="29" width="1936" height="1056" extended-state="0" />
<frame x="542" y="216" width="1936" height="1056" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@ -377,34 +386,6 @@
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/core/server.php">
<provider selected="true" editor-type-id="text-editor">
<state line="241" column="9" selection-start="5767" selection-end="5767" vertical-scroll-proportion="0.5021398" vertical-offset="3745" max-vertical-offset="6579">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/plugin.php">
<provider selected="true" editor-type-id="text-editor">
<state line="11" column="15" selection-start="146" selection-end="146" vertical-scroll-proportion="-5.230769" vertical-offset="51" max-vertical-offset="2703">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/callbacks.php">
<provider selected="true" editor-type-id="text-editor">
<state line="42" column="16" selection-start="0" selection-end="5670" vertical-scroll-proportion="0.24113475" vertical-offset="510" max-vertical-offset="3349">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/pluginHandler.php">
<provider selected="true" editor-type-id="text-editor">
<state line="32" column="2" selection-start="478" selection-end="478" vertical-scroll-proportion="0.643026" vertical-offset="0" max-vertical-offset="846">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/plugins/oldstructure/chatlog.plugin.php">
<provider selected="true" editor-type-id="text-editor">
<state line="40" column="118" selection-start="631" selection-end="741" vertical-scroll-proportion="-20.26923" vertical-offset="153" max-vertical-offset="1547">
@ -419,36 +400,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/chat.php">
<provider selected="true" editor-type-id="text-editor">
<state line="47" column="7" selection-start="976" selection-end="976" vertical-scroll-proportion="-9.653846" vertical-offset="548" max-vertical-offset="1547">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/database.php">
<provider selected="true" editor-type-id="text-editor">
<state line="21" column="0" selection-start="264" selection-end="296" vertical-scroll-proportion="-13.730769" vertical-offset="0" max-vertical-offset="6919">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/player.php">
<provider selected="true" editor-type-id="text-editor">
<state line="83" column="27" selection-start="2805" selection-end="2805" vertical-scroll-proportion="-4.6578946" vertical-offset="1057" max-vertical-offset="1853">
<folding>
<element signature="e#6#85#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/core.php">
<provider selected="true" editor-type-id="text-editor">
<state line="187" column="24" selection-start="4232" selection-end="4232" vertical-scroll-proportion="-41.82895" vertical-offset="0" max-vertical-offset="6817">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/plugins/oldstructure/records.plugin.php">
<provider selected="true" editor-type-id="text-editor">
<state line="1200" column="7" selection-start="37957" selection-end="37957" vertical-scroll-proportion="0.5579196" vertical-offset="19928" max-vertical-offset="20774">
@ -463,20 +414,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/commands.php">
<provider selected="true" editor-type-id="text-editor">
<state line="99" column="27" selection-start="2928" selection-end="2928" vertical-scroll-proportion="170.65384" vertical-offset="6120" max-vertical-offset="11730">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/stats.php">
<provider selected="true" editor-type-id="text-editor">
<state line="20" column="0" selection-start="268" selection-end="268" vertical-scroll-proportion="152.5" vertical-offset="4305" max-vertical-offset="5151">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/tools.php">
<provider selected="true" editor-type-id="text-editor">
<state line="154" column="6" selection-start="3963" selection-end="3963" vertical-scroll-proportion="-22.615385" vertical-offset="2030" max-vertical-offset="4352">
@ -484,9 +421,81 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/chat.php">
<provider selected="true" editor-type-id="text-editor">
<state line="47" column="7" selection-start="976" selection-end="976" vertical-scroll-proportion="-9.653846" vertical-offset="548" max-vertical-offset="1547">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/commands.php">
<provider selected="true" editor-type-id="text-editor">
<state line="38" column="71" selection-start="829" selection-end="829" vertical-scroll-proportion="0.46217495" vertical-offset="255" max-vertical-offset="11730">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/stats.php">
<provider selected="true" editor-type-id="text-editor">
<state line="20" column="0" selection-start="268" selection-end="268" vertical-scroll-proportion="0.40189126" vertical-offset="0" max-vertical-offset="5151">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/server.php">
<provider selected="true" editor-type-id="text-editor">
<state line="229" column="110" selection-start="5463" selection-end="5463" vertical-scroll-proportion="-5.730769" vertical-offset="3744" max-vertical-offset="6596">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/pluginHandler.php">
<provider selected="true" editor-type-id="text-editor">
<state line="32" column="2" selection-start="478" selection-end="478" vertical-scroll-proportion="0.643026" vertical-offset="0" max-vertical-offset="846">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/core.php">
<provider selected="true" editor-type-id="text-editor">
<state line="187" column="24" selection-start="4232" selection-end="4232" vertical-scroll-proportion="-41.82895" vertical-offset="0" max-vertical-offset="6817">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/database.php">
<provider selected="true" editor-type-id="text-editor">
<state line="319" column="19" selection-start="9044" selection-end="9044" vertical-scroll-proportion="-1.25" vertical-offset="5328" max-vertical-offset="6919">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/authentication.php">
<provider selected="true" editor-type-id="text-editor">
<state line="12" column="16" selection-start="146" selection-end="146" vertical-scroll-proportion="-5.8846154" vertical-offset="51" max-vertical-offset="1853">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/player.php">
<provider selected="true" editor-type-id="text-editor">
<state line="103" column="0" selection-start="3396" selection-end="3396" vertical-scroll-proportion="-7.5657897" vertical-offset="1176" max-vertical-offset="1972">
<folding>
<element signature="e#6#85#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/plugin.php">
<provider selected="true" editor-type-id="text-editor">
<state line="58" column="22" selection-start="1179" selection-end="1179" vertical-scroll-proportion="-32.03846" vertical-offset="153" max-vertical-offset="2703">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/playerHandler.php">
<provider selected="true" editor-type-id="text-editor">
<state line="68" column="7" selection-start="1941" selection-end="1941" vertical-scroll-proportion="0.7234042" vertical-offset="459" max-vertical-offset="1768">
<state line="57" column="118" selection-start="1645" selection-end="1645" vertical-scroll-proportion="0.5177305" vertical-offset="446" max-vertical-offset="1921">
<folding />
</state>
</provider>

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -60,7 +60,7 @@ namespace ManiaControl;
*/
public function disablePlugin()
{
$this->active = true;
$this->active = false;
}
/**

View File

@ -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
*