changed direct public access of maniacontrol properties to using getter methods
This commit is contained in:
@ -44,31 +44,31 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
private $statsWidth = 0;
|
||||
|
||||
/**
|
||||
* Create a PlayerList Instance
|
||||
* Construct a new simple stats list instance
|
||||
*
|
||||
* @param ManiaControl $maniaControl
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the menu entry
|
||||
*/
|
||||
public function handleOnInit() {
|
||||
$this->maniaControl->commandManager->registerCommandListener('stats', $this, 'command_ShowStatsList', false, 'Shows statistics.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('stats', $this, 'command_ShowStatsList', false, 'Shows statistics.');
|
||||
|
||||
// Action Open StatsList
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_STATSLIST, $this, 'command_ShowStatsList');
|
||||
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_STATSLIST, $this, 'command_ShowStatsList');
|
||||
|
||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Stats);
|
||||
$itemQuad->setAction(self::ACTION_OPEN_STATSLIST);
|
||||
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 14, 'Open Statistics');
|
||||
$this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, true, 14, 'Open Statistics');
|
||||
|
||||
//TODO settings if a stat get shown
|
||||
$this->registerStat(PlayerManager::STAT_SERVERTIME, 10, "ST", 20, StatisticManager::STAT_TYPE_TIME);
|
||||
@ -119,9 +119,9 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
* @param string $order
|
||||
*/
|
||||
public function showStatsList(Player $player, $order = PlayerManager::STAT_SERVERTIME) {
|
||||
$height = $this->maniaControl->manialinkManager->getStyleManager()->getListWidgetsHeight();
|
||||
$quadStyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
|
||||
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
@ -174,7 +174,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
$posX = $xStart + 55;
|
||||
$statRankings = array();
|
||||
foreach ($this->statArray as $key => $stat) {
|
||||
$ranking = $this->maniaControl->statisticManager->getStatsRanking($stat["Name"]);
|
||||
$ranking = $this->maniaControl->getStatisticManager()->getStatsRanking($stat["Name"]);
|
||||
if (!empty($ranking)) {
|
||||
$statRankings[$stat["Name"]] = $ranking;
|
||||
$array[$stat['HeadShortCut']] = $posX;
|
||||
@ -184,7 +184,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
}
|
||||
}
|
||||
|
||||
$labels = $this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||
$labels = $this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
|
||||
|
||||
// Description Label
|
||||
$index = 2;
|
||||
@ -212,7 +212,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
}
|
||||
|
||||
foreach ($statRankings[$order] as $playerId => $value) {
|
||||
$listPlayer = $this->maniaControl->playerManager->getPlayerByIndex($playerId);
|
||||
$listPlayer = $this->maniaControl->getPlayerManager()->getPlayerByIndex($playerId);
|
||||
if (!$listPlayer) {
|
||||
continue;
|
||||
}
|
||||
@ -249,7 +249,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
}
|
||||
|
||||
$array = array($index => $xStart + 5, $listPlayer->nickname => $xStart + 14);
|
||||
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array);
|
||||
|
||||
$posX = $xStart + 55;
|
||||
foreach ($displayArray as $key => $array) {
|
||||
@ -279,7 +279,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
$posY -= 4;
|
||||
}
|
||||
|
||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'SimpleStatsList');
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'SimpleStatsList');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -299,7 +299,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
switch ($action) {
|
||||
case self::ACTION_SORT_STATS:
|
||||
$playerLogin = $callback[1][1];
|
||||
$player = $this->maniaControl->playerManager->getPlayer($playerLogin);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($playerLogin);
|
||||
$this->showStatsList($player, $actionArray[2]);
|
||||
break;
|
||||
}
|
||||
|
@ -60,48 +60,48 @@ class StatisticCollector implements CallbackListener {
|
||||
private $onShootArray = array();
|
||||
|
||||
/**
|
||||
* Construct player manager
|
||||
* Construct a new statistic collector instance
|
||||
*
|
||||
* @param \ManiaControl\ManiaControl $maniaControl
|
||||
* @param ManiaControl $maniaControl
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
//Register Callbacks
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACK, $this, 'handleCallbacks');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACKARRAY, $this, 'handleCallbacks');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::ONINIT, $this, 'onInit');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'onPlayerDisconnect');
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACK, $this, 'handleCallbacks');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACKARRAY, $this, 'handleCallbacks');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'onInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'onPlayerDisconnect');
|
||||
|
||||
//Initialize Settings
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_COLLECT_STATS_ENABLED, true);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_COLLECT_STATS_MINPLAYERS, 4);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_ON_SHOOT_PRESTORE, 10);
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_COLLECT_STATS_ENABLED, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_COLLECT_STATS_MINPLAYERS, 4);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ON_SHOOT_PRESTORE, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle ManiaControl OnInit Callback
|
||||
*/
|
||||
public function onInit() {
|
||||
//Define Stats MetaData
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYTIME, StatisticManager::STAT_TYPE_TIME);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_MAP_WINS);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ON_SHOOT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ON_NEARMISS);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ON_CAPTURE);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ON_HIT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ON_GOT_HIT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ON_DEATH);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ON_PLAYER_REQUEST_RESPAWN);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ON_KILL);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_LASER_HIT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_LASER_SHOT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_NUCLEUS_HIT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_NUCLEUS_SHOT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ROCKET_HIT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ROCKET_SHOT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ARROW_HIT);
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ARROW_SHOT);
|
||||
// Define Stats MetaData
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYTIME, StatisticManager::STAT_TYPE_TIME);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_MAP_WINS);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ON_SHOOT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ON_NEARMISS);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ON_CAPTURE);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ON_HIT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ON_GOT_HIT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ON_DEATH);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ON_PLAYER_REQUEST_RESPAWN);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ON_KILL);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_LASER_HIT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_LASER_SHOT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_NUCLEUS_HIT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_NUCLEUS_SHOT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ROCKET_HIT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ROCKET_SHOT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ARROW_HIT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_ARROW_SHOT);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,15 +111,15 @@ class StatisticCollector implements CallbackListener {
|
||||
*/
|
||||
public function onEndMap(array $callback) {
|
||||
//Check for Minimum PlayerCount
|
||||
if ($this->maniaControl->playerManager->getPlayerCount() < $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
|
||||
if ($this->maniaControl->getPlayerManager()->getPlayerCount() < $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$leaders = $this->maniaControl->server->getRankingManager()->getLeaders();
|
||||
$leaders = $this->maniaControl->getServer()->getRankingManager()->getLeaders();
|
||||
|
||||
foreach ($leaders as $leaderLogin) {
|
||||
$leader = $this->maniaControl->playerManager->getPlayer($leaderLogin);
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_MAP_WINS, $leader);
|
||||
$leader = $this->maniaControl->getPlayerManager()->getPlayer($leaderLogin);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_MAP_WINS, $leader);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,14 +130,14 @@ class StatisticCollector implements CallbackListener {
|
||||
*/
|
||||
public function onPlayerDisconnect(Player $player) {
|
||||
// Check if Stat Collecting is enabled
|
||||
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED)) {
|
||||
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Insert Data into Database, and destroy player
|
||||
if (isset($this->onShootArray[$player->login])) {
|
||||
if ($this->onShootArray[$player->login] > 0) {
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $this->maniaControl->server->index, $this->onShootArray[$player->login]);
|
||||
$this->maniaControl->getStatisticManager()->insertStat(self::STAT_ON_SHOOT, $player, $this->maniaControl->getServer()->index, $this->onShootArray[$player->login]);
|
||||
}
|
||||
unset($this->onShootArray[$player->login]);
|
||||
}
|
||||
@ -151,12 +151,12 @@ class StatisticCollector implements CallbackListener {
|
||||
public function handleCallbacks(array $callback) {
|
||||
//TODO survivals
|
||||
// Check if Stat Collecting is enabled
|
||||
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED)) {
|
||||
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_ENABLED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for Minimum PlayerCount
|
||||
if ($this->maniaControl->playerManager->getPlayerCount() < $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
|
||||
if ($this->maniaControl->getPlayerManager()->getPlayerCount() < $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -167,47 +167,47 @@ class StatisticCollector implements CallbackListener {
|
||||
$this->handleOnShoot($callback[1][1][0], $callback[1][1][1]);
|
||||
break;
|
||||
case 'LibXmlRpc_OnHit':
|
||||
$shooter = $this->maniaControl->playerManager->getPlayer($callback[1][1][0]);
|
||||
$victim = $this->maniaControl->playerManager->getPlayer($callback[1][1][1]);
|
||||
$shooter = $this->maniaControl->getPlayerManager()->getPlayer($callback[1][1][0]);
|
||||
$victim = $this->maniaControl->getPlayerManager()->getPlayer($callback[1][1][1]);
|
||||
$weapon = $callback[1][1][3];
|
||||
if ($shooter) {
|
||||
$this->maniaControl->statisticManager->incrementStat($this->getWeaponStat(intval($weapon), false), $shooter);
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_HIT, $shooter);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat($this->getWeaponStat(intval($weapon), false), $shooter);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_HIT, $shooter);
|
||||
}
|
||||
if ($victim) {
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_GOT_HIT, $victim);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_GOT_HIT, $victim);
|
||||
}
|
||||
break;
|
||||
case 'LibXmlRpc_OnNearMiss':
|
||||
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1][0]);
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_NEARMISS, $player);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($callback[1][1][0]);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_NEARMISS, $player);
|
||||
break;
|
||||
case 'LibXmlRpc_OnCapture':
|
||||
$logins = $callback[1][1][0];
|
||||
$logins = explode(';', $logins);
|
||||
foreach ($logins as $login) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
continue;
|
||||
}
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_CAPTURE, $player);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_CAPTURE, $player);
|
||||
}
|
||||
break;
|
||||
case 'LibXmlRpc_OnArmorEmpty':
|
||||
$victim = $this->maniaControl->playerManager->getPlayer($callback[1][1][1]);
|
||||
$victim = $this->maniaControl->getPlayerManager()->getPlayer($callback[1][1][1]);
|
||||
if (isset($callback[1][1][0])) {
|
||||
$shooter = $this->maniaControl->playerManager->getPlayer($callback[1][1][0]);
|
||||
$shooter = $this->maniaControl->getPlayerManager()->getPlayer($callback[1][1][0]);
|
||||
if ($shooter) {
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_KILL, $shooter);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_KILL, $shooter);
|
||||
}
|
||||
}
|
||||
if ($victim) {
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_DEATH, $victim);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_DEATH, $victim);
|
||||
}
|
||||
break;
|
||||
case 'LibXmlRpc_OnPlayerRequestRespawn':
|
||||
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1][0]);
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_PLAYER_REQUEST_RESPAWN, $player);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($callback[1][1][0]);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_PLAYER_REQUEST_RESPAWN, $player);
|
||||
break;
|
||||
case 'OnShoot':
|
||||
$paramsObject = json_decode($callback[1][1]);
|
||||
@ -218,15 +218,15 @@ class StatisticCollector implements CallbackListener {
|
||||
case 'OnNearMiss':
|
||||
$paramsObject = json_decode($callback[1][1]);
|
||||
if ($paramsObject && isset($paramsObject->Event)) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Shooter->Login);
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_NEARMISS, $player);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($paramsObject->Event->Shooter->Login);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_NEARMISS, $player);
|
||||
}
|
||||
break;
|
||||
case 'OnCapture':
|
||||
$paramsObject = json_decode($callback[1][1]);
|
||||
if ($paramsObject && isset($paramsObject->Event)) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Player->Login);
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_CAPTURE, $player);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($paramsObject->Event->Player->Login);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_CAPTURE, $player);
|
||||
}
|
||||
break;
|
||||
case 'OnHit':
|
||||
@ -234,16 +234,16 @@ class StatisticCollector implements CallbackListener {
|
||||
if ($paramsObject && isset($paramsObject->Event)) {
|
||||
$weapon = (int)$paramsObject->Event->WeaponNum;
|
||||
if (isset($paramsObject->Event->Shooter)) {
|
||||
$shooter = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Shooter->Login);
|
||||
$shooter = $this->maniaControl->getPlayerManager()->getPlayer($paramsObject->Event->Shooter->Login);
|
||||
if ($shooter) {
|
||||
$this->maniaControl->statisticManager->incrementStat($this->getWeaponStat($weapon, false), $shooter);
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_HIT, $shooter);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat($this->getWeaponStat($weapon, false), $shooter);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_HIT, $shooter);
|
||||
}
|
||||
}
|
||||
if (isset($paramsObject->Event->Victim)) {
|
||||
$victim = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Victim->Login);
|
||||
$victim = $this->maniaControl->getPlayerManager()->getPlayer($paramsObject->Event->Victim->Login);
|
||||
if ($victim) {
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_GOT_HIT, $victim);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_GOT_HIT, $victim);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -251,22 +251,22 @@ class StatisticCollector implements CallbackListener {
|
||||
case 'OnArmorEmpty':
|
||||
$paramsObject = json_decode($callback[1][1]);
|
||||
if ($paramsObject && isset($paramsObject->Event)) {
|
||||
$victim = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Victim->Login);
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_DEATH, $victim);
|
||||
$victim = $this->maniaControl->getPlayerManager()->getPlayer($paramsObject->Event->Victim->Login);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_DEATH, $victim);
|
||||
if (isset($paramsObject->Event->Shooter->Login)) {
|
||||
$shooter = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Shooter->Login);
|
||||
$shooter = $this->maniaControl->getPlayerManager()->getPlayer($paramsObject->Event->Shooter->Login);
|
||||
if ($shooter) {
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_KILL, $shooter);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_KILL, $shooter);
|
||||
}
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_KILL, $shooter);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_KILL, $shooter);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'OnRequestRespawn':
|
||||
$paramsObject = json_decode($callback[1][1]);
|
||||
if ($paramsObject && isset($paramsObject->Event)) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($paramsObject->Event->Player->Login);
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_ON_PLAYER_REQUEST_RESPAWN, $player);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($paramsObject->Event->Player->Login);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_ON_PLAYER_REQUEST_RESPAWN, $player);
|
||||
}
|
||||
break;
|
||||
case 'EndTurn': //TODO make it for other modes working
|
||||
@ -274,8 +274,8 @@ class StatisticCollector implements CallbackListener {
|
||||
if ($paramsObject && is_array($paramsObject->ScoresTable)) {
|
||||
$durationTime = (int)(($paramsObject->EndTime - $paramsObject->StartTime) / 1000);
|
||||
foreach ($paramsObject->ScoresTable as $score) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($score->Login);
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_PLAYTIME, $player, -1, $durationTime);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($score->Login);
|
||||
$this->maniaControl->getStatisticManager()->insertStat(self::STAT_PLAYTIME, $player, -1, $durationTime);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -298,8 +298,8 @@ class StatisticCollector implements CallbackListener {
|
||||
$this->onShootArray[$login][$weaponNumber]++;
|
||||
|
||||
//Write Shoot Data into database
|
||||
if (array_sum($this->onShootArray[$login]) > $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_ON_SHOOT_PRESTORE)) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
if (array_sum($this->onShootArray[$login]) > $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ON_SHOOT_PRESTORE)) {
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
|
||||
$rocketShots = $this->onShootArray[$login][self::WEAPON_ROCKET];
|
||||
$laserShots = $this->onShootArray[$login][self::WEAPON_LASER];
|
||||
@ -307,23 +307,23 @@ class StatisticCollector implements CallbackListener {
|
||||
$nucleusShots = $this->onShootArray[$login][self::WEAPON_NUCLEUS];
|
||||
|
||||
if ($rocketShots > 0) {
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ROCKET_SHOT, $player, $this->maniaControl->server->index, $rocketShots);
|
||||
$this->maniaControl->getStatisticManager()->insertStat(self::STAT_ROCKET_SHOT, $player, $this->maniaControl->getServer()->index, $rocketShots);
|
||||
$this->onShootArray[$login][self::WEAPON_ROCKET] = 0;
|
||||
}
|
||||
if ($laserShots > 0) {
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_LASER_SHOT, $player, $this->maniaControl->server->index, $laserShots);
|
||||
$this->maniaControl->getStatisticManager()->insertStat(self::STAT_LASER_SHOT, $player, $this->maniaControl->getServer()->index, $laserShots);
|
||||
$this->onShootArray[$login][self::WEAPON_LASER] = 0;
|
||||
}
|
||||
if ($arrowShots > 0) {
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ARROW_SHOT, $player, $this->maniaControl->server->index, $arrowShots);
|
||||
$this->maniaControl->getStatisticManager()->insertStat(self::STAT_ARROW_SHOT, $player, $this->maniaControl->getServer()->index, $arrowShots);
|
||||
$this->onShootArray[$login][self::WEAPON_ARROW] = 0;
|
||||
}
|
||||
if ($nucleusShots > 0) {
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_NUCLEUS_SHOT, $player, $this->maniaControl->server->index, $nucleusShots);
|
||||
$this->maniaControl->getStatisticManager()->insertStat(self::STAT_NUCLEUS_SHOT, $player, $this->maniaControl->getServer()->index, $nucleusShots);
|
||||
$this->onShootArray[$login][self::WEAPON_NUCLEUS] = 0;
|
||||
}
|
||||
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $this->maniaControl->server->index, $rocketShots + $laserShots + $arrowShots + $nucleusShots);
|
||||
$this->maniaControl->getStatisticManager()->insertStat(self::STAT_ON_SHOOT, $player, $this->maniaControl->getServer()->index, $rocketShots + $laserShots + $arrowShots + $nucleusShots);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class StatisticManager {
|
||||
* @return bool
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_STATMETADATA . "` (
|
||||
`index` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
@ -117,7 +117,7 @@ class StatisticManager {
|
||||
* Store Stats Meta Data from the Database
|
||||
*/
|
||||
private function storeStatMetaData() {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
|
||||
$query = "SELECT * FROM `" . self::TABLE_STATMETADATA . "`;";
|
||||
$result = $mysqli->query($query);
|
||||
@ -202,14 +202,15 @@ class StatisticManager {
|
||||
return $this->getStatsRankingOfSpecialStat($statName, $serverIndex);
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$statId = $this->getStatId($statName);
|
||||
|
||||
$query = "SELECT playerId, serverIndex, value FROM `" . self::TABLE_STATISTICS . "` WHERE statId = {$statId}";
|
||||
$query = "SELECT `playerId`, `serverIndex`, `value` FROM `" . self::TABLE_STATISTICS . "`
|
||||
WHERE `statId` = {$statId} ";
|
||||
if ($minValue >= 0) {
|
||||
$query .= " AND value >= {$minValue}";
|
||||
$query .= "AND `value` >= {$minValue} ";
|
||||
}
|
||||
$query .= " ORDER BY value DESC;";
|
||||
$query .= "ORDER BY `value` DESC;";
|
||||
|
||||
$result = $mysqli->query($query);
|
||||
if (!$result) {
|
||||
@ -490,7 +491,7 @@ class StatisticManager {
|
||||
return intval($hits) / intval($shots);
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$statId = $this->getStatId($statName);
|
||||
|
||||
if (!$statId) {
|
||||
@ -498,9 +499,14 @@ class StatisticManager {
|
||||
}
|
||||
|
||||
if ($serverIndex < 0) {
|
||||
$query = "SELECT SUM(value) as value FROM `" . self::TABLE_STATISTICS . "` WHERE `statId` = " . $statId . " AND `playerId` = " . $playerId . ";";
|
||||
$query = "SELECT SUM(`value`) as `value` FROM `" . self::TABLE_STATISTICS . "`
|
||||
WHERE `statId` = {$statId}
|
||||
AND `playerId` = {$playerId};";
|
||||
} else {
|
||||
$query = "SELECT value FROM `" . self::TABLE_STATISTICS . "` WHERE `statId` = " . $statId . " AND `playerId` = " . $playerId . " AND `serverIndex` = '" . $serverIndex . "';";
|
||||
$query = "SELECT `value` FROM `" . self::TABLE_STATISTICS . "`
|
||||
WHERE `statId` = {$statId}
|
||||
AND `playerId` = {$playerId}
|
||||
AND `serverIndex` = {$serverIndex};";
|
||||
}
|
||||
|
||||
$result = $mysqli->query($query);
|
||||
@ -554,10 +560,10 @@ class StatisticManager {
|
||||
}
|
||||
|
||||
if ($serverIndex) {
|
||||
$serverIndex = $this->maniaControl->server->index;
|
||||
$serverIndex = $this->maniaControl->getServer()->index;
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "INSERT INTO `" . self::TABLE_STATISTICS . "` (
|
||||
`serverIndex`,
|
||||
`playerId`,
|
||||
@ -592,7 +598,7 @@ class StatisticManager {
|
||||
* @return bool
|
||||
*/
|
||||
public function defineStatMetaData($statName, $type = self::STAT_TYPE_INT, $statDescription = '') {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "INSERT INTO `" . self::TABLE_STATMETADATA . "` (
|
||||
`name`,
|
||||
`type`,
|
||||
|
Reference in New Issue
Block a user