diff --git a/application/core/Statistics/StatisticCollector.php b/application/core/Statistics/StatisticCollector.php new file mode 100644 index 00000000..5f0a2e54 --- /dev/null +++ b/application/core/Statistics/StatisticCollector.php @@ -0,0 +1,71 @@ +maniaControl = $maniaControl; + + //Register Callbacks + $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACK, $this, 'handleCallbacks'); + $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACKARRAY, $this, 'handleCallbacks'); + + //Initialize Settings + $this->maniaControl->settingManager->initSetting($this, self::SETTING_COLLECT_STATS_ENABLED, true); + $this->maniaControl->settingManager->initSetting($this, self::SETTING_COLLECT_STATS_MINPLAYERS, 4); + + //Define Stats MetaData + $this->maniaControl->statisticManager->defineStatMetaData(self::STAT_ON_SHOOT); + } + + + /** + * Handle stats on callbacks + * @param array $callback + */ + public function handleCallbacks(array $callback) { + + //Check if Stat Collecting is enabled + if(!$this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_ENABLED)) { + return; + } + + //Check for Minplayer + if(count($this->maniaControl->playerManager->getPlayers()) < $this->maniaControl->settingManager->getSetting($this, self::SETTING_COLLECT_STATS_MINPLAYERS)) { + return; + } + + var_dump($callback); + + } +} \ No newline at end of file diff --git a/application/core/Statistics/StatisticManager.php b/application/core/Statistics/StatisticManager.php index 65b4f47e..fef00c75 100644 --- a/application/core/Statistics/StatisticManager.php +++ b/application/core/Statistics/StatisticManager.php @@ -1,6 +1,9 @@ mysqli = $this->maniaControl->database->mysqli; $this->initTables(); + $this->statisticCollector = new StatisticCollector($maniaControl); + //Store Stats MetaData $this->storeStatMetaData(); }