improved variable names

This commit is contained in:
Steffen Schröder 2014-06-17 23:55:59 +02:00
parent b1ce658fc9
commit c59b5ac9cd
5 changed files with 35 additions and 37 deletions

View File

@ -174,18 +174,16 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
$itemQuad->addToggleFeature($popoutFrame); $itemQuad->addToggleFeature($popoutFrame);
// Add items // Add items
$x = -1; $itemPosX = -1;
foreach ($this->adminMenuItems as $menuItems) { foreach ($this->adminMenuItems as $menuItems) {
foreach ($menuItems as $menuItem) { foreach ($menuItems as $menuItem) {
$menuQuad = $menuItem[0]; $menuQuad = $menuItem[0];
/** /** @var Quad $menuQuad */
* @var Quad $menuQuad
*/
$popoutFrame->add($menuQuad); $popoutFrame->add($menuQuad);
$menuQuad->setSize($itemSize, $itemSize); $menuQuad->setSize($itemSize, $itemSize);
$menuQuad->setX($x); $menuQuad->setX($itemPosX);
$menuQuad->setHAlign(Control::RIGHT); $menuQuad->setHAlign(Control::RIGHT);
$x -= $itemSize * 1.05; $itemPosX -= $itemSize * 1.05;
if ($menuItem[1]) { if ($menuItem[1]) {
$menuQuad->removeScriptFeatures(); $menuQuad->removeScriptFeatures();
@ -240,18 +238,16 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
$itemQuad->addToggleFeature($popoutFrame); $itemQuad->addToggleFeature($popoutFrame);
// Add items // Add items
$x = -1; $itemPosX = -1;
foreach ($this->playerMenuItems as $menuItems) { foreach ($this->playerMenuItems as $menuItems) {
foreach ($menuItems as $menuItem) { foreach ($menuItems as $menuItem) {
$menuQuad = $menuItem[0]; $menuQuad = $menuItem[0];
/** /** @var Quad $menuQuad */
* @var Quad $menuQuad
*/
$popoutFrame->add($menuQuad); $popoutFrame->add($menuQuad);
$menuQuad->setSize($itemSize, $itemSize); $menuQuad->setSize($itemSize, $itemSize);
$menuQuad->setX($x); $menuQuad->setX($itemPosX);
$menuQuad->setHAlign(Control::RIGHT); $menuQuad->setHAlign(Control::RIGHT);
$x -= $itemSize * 1.05; $itemPosX -= $itemSize * 1.05;
if ($menuItem[1]) { if ($menuItem[1]) {
$menuQuad->removeScriptFeatures(); $menuQuad->removeScriptFeatures();

View File

@ -174,27 +174,27 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
$paging->setLabel($pageCountLabel); $paging->setLabel($pageCountLabel);
// Setting pages // Setting pages
$y = 0.; $posY = 0.;
$id = 0; $index = 0;
$pageFrame = null; $pageFrame = null;
foreach ($serverSettings as $name => $value) { foreach ($serverSettings as $name => $value) {
// Continue on CurrentMaxPlayers... // Continue on CurrentMaxPlayers...
$pos = strpos($name, "Current"); // TODO maybe display current somewhere $pos = strpos($name, 'Current'); // TODO maybe display current somewhere
if ($pos !== false) { if ($pos !== false) {
continue; continue;
} }
if ($id % 13 === 0) { if ($index % 13 === 0) {
$pageFrame = new Frame(); $pageFrame = new Frame();
$frame->add($pageFrame); $frame->add($pageFrame);
$y = $height * 0.41; $posY = $height * 0.41;
$paging->addPage($pageFrame); $paging->addPage($pageFrame);
} }
$settingFrame = new Frame(); $settingFrame = new Frame();
$pageFrame->add($settingFrame); $pageFrame->add($settingFrame);
$settingFrame->setY($y); $settingFrame->setY($posY);
$nameLabel = new Label_Text(); $nameLabel = new Label_Text();
$settingFrame->add($nameLabel); $settingFrame->add($nameLabel);
@ -227,16 +227,16 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
if ($name === 'Comment') { if ($name === 'Comment') {
$entry->setAutoNewLine(true); $entry->setAutoNewLine(true);
$entry->setSize($width * 0.48, $settingHeight * 3 + $settingHeight * 0.9); $entry->setSize($width * 0.48, $settingHeight * 3 + $settingHeight * 0.9);
$settingFrame->setY($y - $settingHeight * 1.5); $settingFrame->setY($posY - $settingHeight * 1.5);
// dummy: // dummy:
// TODO: "dummy:" what? remove? // TODO: "dummy:" what? remove?
$y -= $settingHeight * 3; $posY -= $settingHeight * 3;
$id += 3; $index += 3;
} }
} }
$y -= $settingHeight; $posY -= $settingHeight;
$id++; $index++;
} }
return $frame; return $frame;

View File

@ -625,6 +625,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$votesPlugin->defineVote('switchmap', "Goto " . $map->name, true, $message); $votesPlugin->defineVote('switchmap', "Goto " . $map->name, true, $message);
$votesPlugin->startVote($player, 'switchmap', function ($result) use (&$votesPlugin, &$map) { $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!'); $this->maniaControl->chat->sendInformation('$sVote Successful -> Map switched!');
$votesPlugin->undefineVote('switchmap'); $votesPlugin->undefineVote('switchmap');

View File

@ -167,10 +167,10 @@ class MapQueue implements CallbackListener, CommandListener {
} }
$message = '$fa0Upcoming maps in the Map-Queue:'; $message = '$fa0Upcoming maps in the Map-Queue:';
$i = 1; $index = 1;
foreach ($this->queuedMaps as $queuedMap) { foreach ($this->queuedMaps as $queuedMap) {
$message .= ' $<$fff' . $i . '$>. [$<$fff' . Formatter::stripCodes($queuedMap[1]->name) . '$>]'; $message .= ' $<$fff' . $index . '$>. [$<$fff' . Formatter::stripCodes($queuedMap[1]->name) . '$>]';
$i++; $index++;
} }
$this->maniaControl->chat->sendInformation($message, $player->login); $this->maniaControl->chat->sendInformation($message, $player->login);

View File

@ -198,11 +198,11 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
$accuracies = $this->maniaControl->statisticManager->getStatsRanking(StatisticManager::SPECIAL_STAT_LASER_ACC); $accuracies = $this->maniaControl->statisticManager->getStatsRanking(StatisticManager::SPECIAL_STAT_LASER_ACC);
$ranks = array(); $ranks = array();
foreach ($hits as $player => $hitCount) { foreach ($hits as $login => $hitCount) {
if (!isset($killDeathRatios[$player]) || !isset($accuracies[$player])) { if (!isset($killDeathRatios[$login]) || !isset($accuracies[$login])) {
continue; continue;
} }
$ranks[$player] = $killDeathRatios[$player] * $accuracies[$player] * 1000; $ranks[$login] = $killDeathRatios[$login] * $accuracies[$login] * 1000;
} }
arsort($ranks); arsort($ranks);
@ -212,7 +212,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
$minHits = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_HITS_POINTS_RANKING); $minHits = $this->maniaControl->settingManager->getSettingValue($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);
break; break;
case self::RANKING_TYPE_RECORDS: //TODO verify workable status case self::RANKING_TYPE_RECORDS:
// TODO: verify workable status
/** @var LocalRecordsPlugin $localRecordsPlugin */ /** @var LocalRecordsPlugin $localRecordsPlugin */
$localRecordsPlugin = $this->maniaControl->pluginManager->getPlugin(__NAMESPACE__ . '\LocalRecordsPlugin'); $localRecordsPlugin = $this->maniaControl->pluginManager->getPlugin(__NAMESPACE__ . '\LocalRecordsPlugin');
if (!$localRecordsPlugin) { if (!$localRecordsPlugin) {
@ -252,11 +253,11 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
//compute each players new average score //compute each players new average score
$ranks = array(); $ranks = array();
foreach ($players as $player => $val) { foreach ($players as $playerIndex => $val) {
$sum = $val[0]; $sum = $val[0];
$cnt = $val[1]; $cnt = $val[1];
// ranked maps sum + $maxRecs rank for all remaining maps // 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); asort($ranks);
@ -273,8 +274,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
$query = "INSERT INTO `" . self::TABLE_RANK . "` VALUES "; $query = "INSERT INTO `" . self::TABLE_RANK . "` VALUES ";
$index = 1; $index = 1;
foreach ($ranks as $player => $rankValue) { foreach ($ranks as $playerIndex => $rankValue) {
$query .= '(' . $player . ',' . $index . ',' . $rankValue . '),'; $query .= '(' . $playerIndex . ',' . $index . ',' . $rankValue . '),';
$index++; $index++;
} }
$query = substr($query, 0, strlen($query) - 1); // strip trailing ',' $query = substr($query, 0, strlen($query) - 1); // strip trailing ','
@ -315,9 +316,9 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
if ($rankObj) { if ($rankObj) {
switch ($type) { switch ($type) {
case self::RANKING_TYPE_RATIOS: case self::RANKING_TYPE_RATIOS:
$kd = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_KD_RATIO, $player->index); $killDeathRatio = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_KD_RATIO, $player->index);
$acc = $this->maniaControl->statisticManager->getStatisticData(StatisticManager::SPECIAL_STAT_LASER_ACC, $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($kd, 2) . '$> Acc: $<$fff' . round($acc * 100) . '%$>)'; $message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> (K/D: $<$fff' . round($killDeathRatio, 2) . '$> Acc: $<$fff' . round($accuracy * 100) . '%$>)';
break; break;
case self::RANKING_TYPE_POINTS: case self::RANKING_TYPE_POINTS:
$message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> Points: $fff' . $rankObj->avg; $message = '$0f3Your Server rank is $<$ff3' . $rankObj->rank . '$> / $<$fff' . $this->recordCount . '$> Points: $fff' . $rankObj->avg;