code refactoring
- improved comparing & checking - improved string composition
This commit is contained in:
@@ -180,7 +180,7 @@ class Player {
|
||||
* @return bool
|
||||
*/
|
||||
public function isFakePlayer() {
|
||||
return ($this->pid <= 0 || $this->path == "");
|
||||
return ($this->pid <= 0 || !$this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,9 +102,9 @@ class PlayerActions {
|
||||
|
||||
$chatMessage = false;
|
||||
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
|
||||
if ($teamId == self::TEAM_BLUE) {
|
||||
if ($teamId === self::TEAM_BLUE) {
|
||||
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Blue-Team!';
|
||||
} else if ($teamId == self::TEAM_RED) {
|
||||
} else if ($teamId === self::TEAM_RED) {
|
||||
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!';
|
||||
}
|
||||
if (!$chatMessage) {
|
||||
@@ -497,7 +497,7 @@ class PlayerActions {
|
||||
public function isPlayerMuted($login) {
|
||||
$ignoreList = $this->maniaControl->client->getIgnoreList(100, 0);
|
||||
foreach ($ignoreList as $ignoredPlayers) {
|
||||
if ($ignoredPlayers->login == $login) {
|
||||
if ($ignoredPlayers->login === $login) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,12 +223,9 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
|
||||
$type = 2;
|
||||
if (isset($params[2]) && is_numeric($params[2])) {
|
||||
$type = intval($params[2]);
|
||||
}
|
||||
$selectable = false;
|
||||
if ($type == 2) {
|
||||
$selectable = true;
|
||||
$type = (int)$params[2];
|
||||
}
|
||||
$selectable = ($type === 2);
|
||||
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
||||
}
|
||||
|
||||
@@ -225,52 +225,51 @@ class PlayerDetailed {
|
||||
$frame = new Frame();
|
||||
|
||||
$playerStats = $this->maniaControl->statisticManager->getAllPlayerStats($player);
|
||||
$y = $this->height / 2 - 15;
|
||||
$x = -$this->width / 2 + 52;
|
||||
$posY = $this->height / 2 - 15;
|
||||
$posX = -$this->width / 2 + 52;
|
||||
$id = 1;
|
||||
|
||||
foreach ($playerStats as $stat) {
|
||||
$statProperties = $stat[0];
|
||||
$value = $stat[1];
|
||||
|
||||
if (floatval($value) == 0) {
|
||||
$value = (float)$stat[1];
|
||||
if (!$value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($statProperties->type == StatisticManager::STAT_TYPE_TIME) {
|
||||
$statProperties = $stat[0];
|
||||
if ($statProperties->type === StatisticManager::STAT_TYPE_TIME) {
|
||||
$value = Formatter::formatTimeHMS($value);
|
||||
} else if ($statProperties->type == StatisticManager::STAT_TYPE_FLOAT) {
|
||||
$value = round(floatval($value), 2);
|
||||
} else if ($statProperties->type === StatisticManager::STAT_TYPE_FLOAT) {
|
||||
$value = round($value, 2);
|
||||
}
|
||||
|
||||
if ($id % 2 != 0) {
|
||||
if ($id % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$frame->add($lineQuad);
|
||||
$lineQuad->setSize(49, 4);
|
||||
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||
$lineQuad->setPosition($x, $y, 0.001);
|
||||
$lineQuad->setPosition($posX, $posY, 0.001);
|
||||
$lineQuad->setHAlign(Control::LEFT);
|
||||
}
|
||||
|
||||
$label = new Label_Text();
|
||||
$frame->add($label);
|
||||
$label->setPosition($x + 4, $y);
|
||||
$label->setPosition($posX + 4, $posY);
|
||||
$label->setText($statProperties->name);
|
||||
$label->setHAlign(Control::LEFT);
|
||||
$label->setTextSize(1.5);
|
||||
|
||||
$label = new Label_Text();
|
||||
$frame->add($label);
|
||||
$label->setPosition($x + 40, $y);
|
||||
$label->setPosition($posX + 40, $posY);
|
||||
$label->setText($value);
|
||||
$label->setTextSize(1.5);
|
||||
|
||||
$y -= 4;
|
||||
$posY -= 4;
|
||||
$id++;
|
||||
|
||||
if ($id > self::STATS_PER_COLUMN) {
|
||||
$y = $this->height / 2 - 15;
|
||||
$x += 47;
|
||||
$posY = $this->height / 2 - 15;
|
||||
$posX += 47;
|
||||
$id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
*/
|
||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||
//unset when another main widget got opened
|
||||
if ($openedWidget != 'PlayerList') {
|
||||
if ($openedWidget !== 'PlayerList') {
|
||||
unset($this->playersListShown[$player->login]);
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame = new Frame();
|
||||
$pageFrame->add($playerFrame);
|
||||
|
||||
if ($i % 2 != 0) {
|
||||
if ($i % 2 !== 0) {
|
||||
$lineQuad = new Quad_BgsPlayerCard();
|
||||
$playerFrame->add($lineQuad);
|
||||
$lineQuad->setSize($width, 4);
|
||||
@@ -200,8 +200,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
|
||||
$playerFrame->setY($y);
|
||||
|
||||
//Show current Player Arrow
|
||||
if ($listPlayer->index == $player->index) {
|
||||
// Show current Player Arrow
|
||||
if ($listPlayer->index === $player->index) {
|
||||
$currentQuad = new Quad_Icons64x64_1();
|
||||
$playerFrame->add($currentQuad);
|
||||
$currentQuad->setX($x + 3.5);
|
||||
@@ -238,14 +238,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
$countryCode = Formatter::mapCountry($listPlayer->getCountry());
|
||||
if ($countryCode != 'OTH') {
|
||||
if ($countryCode !== 'OTH') {
|
||||
// Nation Quad
|
||||
$countryQuad = new Quad();
|
||||
$playerFrame->add($countryQuad);
|
||||
$countryQuad->setImage("file://ZoneFlags/Login/{$listPlayer->login}/country");
|
||||
$countryQuad->setX($x + 98);
|
||||
$countryQuad->setSize(4, 4);
|
||||
$countryQuad->setZ(1);
|
||||
$countryQuad->setSize(4, 4);
|
||||
|
||||
$countryQuad->addTooltipLabelFeature($descriptionLabel, '$<' . $listPlayer->nickname . '$> from ' . $listPlayer->path);
|
||||
}
|
||||
@@ -255,15 +255,15 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($rightQuad);
|
||||
$rightQuad->setX($x + 13);
|
||||
$rightQuad->setZ(3);
|
||||
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
||||
$rightQuad->setSize(7, 3.5);
|
||||
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
||||
|
||||
$rightLabel = new Label_Text();
|
||||
$playerFrame->add($rightLabel);
|
||||
$rightLabel->setX($x + 13.9);
|
||||
$rightLabel->setTextSize(0.8);
|
||||
$rightLabel->setZ(3.1);
|
||||
$rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($listPlayer->authLevel));
|
||||
$rightLabel->setTextSize(0.8);
|
||||
$rightLabel->setTextColor("fff");
|
||||
|
||||
$description = $this->maniaControl->authenticationManager->getAuthLevelName($listPlayer) . " " . $listPlayer->nickname;
|
||||
@@ -274,8 +274,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($playerQuad);
|
||||
$playerQuad->setX($x + 61);
|
||||
$playerQuad->setZ(3);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_TrackInfo);
|
||||
$playerQuad->setSize(2.7, 2.7);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_TrackInfo);
|
||||
$playerQuad->setAction(self::ACTION_OPEN_PLAYER_DETAILED . "." . $listPlayer->login);
|
||||
$description = 'View Statistics of $<' . $listPlayer->nickname . '$>';
|
||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
@@ -285,8 +285,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($playerQuad);
|
||||
$playerQuad->setX($x + 64.5);
|
||||
$playerQuad->setZ(3);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Camera);
|
||||
$playerQuad->setSize(3.8, 3.8);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Camera);
|
||||
$description = 'Spectate $<' . $listPlayer->nickname . '$>';
|
||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$playerQuad->setAction(self::ACTION_SPECTATE_PLAYER . "." . $listPlayer->login);
|
||||
@@ -296,8 +296,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($playerQuad);
|
||||
$playerQuad->setX($x + 68);
|
||||
$playerQuad->setZ(3);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
|
||||
$playerQuad->setSize(3.8, 3.8);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
|
||||
$playerQuad->addPlayerProfileFeature($listPlayer->login);
|
||||
|
||||
// Description Label
|
||||
@@ -310,8 +310,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($playerQuad);
|
||||
$playerQuad->setX($x + 132);
|
||||
$playerQuad->setZ(0.1);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
||||
$playerQuad->setSize(3.8, 3.8);
|
||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
||||
$playerQuad->setAction(self::ACTION_PLAYER_ADV . "." . $listPlayer->login);
|
||||
|
||||
// Description Label
|
||||
@@ -326,9 +326,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($redQuad);
|
||||
$redQuad->setX($x + 145);
|
||||
$redQuad->setZ(0.1);
|
||||
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
||||
$redQuad->setSize(3.8, 3.8);
|
||||
$redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login);
|
||||
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
||||
$redQuad->setAction(self::ACTION_FORCE_RED . '.' . $listPlayer->login);
|
||||
|
||||
// Force to Red-Team Description Label
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Red Team!';
|
||||
@@ -339,9 +339,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($blueQuad);
|
||||
$blueQuad->setX($x + 141);
|
||||
$blueQuad->setZ(0.1);
|
||||
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
||||
$blueQuad->setSize(3.8, 3.8);
|
||||
$blueQuad->setAction(self::ACTION_FORCE_BLUE . "." . $listPlayer->login);
|
||||
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
||||
$blueQuad->setAction(self::ACTION_FORCE_BLUE . '.' . $listPlayer->login);
|
||||
|
||||
// Force to Blue-Team Description Label
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Blue Team!';
|
||||
@@ -353,9 +353,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($kickQuad);
|
||||
$kickQuad->setX($x + 141);
|
||||
$kickQuad->setZ(0.1);
|
||||
$kickQuad->setSubStyle($kickQuad::SUBSTYLE_Validate_Step2);
|
||||
$kickQuad->setSize(3.8, 3.8);
|
||||
$kickQuad->setAction(self::ACTION_KICK_PLAYER_VOTE . "." . $listPlayer->login);
|
||||
$kickQuad->setSubStyle($kickQuad::SUBSTYLE_Validate_Step2);
|
||||
$kickQuad->setAction(self::ACTION_KICK_PLAYER_VOTE . '.' . $listPlayer->login);
|
||||
|
||||
$description = 'Start a Kick Vote on $<' . $listPlayer->nickname . '$>!';
|
||||
$kickQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
@@ -367,9 +367,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($playQuad);
|
||||
$playQuad->setX($x + 143);
|
||||
$playQuad->setZ(0.1);
|
||||
$playQuad->setSubStyle($playQuad::SUBSTYLE_2);
|
||||
$playQuad->setSize(3.8, 3.8);
|
||||
$playQuad->setAction(self::ACTION_FORCE_PLAY . "." . $listPlayer->login);
|
||||
$playQuad->setSubStyle($playQuad::SUBSTYLE_2);
|
||||
$playQuad->setAction(self::ACTION_FORCE_PLAY . '.' . $listPlayer->login);
|
||||
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Play!';
|
||||
$playQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
@@ -382,9 +382,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($spectatorQuad);
|
||||
$spectatorQuad->setX($x + 137);
|
||||
$spectatorQuad->setZ(0.1);
|
||||
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
||||
$spectatorQuad->setSize(3.8, 3.8);
|
||||
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . "." . $listPlayer->login);
|
||||
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
||||
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . '.' . $listPlayer->login);
|
||||
|
||||
// Force to Spectator Description Label
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Spectator!';
|
||||
@@ -395,9 +395,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($spectatorQuad);
|
||||
$spectatorQuad->setX($x + 137);
|
||||
$spectatorQuad->setZ(0.1);
|
||||
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
||||
$spectatorQuad->setSize(3.8, 3.8);
|
||||
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC_VOTE . "." . $listPlayer->login);
|
||||
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
||||
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC_VOTE . '.' . $listPlayer->login);
|
||||
|
||||
// Force to Spectator Description Label
|
||||
$description = 'Start a Vote to force $<' . $listPlayer->nickname . '$> to Spectator!';
|
||||
@@ -409,8 +409,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
// Show advanced window
|
||||
if ($this->playersListShown[$player->login] && $this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW) {
|
||||
$frame = $this->showAdvancedPlayerWidget($player, $this->playersListShown[$player->login]);
|
||||
$listShownValue = $this->playersListShown[$player->login];
|
||||
if ($listShownValue && $listShownValue !== self::SHOWN_MAIN_WINDOW) {
|
||||
$frame = $this->showAdvancedPlayerWidget($player, $listShownValue);
|
||||
$maniaLink->add($frame);
|
||||
}
|
||||
|
||||
@@ -773,7 +774,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
// Reopen widget
|
||||
if ($shown != self::SHOWN_MAIN_WINDOW) {
|
||||
if ($shown !== self::SHOWN_MAIN_WINDOW) {
|
||||
$this->playersListShown[$login] = false;
|
||||
}
|
||||
$this->showPlayerList($player);
|
||||
|
||||
@@ -123,7 +123,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
$detailedPlayerInfo = $this->maniaControl->client->getDetailedPlayerInfo($playerItem->login);
|
||||
|
||||
//Check if the Player is in a Team, to notify if its a TeamMode or not
|
||||
if ($playerItem->teamId != -1) {
|
||||
if ($playerItem->teamId >= 0) {
|
||||
$this->maniaControl->server->setTeamMode(true);
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
$player->teamId = $callback[1][0]["TeamId"];
|
||||
|
||||
//Check if the Player is in a Team, to notify if its a TeamMode or not
|
||||
if ($player->teamId != -1) {
|
||||
if ($player->teamId >= 0) {
|
||||
$this->maniaControl->server->setTeamMode(true);
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
*/
|
||||
public function getPlayerByIndex($index, $connectedPlayersOnly = false) {
|
||||
foreach ($this->players as $player) {
|
||||
if ($player->index == $index) {
|
||||
if ($player->index === $index) {
|
||||
return $player;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user