2014-02-14 19:22:11 +01:00
|
|
|
<?php
|
|
|
|
namespace Dedimania;
|
|
|
|
|
2014-02-15 01:03:25 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
use Maniaplanet\DedicatedServer\Structures\Version;
|
|
|
|
|
2014-02-14 19:22:11 +01:00
|
|
|
/**
|
2014-04-13 12:00:08 +02:00
|
|
|
* ManiaControl Dedimania Plugin DataStructure
|
2014-02-14 19:22:11 +01:00
|
|
|
*
|
2014-04-13 12:00:08 +02:00
|
|
|
* @author kremsy and steeffeen
|
|
|
|
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-02-14 19:22:11 +01:00
|
|
|
*/
|
|
|
|
class DedimaniaData {
|
2014-02-15 01:03:25 +01:00
|
|
|
public $game;
|
|
|
|
public $path;
|
|
|
|
public $packmask;
|
|
|
|
public $serverVersion;
|
|
|
|
public $serverBuild;
|
|
|
|
public $tool;
|
|
|
|
public $version;
|
|
|
|
public $login;
|
|
|
|
public $code;
|
2014-02-16 22:38:14 +01:00
|
|
|
public $sessionId = '';
|
|
|
|
public $records = array();
|
2014-02-23 13:15:28 +01:00
|
|
|
public $players = array();
|
2014-02-20 11:04:52 +01:00
|
|
|
public $directoryAccessChecked = false;
|
2014-02-23 13:15:28 +01:00
|
|
|
public $serverMaxRank = 30;
|
2014-02-15 01:03:25 +01:00
|
|
|
|
|
|
|
public function __construct($serverLogin, $dedimaniaCode, $path, $packmask, Version $serverVersion) {
|
|
|
|
$this->game = "TM2";
|
|
|
|
$this->login = $serverLogin;
|
|
|
|
$this->code = $dedimaniaCode;
|
|
|
|
$this->version = ManiaControl::VERSION;
|
|
|
|
$this->tool = "ManiaControl";
|
|
|
|
$this->path = $path;
|
|
|
|
$this->packmask = $packmask;
|
|
|
|
$this->serverVersion = $serverVersion->version;
|
|
|
|
$this->serverBuild = $serverVersion->build;
|
|
|
|
}
|
2014-02-14 19:22:11 +01:00
|
|
|
|
2014-02-15 01:03:25 +01:00
|
|
|
public function toArray() {
|
|
|
|
$array = array();
|
2014-02-16 22:38:14 +01:00
|
|
|
foreach(get_object_vars($this) as $key => $value) {
|
2014-02-23 13:15:28 +01:00
|
|
|
if ($key == 'records' || $key == 'sessionId' || $key == 'directoryAccessChecked' || $key == 'serverMaxRank' || $key == 'players') {
|
2014-02-16 22:38:14 +01:00
|
|
|
continue;
|
|
|
|
}
|
2014-02-15 01:03:25 +01:00
|
|
|
$array[ucfirst($key)] = $value;
|
2014-02-16 22:38:14 +01:00
|
|
|
}
|
2014-02-15 01:03:25 +01:00
|
|
|
return $array;
|
2014-02-14 19:22:11 +01:00
|
|
|
}
|
2014-02-23 13:15:28 +01:00
|
|
|
|
|
|
|
public function getRecordCount() {
|
|
|
|
return count($this->records);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Max Rank for a certain Player
|
|
|
|
*
|
|
|
|
* @param $login
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getPlayerMaxRank($login) {
|
|
|
|
$maxRank = $this->serverMaxRank;
|
|
|
|
foreach($this->players as $player) {
|
|
|
|
/** @var DedimaniaPlayer $player */
|
|
|
|
if ($player->login === $login) {
|
|
|
|
if ($player->maxRank > $maxRank) {
|
|
|
|
$maxRank = $player->maxRank;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $maxRank;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a Player to the Players array
|
|
|
|
*
|
|
|
|
* @param DedimaniaPlayer $player
|
|
|
|
*/
|
|
|
|
public function addPlayer(DedimaniaPlayer $player) {
|
|
|
|
/** @var DedimaniaPlayer $player */
|
|
|
|
$this->players[$player->login] = $player;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a Dedimania Player by its login
|
|
|
|
*
|
|
|
|
* @param string $player
|
|
|
|
*/
|
|
|
|
public function removePlayer($login) {
|
|
|
|
unset($this->players[$login]);
|
|
|
|
}
|
2014-02-14 19:22:11 +01:00
|
|
|
}
|