small improvements

This commit is contained in:
kremsy 2014-02-06 22:51:32 +01:00 committed by Steffen Schröder
parent c38f6011b8
commit 08e8cd3432
2 changed files with 36 additions and 28 deletions

View File

@ -90,6 +90,14 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
} }
/**
* Register a Certain Stat
* @param $statName
* @param $order
* @param $headShortCut
* @param int $width
* @param string $format
*/
public function registerStat($statName, $order, $headShortCut, $width = 10, $format = StatisticManager::STAT_TYPE_INT) { public function registerStat($statName, $order, $headShortCut, $width = 10, $format = StatisticManager::STAT_TYPE_INT) {
$this->statArray[$order] = array(); $this->statArray[$order] = array();
$this->statArray[$order]["Name"] = $statName; $this->statArray[$order]["Name"] = $statName;

View File

@ -22,10 +22,10 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
const TABLE_RANK = 'mc_rank'; const TABLE_RANK = 'mc_rank';
const RANKING_TYPE_RECORDS = 'Records'; const RANKING_TYPE_RECORDS = 'Records';
const RANKING_TYPE_RATIOS = 'Ratios'; const RANKING_TYPE_RATIOS = 'Ratios';
const RANKING_TYPE_HITS = 'Hits'; const RANKING_TYPE_POINTS = 'Points';
const SETTING_MIN_RANKING_TYPE = 'ServerRankings Type Records/Hits/Ratios'; const SETTING_MIN_RANKING_TYPE = 'ServerRankings Type Records/Points/Ratios';
const SETTING_MIN_HITS_RATIO_RANKING = 'Min Hits on Ratio Rankings'; const SETTING_MIN_HITS_RATIO_RANKING = 'Min Hits on Ratio Rankings';
const SETTING_MIN_HITS_HITS_RANKING = 'Min Hits on Hits Rankings'; const SETTING_MIN_HITS_POINTS_RANKING = 'Min Hits on Points Rankings';
const SETTING_MIN_REQUIRED_RECORDS = 'Minimum amount of records required on Records Ranking'; const SETTING_MIN_REQUIRED_RECORDS = 'Minimum amount of records required on Records Ranking';
const SETTING_MAX_STORED_RECORDS = 'Maximum number of records per map for calculations'; const SETTING_MAX_STORED_RECORDS = 'Maximum number of records per map for calculations';
const CB_RANK_BUILT = 'ServerRankingPlugin.RankBuilt'; const CB_RANK_BUILT = 'ServerRankingPlugin.RankBuilt';
@ -59,7 +59,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
$this->initTables(); $this->initTables();
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING, 100); $maniaControl->settingManager->initSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING, 100);
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_HITS_HITS_RANKING, 15); $maniaControl->settingManager->initSetting($this, self::SETTING_MIN_HITS_POINTS_RANKING, 15);
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_REQUIRED_RECORDS, 3); $maniaControl->settingManager->initSetting($this, self::SETTING_MIN_REQUIRED_RECORDS, 3);
$maniaControl->settingManager->initSetting($this, self::SETTING_MAX_STORED_RECORDS, 50); $maniaControl->settingManager->initSetting($this, self::SETTING_MAX_STORED_RECORDS, 50);
@ -72,13 +72,13 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
} else if ($this->maniaControl->client->getScriptName()["CurrentValue"] == "InstaDM.Script.txt") { } else if ($this->maniaControl->client->getScriptName()["CurrentValue"] == "InstaDM.Script.txt") {
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RATIOS); $maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RATIOS);
} else { } else {
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_HITS); $maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_POINTS);
} }
//Check if the type is Correct //Check if the type is Correct
$type = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_RANKING_TYPE); $type = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_RANKING_TYPE);
if ($type != self::RANKING_TYPE_RECORDS && $type != self::RANKING_TYPE_HITS && $type != self::RANKING_TYPE_RATIOS) { if ($type != self::RANKING_TYPE_RECORDS && $type != self::RANKING_TYPE_POINTS && $type != self::RANKING_TYPE_RATIOS) {
$error = 'Ranking Type is not correct, possible values(' . self::RANKING_TYPE_RATIOS . ', ' . self::RANKING_TYPE_HITS . ', ' . self::RANKING_TYPE_HITS . ')'; $error = 'Ranking Type is not correct, possible values(' . self::RANKING_TYPE_RATIOS . ', ' . self::RANKING_TYPE_POINTS . ', ' . self::RANKING_TYPE_POINTS . ')';
throw new Exception($error); throw new Exception($error);
} }
@ -143,7 +143,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
* @return string * @return string
*/ */
public static function getDescription() { public static function getDescription() {
return "ServerRanking Plugin, Serverranking by an avg build from the records, per count of hits, or by a multiplication from Kill/Death Ratio and Laser accuracy"; return "ServerRanking Plugin, ServerRanking by an avg build from the records, per count of points, or by a multiplication from Kill/Death Ratio and Laser accuracy";
} }
/** /**
@ -195,8 +195,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
break; break;
case self::RANKING_TYPE_HITS: case self::RANKING_TYPE_POINTS:
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_HITS_RANKING); $minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_POINTS_RANKING);
$ranks = $this->maniaControl->statisticManager->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits); $ranks = $this->maniaControl->statisticManager->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits);
@ -322,8 +322,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
$acc = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_LASER_ACC, $player->index); $acc = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_LASER_ACC, $player->index);
$message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> (K/D: $<$fff' . round($kd, 2) . '$> Acc: $<$fff' . round($acc * 100) . '%$>)'; $message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> (K/D: $<$fff' . round($kd, 2) . '$> Acc: $<$fff' . round($acc * 100) . '%$>)';
break; break;
case self::RANKING_TYPE_HITS: case self::RANKING_TYPE_POINTS:
$message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> Hits: $fff' . $rankObj->avg; $message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> Points: $fff' . $rankObj->avg;
break; break;
case self::RANKING_TYPE_RECORDS: case self::RANKING_TYPE_RECORDS:
$message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> Avg: $fff' . round($rankObj->avg, 2); $message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> Avg: $fff' . round($rankObj->avg, 2);
@ -332,15 +332,15 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
switch($type) { switch($type) {
case self::RANKING_TYPE_RATIOS: case self::RANKING_TYPE_RATIOS:
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING); $minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING);
$message = '$0f3 You must make $<$fff' . $minHits . '$> Hits on this server before recieving a rank...'; $message = '$0f3 You must make $<$fff' . $minHits . '$> Hits on this server before receiving a rank...';
break; break;
case self::RANKING_TYPE_HITS: case self::RANKING_TYPE_POINTS:
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_HITS_RANKING); $minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_HITS_POINTS_RANKING);
$message = '$0f3 You must make $<$fff' . $minHits . '$> Hits on this server before recieving a rank...'; $message = '$0f3 You must make $<$fff' . $minHits . '$> Hits on this server before receiving a rank...';
break; break;
case self::RANKING_TYPE_RECORDS: case self::RANKING_TYPE_RECORDS:
$minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_REQUIRED_RECORDS); $minHits = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_REQUIRED_RECORDS);
$message = '$0f3 You need $<$fff' . $minHits . '$> Records on this server before recieving a rank...'; $message = '$0f3 You need $<$fff' . $minHits . '$> Records on this server before receiving a rank...';
} }
} }
$this->maniaControl->chat->sendChat($message, $player->login); $this->maniaControl->chat->sendChat($message, $player->login);