From 82ff05d6dd26d07d91dd8eb222cf574c4d7a657e Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 12 Feb 2017 14:52:16 -0700 Subject: [PATCH] Improved & more consistent method naming and calls --- attack.php | 2 +- classes/Ibank.php | 4 ---- classes/Kabal.php | 2 -- classes/Loan.php | 4 ---- classes/Log.php | 4 ---- classes/Login.php | 4 ++-- classes/Planet.php | 2 +- classes/PlanetReport.php | 2 +- classes/PlanetReportCE.php | 4 ---- classes/Player.php | 4 ++-- classes/Team.php | 2 +- planet.php | 2 +- planet_report.php | 4 ++-- ship.php | 2 +- 14 files changed, 12 insertions(+), 30 deletions(-) diff --git a/attack.php b/attack.php index d819bfc46..59f3de8b3 100644 --- a/attack.php +++ b/attack.php @@ -74,7 +74,7 @@ { echo $langvars['l_att_noturn'] . '

'; } -elseif (Tki\Team::sameTeam($playerinfo['team'], $targetinfo['team'])) +elseif (Tki\Team::isSameTeam($playerinfo['team'], $targetinfo['team'])) { echo "
" . $langvars['l_team_noattack_members'] . "
\n"; } diff --git a/classes/Ibank.php b/classes/Ibank.php index c8ad60654..79eb117e1 100644 --- a/classes/Ibank.php +++ b/classes/Ibank.php @@ -17,10 +17,6 @@ // along with this program. If not, see . // // File: classes/Ibank.php -// -// FUTURE: These are horribly bad. They should be broken out of classes, and turned mostly into template -// behaviors. But in the interest of saying goodbye to the includes directory, and raw functions, this -// will at least allow us to auto-load and use classes instead. Plenty to do in the future, though! namespace Tki; diff --git a/classes/Kabal.php b/classes/Kabal.php index 1b3d9328d..5c06079df 100644 --- a/classes/Kabal.php +++ b/classes/Kabal.php @@ -17,8 +17,6 @@ // along with this program. If not, see . // // File: classes/Kabal.php -// -// FUTURE: This class is horribly bad, and needs to be refactored and tested. namespace Tki; diff --git a/classes/Loan.php b/classes/Loan.php index 86b051aa6..73f5a9bc1 100644 --- a/classes/Loan.php +++ b/classes/Loan.php @@ -17,10 +17,6 @@ // along with this program. If not, see . // // File: classes/Loan.php -// -// FUTURE: These are horribly bad. They should be broken out of classes, and turned mostly into template -// behaviors. But in the interest of saying goodbye to the includes directory, and raw functions, this -// will at least allow us to auto-load and use classes instead. Plenty to do in the future, though! namespace Tki; diff --git a/classes/Log.php b/classes/Log.php index 6e6edd304..2b5b02ccd 100644 --- a/classes/Log.php +++ b/classes/Log.php @@ -17,10 +17,6 @@ // along with this program. If not, see . // // File: classes/Log.php -// -// FUTURE: These are horribly bad. They should be broken out of classes, and turned mostly into template -// behaviors. But in the interest of saying goodbye to the includes directory, and raw functions, this -// will at least allow us to auto-load and use classes instead. Plenty to do in the future, though! namespace Tki; diff --git a/classes/Login.php b/classes/Login.php index 531b34ecc..b6d1586db 100644 --- a/classes/Login.php +++ b/classes/Login.php @@ -31,7 +31,7 @@ public static function checkLogin(\PDO $pdo_db, string $lang, Reg $tkireg, Smart Game::isGameClosed($pdo_db, $tkireg, $lang, $template, $langvars); // Handle authentication check - Will die if fails, or return correct playerinfo - $playerinfo = Player::handleAuth($pdo_db, $lang, $langvars, $tkireg, $template); + $playerinfo = Player::auth($pdo_db, $lang, $langvars, $tkireg, $template); // Establish timestamp for interval in checking bans $stamp = date('Y-m-d H:i:s'); @@ -40,7 +40,7 @@ public static function checkLogin(\PDO $pdo_db, string $lang, Reg $tkireg, Smart $timestamp['last'] = (int) strtotime($playerinfo['last_login']); // Check for ban - Ignore the false return if not - Player::handleBan($pdo_db, $lang, $timestamp, $template, $playerinfo, $langvars, $tkireg); + Player::ban($pdo_db, $lang, $timestamp, $template, $playerinfo, $langvars, $tkireg); // Check for destroyed ship - Ignore the false return if not Ship::isDestroyed($pdo_db, $lang, $tkireg, $langvars, $template, $playerinfo); diff --git a/classes/Planet.php b/classes/Planet.php index f181d2b71..501150f68 100644 --- a/classes/Planet.php +++ b/classes/Planet.php @@ -45,7 +45,7 @@ public function getOwner(\PDO $pdo_db, int $planet_id, &$owner_info): bool return false; } - public static function planetBombing(\PDO $pdo_db, string $lang, array $langvars, Reg $tkireg, array $playerinfo, array $ownerinfo, array $planetinfo, Smarty $template): void + public static function bombing(\PDO $pdo_db, string $lang, array $langvars, Reg $tkireg, array $playerinfo, array $ownerinfo, array $planetinfo, Smarty $template): void { if ($playerinfo['turns'] < 1) { diff --git a/classes/PlanetReport.php b/classes/PlanetReport.php index 499c3a5b9..3d350036c 100644 --- a/classes/PlanetReport.php +++ b/classes/PlanetReport.php @@ -38,7 +38,7 @@ public static function baseBuildCheck($langvars, Reg $tkireg, $planet, int $i): } } - public static function planetReportMenu(array $playerinfo, array $langvars): void + public static function menu(array $playerinfo, array $langvars): void { echo "
\n"; echo "Planet Status
" . diff --git a/classes/PlanetReportCE.php b/classes/PlanetReportCE.php index 14b60c067..ab7071a87 100644 --- a/classes/PlanetReportCE.php +++ b/classes/PlanetReportCE.php @@ -17,10 +17,6 @@ // along with this program. If not, see . // // File: classes/PlanetReportCE.php -// -// FUTURE: These are horribly bad. They should be broken out of classes, and turned mostly into template -// behaviors. But in the interest of saying goodbye to the includes directory, and raw functions, this -// will at least allow us to auto-load and use classes instead. Plenty to do in the future, though! namespace Tki; diff --git a/classes/Player.php b/classes/Player.php index e99d92c67..4a7f6670c 100644 --- a/classes/Player.php +++ b/classes/Player.php @@ -24,7 +24,7 @@ class Player { - public static function handleAuth(\PDO $pdo_db, string $lang, array $langvars, Reg $tkireg, Smarty $template) + public static function auth(\PDO $pdo_db, string $lang, array $langvars, Reg $tkireg, Smarty $template) { $request = Request::createFromGlobals(); $flag = true; @@ -97,7 +97,7 @@ public static function handleAuth(\PDO $pdo_db, string $lang, array $langvars, R } } - public static function handleBan(\PDO $pdo_db, string $lang, $timestamp, Smarty $template, array $playerinfo, array $langvars, Reg $tkireg) + public static function ban(\PDO $pdo_db, string $lang, $timestamp, Smarty $template, array $playerinfo, array $langvars, Reg $tkireg) { // Check to see if the player is banned every 60 seconds (may need to ajust this). if ($timestamp['now'] >= ($timestamp['last'] + 60)) diff --git a/classes/Team.php b/classes/Team.php index 753a4c983..892d29953 100644 --- a/classes/Team.php +++ b/classes/Team.php @@ -22,7 +22,7 @@ class Team { - public static function sameTeam($attacker_team = null, $attackie_team = null) : bool + public static function isSameTeam($attacker_team = null, $attackie_team = null) : bool { if (($attacker_team != $attackie_team) || ($attacker_team == 0 || $attackie_team == 0)) { diff --git a/planet.php b/planet.php index 25538ffac..9e767ebf0 100644 --- a/planet.php +++ b/planet.php @@ -636,7 +636,7 @@ } elseif ($command == "bomb" && $tkireg->allow_sofa) { - Planet::planetBombing($pdo_db, $lang, $langvars, $tkireg, $playerinfo, $ownerinfo, $planetinfo, $template); + Planet::bombing($pdo_db, $lang, $langvars, $tkireg, $playerinfo, $ownerinfo, $planetinfo, $template); } elseif ($command == "scan") { diff --git a/planet_report.php b/planet_report.php index b2dd39cf2..ba006677e 100644 --- a/planet_report.php +++ b/planet_report.php @@ -56,13 +56,13 @@ { $title = $title . ": Menu"; echo "

" . $title . "

\n"; - Tki\PlanetReport::planetReportMenu($playerinfo, $langvars); + Tki\PlanetReport::menu($playerinfo, $langvars); } else // Display the menu if no valid options are passed in { $title = $title . ": Status"; echo "

" . $title . "

\n"; - Tki\PlanetReport::planetReportMenu($playerinfo, $langvars); + Tki\PlanetReport::menu($playerinfo, $langvars); } echo "

"; diff --git a/ship.php b/ship.php index bb2dcb56c..2d7c93d30 100644 --- a/ship.php +++ b/ship.php @@ -55,7 +55,7 @@ echo $langvars['l_ship_perform'] . "

"; echo "" . $langvars['l_planet_scn_link'] . "
"; - if (!Tki\Team::sameTeam($playerinfo['team'], $othership['team'])) + if (!Tki\Team::isSameTeam($playerinfo['team'], $othership['team'])) { echo "" . $langvars['l_planet_att_link'] . "
"; }