From c59b5ac9cd8bf7efcb4eef4587ce2d85ddd6e745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Tue, 17 Jun 2014 23:55:59 +0200 Subject: [PATCH] improved variable names --- application/core/Admin/ActionsMenu.php | 20 +++++++--------- .../core/Configurators/ServerSettings.php | 22 +++++++++--------- application/core/Maps/MapList.php | 1 + application/core/Maps/MapQueue.php | 6 ++--- .../plugins/MCTeam/ServerRankingPlugin.php | 23 ++++++++++--------- 5 files changed, 35 insertions(+), 37 deletions(-) diff --git a/application/core/Admin/ActionsMenu.php b/application/core/Admin/ActionsMenu.php index 8c3b55ab..81d0204f 100644 --- a/application/core/Admin/ActionsMenu.php +++ b/application/core/Admin/ActionsMenu.php @@ -174,18 +174,16 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { $itemQuad->addToggleFeature($popoutFrame); // Add items - $x = -1; + $itemPosX = -1; foreach ($this->adminMenuItems as $menuItems) { foreach ($menuItems as $menuItem) { $menuQuad = $menuItem[0]; - /** - * @var Quad $menuQuad - */ + /** @var Quad $menuQuad */ $popoutFrame->add($menuQuad); $menuQuad->setSize($itemSize, $itemSize); - $menuQuad->setX($x); + $menuQuad->setX($itemPosX); $menuQuad->setHAlign(Control::RIGHT); - $x -= $itemSize * 1.05; + $itemPosX -= $itemSize * 1.05; if ($menuItem[1]) { $menuQuad->removeScriptFeatures(); @@ -240,18 +238,16 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { $itemQuad->addToggleFeature($popoutFrame); // Add items - $x = -1; + $itemPosX = -1; foreach ($this->playerMenuItems as $menuItems) { foreach ($menuItems as $menuItem) { $menuQuad = $menuItem[0]; - /** - * @var Quad $menuQuad - */ + /** @var Quad $menuQuad */ $popoutFrame->add($menuQuad); $menuQuad->setSize($itemSize, $itemSize); - $menuQuad->setX($x); + $menuQuad->setX($itemPosX); $menuQuad->setHAlign(Control::RIGHT); - $x -= $itemSize * 1.05; + $itemPosX -= $itemSize * 1.05; if ($menuItem[1]) { $menuQuad->removeScriptFeatures(); diff --git a/application/core/Configurators/ServerSettings.php b/application/core/Configurators/ServerSettings.php index 34f39e4c..68d995af 100644 --- a/application/core/Configurators/ServerSettings.php +++ b/application/core/Configurators/ServerSettings.php @@ -174,27 +174,27 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { $paging->setLabel($pageCountLabel); // Setting pages - $y = 0.; - $id = 0; + $posY = 0.; + $index = 0; $pageFrame = null; foreach ($serverSettings as $name => $value) { // Continue on CurrentMaxPlayers... - $pos = strpos($name, "Current"); // TODO maybe display current somewhere + $pos = strpos($name, 'Current'); // TODO maybe display current somewhere if ($pos !== false) { continue; } - if ($id % 13 === 0) { + if ($index % 13 === 0) { $pageFrame = new Frame(); $frame->add($pageFrame); - $y = $height * 0.41; + $posY = $height * 0.41; $paging->addPage($pageFrame); } $settingFrame = new Frame(); $pageFrame->add($settingFrame); - $settingFrame->setY($y); + $settingFrame->setY($posY); $nameLabel = new Label_Text(); $settingFrame->add($nameLabel); @@ -227,16 +227,16 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { if ($name === 'Comment') { $entry->setAutoNewLine(true); $entry->setSize($width * 0.48, $settingHeight * 3 + $settingHeight * 0.9); - $settingFrame->setY($y - $settingHeight * 1.5); + $settingFrame->setY($posY - $settingHeight * 1.5); // dummy: // TODO: "dummy:" what? remove? - $y -= $settingHeight * 3; - $id += 3; + $posY -= $settingHeight * 3; + $index += 3; } } - $y -= $settingHeight; - $id++; + $posY -= $settingHeight; + $index++; } return $frame; diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index dd9bef36..360f61c2 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -625,6 +625,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $votesPlugin->defineVote('switchmap', "Goto " . $map->name, true, $message); $votesPlugin->startVote($player, 'switchmap', function ($result) use (&$votesPlugin, &$map) { + // TODO: $result isn't used -> bug? does it skip even if vote is not successful? $this->maniaControl->chat->sendInformation('$sVote Successful -> Map switched!'); $votesPlugin->undefineVote('switchmap'); diff --git a/application/core/Maps/MapQueue.php b/application/core/Maps/MapQueue.php index 91665a17..6ea02c63 100644 --- a/application/core/Maps/MapQueue.php +++ b/application/core/Maps/MapQueue.php @@ -167,10 +167,10 @@ class MapQueue implements CallbackListener, CommandListener { } $message = '$fa0Upcoming maps in the Map-Queue:'; - $i = 1; + $index = 1; foreach ($this->queuedMaps as $queuedMap) { - $message .= ' $<$fff' . $i . '$>. [$<$fff' . Formatter::stripCodes($queuedMap[1]->name) . '$>]'; - $i++; + $message .= ' $<$fff' . $index . '$>. [$<$fff' . Formatter::stripCodes($queuedMap[1]->name) . '$>]'; + $index++; } $this->maniaControl->chat->sendInformation($message, $player->login); diff --git a/application/plugins/MCTeam/ServerRankingPlugin.php b/application/plugins/MCTeam/ServerRankingPlugin.php index dae3a7fe..119c4ab0 100644 --- a/application/plugins/MCTeam/ServerRankingPlugin.php +++ b/application/plugins/MCTeam/ServerRankingPlugin.php @@ -198,11 +198,11 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { $accuracies = $this->maniaControl->statisticManager->getStatsRanking(StatisticManager::SPECIAL_STAT_LASER_ACC); $ranks = array(); - foreach ($hits as $player => $hitCount) { - if (!isset($killDeathRatios[$player]) || !isset($accuracies[$player])) { + foreach ($hits as $login => $hitCount) { + if (!isset($killDeathRatios[$login]) || !isset($accuracies[$login])) { continue; } - $ranks[$player] = $killDeathRatios[$player] * $accuracies[$player] * 1000; + $ranks[$login] = $killDeathRatios[$login] * $accuracies[$login] * 1000; } arsort($ranks); @@ -212,7 +212,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { $minHits = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_HITS_POINTS_RANKING); $ranks = $this->maniaControl->statisticManager->getStatsRanking(StatisticCollector::STAT_ON_HIT, -1, $minHits); break; - case self::RANKING_TYPE_RECORDS: //TODO verify workable status + case self::RANKING_TYPE_RECORDS: + // TODO: verify workable status /** @var LocalRecordsPlugin $localRecordsPlugin */ $localRecordsPlugin = $this->maniaControl->pluginManager->getPlugin(__NAMESPACE__ . '\LocalRecordsPlugin'); if (!$localRecordsPlugin) { @@ -252,11 +253,11 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { //compute each players new average score $ranks = array(); - foreach ($players as $player => $val) { + foreach ($players as $playerIndex => $val) { $sum = $val[0]; $cnt = $val[1]; // ranked maps sum + $maxRecs rank for all remaining maps - $ranks[$player] = ($sum + ($mapCount - $cnt) * $maxRecords) / $mapCount; + $ranks[$playerIndex] = ($sum + ($mapCount - $cnt) * $maxRecords) / $mapCount; } asort($ranks); @@ -273,8 +274,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { $query = "INSERT INTO `" . self::TABLE_RANK . "` VALUES "; $index = 1; - foreach ($ranks as $player => $rankValue) { - $query .= '(' . $player . ',' . $index . ',' . $rankValue . '),'; + foreach ($ranks as $playerIndex => $rankValue) { + $query .= '(' . $playerIndex . ',' . $index . ',' . $rankValue . '),'; $index++; } $query = substr($query, 0, strlen($query) - 1); // strip trailing ',' @@ -315,9 +316,9 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { if ($rankObj) { switch ($type) { case self::RANKING_TYPE_RATIOS: - $kd = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_KD_RATIO, $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) . '%$>)'; + $killDeathRatio = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_KD_RATIO, $player->index); + $accuracy = $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($killDeathRatio, 2) . '$> Acc: $<$fff' . round($accuracy * 100) . '%$>)'; break; case self::RANKING_TYPE_POINTS: $message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> Points: $fff' . $rankObj->avg;