From d8513733ecf3f6d7441e31a2016e73b72bc961fc Mon Sep 17 00:00:00 2001 From: kremsy Date: Tue, 31 Dec 2013 21:41:52 +0100 Subject: [PATCH] added statisticcollector class --- .../core/Statistics/StatisticCollector.php | 71 +++++++++++++++++++ .../core/Statistics/StatisticManager.php | 10 +++ 2 files changed, 81 insertions(+) create mode 100644 application/core/Statistics/StatisticCollector.php 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(); }