some changes

This commit is contained in:
kremsy 2014-01-03 19:14:07 +01:00
parent f29a83a8bc
commit 176b9eef6d
4 changed files with 26 additions and 12 deletions

View File

@ -8,8 +8,10 @@ use FML\Controls\Quad;
use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\ManiaLink; use FML\ManiaLink;
use FML\Script\Script; use FML\Script\Script;
use ManiaControl\Formatter;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Statistics\StatisticManager;
/** /**
* Player Detailed Page * Player Detailed Page
@ -225,6 +227,10 @@ class PlayerDetailed {
$statProperties = $stat[0]; $statProperties = $stat[0];
$value = $stat[1]; $value = $stat[1];
if($statProperties->type == StatisticManager::STAT_TYPE_TIME){
$value = Formatter::formatTimeH($value);
}
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
$label->setPosition(-$this->width / 2 + 70, $y); $label->setPosition(-$this->width / 2 + 70, $y);

View File

@ -10,6 +10,7 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Formatter; use ManiaControl\Formatter;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Statistics\StatisticManager;
/** /**
* Class managing players * Class managing players
@ -66,7 +67,7 @@ class PlayerManager implements CallbackListener {
// Define player stats // Define player stats
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_JOIN_COUNT); $this->maniaControl->statisticManager->defineStatMetaData(self::STAT_JOIN_COUNT);
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYTIME); $this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYTIME, StatisticManager::STAT_TYPE_TIME);
} }
/** /**

View File

@ -30,6 +30,9 @@ class StatisticCollector implements CallbackListener {
const STAT_ON_DEATH = 'Deaths'; const STAT_ON_DEATH = 'Deaths';
const STAT_ON_PLAYER_REQUEST_RESPAWN = 'Respawns'; const STAT_ON_PLAYER_REQUEST_RESPAWN = 'Respawns';
const STAT_ON_KILL = 'Kills'; const STAT_ON_KILL = 'Kills';
const SPECIAL_STAT_KILL_DEATH_RATIO = 'Kill / Death';
/** /**
* Private Properties * Private Properties
*/ */

View File

@ -22,6 +22,7 @@ class StatisticManager {
const TABLE_STATISTICS = 'mc_statistics'; const TABLE_STATISTICS = 'mc_statistics';
const STAT_TYPE_INT = '0'; const STAT_TYPE_INT = '0';
const STAT_TYPE_TIME = '1';
/** /**
* Public Properties * Public Properties
@ -207,29 +208,32 @@ class StatisticManager {
return $this->insertStat($statName, $player, $serverLogin, 1); return $this->insertStat($statName, $player, $serverLogin, 1);
} }
/** /**
* Defines a Stat * Defines a Stat
* *
* @param string $statName * @param $statName
* @param string $statDescription
* @param string $type * @param string $type
* @param string $statDescription
* @return bool * @return bool
*/ */
public function defineStatMetaData($statName, $statDescription = '', $type = self::STAT_TYPE_INT) { public function defineStatMetaData($statName, $type = self::STAT_TYPE_INT, $statDescription = '') {
$mysqli = $this->maniaControl->database->mysqli; $mysqli = $this->maniaControl->database->mysqli;
$query = "INSERT IGNORE INTO `" . self::TABLE_STATMETADATA . "` ( $query = "INSERT INTO `" . self::TABLE_STATMETADATA . "` (
`name`, `name`,
`type`, `type`,
`description` `description`
) VALUES ( ) VALUES (
?, ?, ? ?, ?, ?
);"; ) ON DUPLICATE KEY UPDATE
`type` = VALUES(`type`),
`description` = VALUES(`description`);";
$statement = $mysqli->prepare($query); $statement = $mysqli->prepare($query);
if($mysqli->error) { if($mysqli->error) {
trigger_error($mysqli->error); trigger_error($mysqli->error);
return false; return false;
} }
$statement->bind_param('sss', $statName, $type, $statDescription); $statement->bind_param('sis', $statName, $type, $statDescription);
$statement->execute(); $statement->execute();
if($statement->error) { if($statement->error) {
trigger_error($statement->error); trigger_error($statement->error);
@ -253,7 +257,7 @@ class StatisticManager {
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_STATMETADATA . "` ( $query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_STATMETADATA . "` (
`index` int(11) NOT NULL AUTO_INCREMENT, `index` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`type` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `type` int(5) NOT NULL,
`description` varchar(150) COLLATE utf8_unicode_ci, `description` varchar(150) COLLATE utf8_unicode_ci,
PRIMARY KEY (`index`), PRIMARY KEY (`index`),
UNIQUE KEY `name` (`name`) UNIQUE KEY `name` (`name`)