We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -41,8 +41,8 @@ |
||
| 41 | 41 | |
| 42 | 42 | function teamAttack(&$results, $fightingPlayers, $attack, $defend) { |
| 43 | 43 | foreach ($fightingPlayers[$attack] as $accountID => $teamPlayer) { |
| 44 | - $playerResults =& $teamPlayer->shootPlayers($fightingPlayers[$defend]); |
|
| 45 | - $results[$attack]['Traders'][$teamPlayer->getAccountID()] =& $playerResults; |
|
| 44 | + $playerResults = & $teamPlayer->shootPlayers($fightingPlayers[$defend]); |
|
| 45 | + $results[$attack]['Traders'][$teamPlayer->getAccountID()] = & $playerResults; |
|
| 46 | 46 | $results[$attack]['TotalDamage'] += $playerResults['TotalDamage']; |
| 47 | 47 | |
| 48 | 48 | // Award assists (if there are multiple attackers) |
@@ -1,30 +1,36 @@ discard block |
||
| 1 | 1 | <?php declare(strict_types=1); |
| 2 | 2 | |
| 3 | -if ($player->hasNewbieTurns()) |
|
| 3 | +if ($player->hasNewbieTurns()) { |
|
| 4 | 4 | create_error('You are under newbie protection.'); |
| 5 | -if ($player->hasFederalProtection()) |
|
| 5 | +} |
|
| 6 | +if ($player->hasFederalProtection()) { |
|
| 6 | 7 | create_error('You are under federal protection.'); |
| 7 | -if ($player->isLandedOnPlanet()) |
|
| 8 | +} |
|
| 9 | +if ($player->isLandedOnPlanet()) { |
|
| 8 | 10 | create_error('You cannot attack whilst on a planet!'); |
| 9 | -if ($player->getTurns() < 3) |
|
| 11 | +} |
|
| 12 | +if ($player->getTurns() < 3) { |
|
| 10 | 13 | create_error('You have insufficient turns to perform that action.'); |
| 11 | -if (!$player->canFight()) |
|
| 14 | +} |
|
| 15 | +if (!$player->canFight()) { |
|
| 12 | 16 | create_error('You are not allowed to fight!'); |
| 17 | +} |
|
| 13 | 18 | |
| 14 | 19 | $targetPlayer = SmrPlayer::getPlayer($var['target'], $player->getGameID()); |
| 15 | 20 | |
| 16 | - if ($player->traderNAPAlliance($targetPlayer)) |
|
| 17 | - create_error('Your alliance does not allow you to attack this trader.'); |
|
| 18 | - else if ($targetPlayer->isDead()) |
|
| 19 | - create_error('Target is already dead.'); |
|
| 20 | - else if ($targetPlayer->getSectorID() != $player->getSectorID()) |
|
| 21 | - create_error('Target is no longer in this sector.'); |
|
| 22 | - else if ($targetPlayer->hasNewbieTurns()) |
|
| 23 | - create_error('Target is under newbie protection.'); |
|
| 24 | - else if ($targetPlayer->isLandedOnPlanet()) |
|
| 25 | - create_error('Target is protected by planetary shields.'); |
|
| 26 | - else if ($targetPlayer->hasFederalProtection()) |
|
| 27 | - create_error('Target is under federal protection.'); |
|
| 21 | + if ($player->traderNAPAlliance($targetPlayer)) { |
|
| 22 | + create_error('Your alliance does not allow you to attack this trader.'); |
|
| 23 | + } else if ($targetPlayer->isDead()) { |
|
| 24 | + create_error('Target is already dead.'); |
|
| 25 | + } else if ($targetPlayer->getSectorID() != $player->getSectorID()) { |
|
| 26 | + create_error('Target is no longer in this sector.'); |
|
| 27 | + } else if ($targetPlayer->hasNewbieTurns()) { |
|
| 28 | + create_error('Target is under newbie protection.'); |
|
| 29 | + } else if ($targetPlayer->isLandedOnPlanet()) { |
|
| 30 | + create_error('Target is protected by planetary shields.'); |
|
| 31 | + } else if ($targetPlayer->hasFederalProtection()) { |
|
| 32 | + create_error('Target is under federal protection.'); |
|
| 33 | + } |
|
| 28 | 34 | |
| 29 | 35 | $fightingPlayers = $sector->getFightingTraders($player, $targetPlayer); |
| 30 | 36 | |
@@ -76,10 +82,11 @@ discard block |
||
| 76 | 82 | $container = create_container('skeleton.php', 'trader_attack.php'); |
| 77 | 83 | |
| 78 | 84 | // If their target is dead there is no continue attack button |
| 79 | -if (!$targetPlayer->isDead()) |
|
| 85 | +if (!$targetPlayer->isDead()) { |
|
| 80 | 86 | $container['target'] = $var['target']; |
| 81 | -else |
|
| 87 | +} else { |
|
| 82 | 88 | $container['target'] = 0; |
| 89 | +} |
|
| 83 | 90 | |
| 84 | 91 | // If they died on the shot they get to see the results |
| 85 | 92 | if ($player->isDead()) { |
@@ -72,18 +72,18 @@ |
||
| 72 | 72 | |
| 73 | 73 | // If mines are bumped, the forces shoot first. Otherwise player shoots first. |
| 74 | 74 | if ($bump) { |
| 75 | - $results['Forces'] =& $forces->shootPlayers($attackers, $bump); |
|
| 75 | + $results['Forces'] = & $forces->shootPlayers($attackers, $bump); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $results['Attackers'] = array('TotalDamage' => 0); |
| 79 | 79 | foreach ($attackers as $attacker) { |
| 80 | - $playerResults =& $attacker->shootForces($forces); |
|
| 81 | - $results['Attackers']['Traders'][$attacker->getAccountID()] =& $playerResults; |
|
| 80 | + $playerResults = & $attacker->shootForces($forces); |
|
| 81 | + $results['Attackers']['Traders'][$attacker->getAccountID()] = & $playerResults; |
|
| 82 | 82 | $results['Attackers']['TotalDamage'] += $playerResults['TotalDamage']; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | if (!$bump) { |
| 86 | - $results['Forces'] =& $forces->shootPlayers($attackers, $bump); |
|
| 86 | + $results['Forces'] = & $forces->shootPlayers($attackers, $bump); |
|
| 87 | 87 | $forces->updateExpire(); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -3,16 +3,21 @@ discard block |
||
| 3 | 3 | $forces = SmrForce::getForce($player->getGameID(), $player->getSectorID(), $var['owner_id']); |
| 4 | 4 | $forceOwner = $forces->getOwner(); |
| 5 | 5 | |
| 6 | -if ($player->hasNewbieTurns()) |
|
| 6 | +if ($player->hasNewbieTurns()) { |
|
| 7 | 7 | create_error('You are under newbie protection!'); |
| 8 | -if ($player->hasFederalProtection()) |
|
| 8 | +} |
|
| 9 | +if ($player->hasFederalProtection()) { |
|
| 9 | 10 | create_error('You are under federal protection.'); |
| 10 | -if ($player->isLandedOnPlanet()) |
|
| 11 | +} |
|
| 12 | +if ($player->isLandedOnPlanet()) { |
|
| 11 | 13 | create_error('You cannot attack forces whilst on a planet!'); |
| 12 | -if (!$player->canFight()) |
|
| 14 | +} |
|
| 15 | +if (!$player->canFight()) { |
|
| 13 | 16 | create_error('You are not allowed to fight!'); |
| 14 | -if ($player->forceNAPAlliance($forceOwner)) |
|
| 17 | +} |
|
| 18 | +if ($player->forceNAPAlliance($forceOwner)) { |
|
| 15 | 19 | create_error('You cannot attack allied forces!'); |
| 20 | +} |
|
| 16 | 21 | |
| 17 | 22 | // The attack is processed slightly differently if the attacker bumped into mines |
| 18 | 23 | // when moving into sector |
@@ -25,16 +30,20 @@ discard block |
||
| 25 | 30 | } |
| 26 | 31 | |
| 27 | 32 | if ($bump) { |
| 28 | - if (!$forces->hasMines()) |
|
| 29 | - create_error('No mines in sector!'); |
|
| 30 | -} else { |
|
| 31 | - if (!$forces->exists()) |
|
| 32 | - create_error('These forces no longer exist.'); |
|
| 33 | - if ($player->getTurns() < $forces->getAttackTurnCost($ship)) |
|
| 34 | - create_error('You do not have enough turns to attack these forces!'); |
|
| 35 | - if (!$ship->hasWeapons() && !$ship->hasCDs()) |
|
| 36 | - create_error('You cannot attack without weapons!'); |
|
| 37 | -} |
|
| 33 | + if (!$forces->hasMines()) { |
|
| 34 | + create_error('No mines in sector!'); |
|
| 35 | + } |
|
| 36 | + } else { |
|
| 37 | + if (!$forces->exists()) { |
|
| 38 | + create_error('These forces no longer exist.'); |
|
| 39 | + } |
|
| 40 | + if ($player->getTurns() < $forces->getAttackTurnCost($ship)) { |
|
| 41 | + create_error('You do not have enough turns to attack these forces!'); |
|
| 42 | + } |
|
| 43 | + if (!$ship->hasWeapons() && !$ship->hasCDs()) { |
|
| 44 | + create_error('You cannot attack without weapons!'); |
|
| 45 | + } |
|
| 46 | + } |
|
| 38 | 47 | |
| 39 | 48 | // take the turns |
| 40 | 49 | if ($bump) { |
@@ -103,10 +112,11 @@ discard block |
||
| 103 | 112 | $container = create_container('skeleton.php', 'forces_attack.php'); |
| 104 | 113 | |
| 105 | 114 | // If their target is dead there is no continue attack button |
| 106 | -if ($forces->exists()) |
|
| 115 | +if ($forces->exists()) { |
|
| 107 | 116 | $container['owner_id'] = $forces->getOwnerID(); |
| 108 | -else |
|
| 117 | +} else { |
|
| 109 | 118 | $container['owner_id'] = 0; |
| 119 | +} |
|
| 110 | 120 | |
| 111 | 121 | // If they died on the shot they get to see the results |
| 112 | 122 | if ($player->isDead()) { |
@@ -4,7 +4,9 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | $fn_seedlist = function($message) { |
| 6 | 6 | $link = new GameLink($message->channel, $message->author); |
| 7 | - if (!$link->valid) return; |
|
| 7 | + if (!$link->valid) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 8 | 10 | |
| 9 | 11 | // print the entire seedlist |
| 10 | 12 | $results = shared_channel_msg_seedlist($link->player); |
@@ -13,7 +15,9 @@ discard block |
||
| 13 | 15 | |
| 14 | 16 | $fn_seedlist_add = function($message, $sectors) { |
| 15 | 17 | $link = new GameLink($message->channel, $message->author); |
| 16 | - if (!$link->valid) return; |
|
| 18 | + if (!$link->valid) { |
|
| 19 | + return; |
|
| 20 | + } |
|
| 17 | 21 | |
| 18 | 22 | // add sectors to the seedlist |
| 19 | 23 | $results = shared_channel_msg_seedlist_add($link->player, $sectors); |
@@ -22,7 +26,9 @@ discard block |
||
| 22 | 26 | |
| 23 | 27 | $fn_seedlist_del = function($message, $sectors) { |
| 24 | 28 | $link = new GameLink($message->channel, $message->author); |
| 25 | - if (!$link->valid) return; |
|
| 29 | + if (!$link->valid) { |
|
| 30 | + return; |
|
| 31 | + } |
|
| 26 | 32 | |
| 27 | 33 | // delete sectors from the seedlist |
| 28 | 34 | $results = shared_channel_msg_seedlist_del($link->player, $sectors); |
@@ -45,8 +45,9 @@ discard block |
||
| 45 | 45 | // delete any old entries in the list |
| 46 | 46 | foreach ($sds as $key => $value) { |
| 47 | 47 | |
| 48 | - if ($value[3] != $channel) |
|
| 49 | - continue; |
|
| 48 | + if ($value[3] != $channel) { |
|
| 49 | + continue; |
|
| 50 | + } |
|
| 50 | 51 | |
| 51 | 52 | if ($value[0] == $sector) { |
| 52 | 53 | unset($sds[$key]); |
@@ -82,8 +83,9 @@ discard block |
||
| 82 | 83 | |
| 83 | 84 | foreach ($sds as $key => $sd) { |
| 84 | 85 | |
| 85 | - if ($sd[3] != $channel) |
|
| 86 | - continue; |
|
| 86 | + if ($sd[3] != $channel) { |
|
| 87 | + continue; |
|
| 88 | + } |
|
| 87 | 89 | |
| 88 | 90 | if ($sd[0] == $sector) { |
| 89 | 91 | fputs($fp, 'PRIVMSG ' . $channel . ' :The supply/demand for sector ' . $sector . ' has been deleted.' . EOL); |
@@ -121,7 +123,9 @@ discard block |
||
| 121 | 123 | if ($sd[3] == $channel) { |
| 122 | 124 | |
| 123 | 125 | $seconds_since_refresh = time() - $sd[2]; |
| 124 | - if ($seconds_since_refresh < 0) $seconds_since_refresh = 0; |
|
| 126 | + if ($seconds_since_refresh < 0) { |
|
| 127 | + $seconds_since_refresh = 0; |
|
| 128 | + } |
|
| 125 | 129 | $amt_to_add = floor($seconds_since_refresh * $refresh_per_sec); |
| 126 | 130 | |
| 127 | 131 | if ($sd[1] + $amt_to_add > 4000) { |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | // Delete all tickets and re-insert the winning ticket |
| 24 | 24 | $db->query('DELETE FROM player_has_ticket WHERE game_id = ' . $db->escapeNumber($gameID)); |
| 25 | 25 | $db->query('INSERT INTO player_has_ticket (game_id, account_id, time, prize) ' |
| 26 | - .'VALUES (' . $db->escapeNumber($gameID) . ',' . $db->escapeNumber($winner_id) . ',\'0\',' . $db->escapeNumber($lottoInfo['Prize']) . ')'); |
|
| 26 | + .'VALUES (' . $db->escapeNumber($gameID) . ',' . $db->escapeNumber($winner_id) . ',\'0\',' . $db->escapeNumber($lottoInfo['Prize']) . ')'); |
|
| 27 | 27 | |
| 28 | 28 | //get around locked table problem |
| 29 | 29 | $lottoWon = true; |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | // Set the body of the e-mail |
| 37 | 37 | set_mail_body($mail, $var['newsletter_html'], $var['newsletter_text'], |
| 38 | - $_REQUEST['salutation']); |
|
| 38 | + $_REQUEST['salutation']); |
|
| 39 | 39 | |
| 40 | 40 | if ($_REQUEST['to_email'] == '*') { |
| 41 | 41 | // Send the newsletter to all players. |
@@ -7,12 +7,14 @@ discard block |
||
| 7 | 7 | transfer('offended'); |
| 8 | 8 | transfer('game_id'); |
| 9 | 9 | transfer('sender_id'); |
| 10 | - if (!empty($offenderReply)) |
|
| 11 | - $container['PreviewOffender'] = $offenderReply; |
|
| 10 | + if (!empty($offenderReply)) { |
|
| 11 | + $container['PreviewOffender'] = $offenderReply; |
|
| 12 | + } |
|
| 12 | 13 | $container['OffenderBanPoints'] = $_REQUEST['offenderBanPoints']; |
| 13 | 14 | |
| 14 | - if (!empty($offendedReply)) |
|
| 15 | - $container['PreviewOffended'] = $offendedReply; |
|
| 15 | + if (!empty($offendedReply)) { |
|
| 16 | + $container['PreviewOffended'] = $offendedReply; |
|
| 17 | + } |
|
| 16 | 18 | $container['OffendedBanPoints'] = $_REQUEST['offendedBanPoints']; |
| 17 | 19 | forward($container); |
| 18 | 20 | } |
@@ -28,7 +30,9 @@ discard block |
||
| 28 | 30 | $offenderAccount->addPoints($_REQUEST['offenderBanPoints'], $account, 7, $suspicion); |
| 29 | 31 | } |
| 30 | 32 | } |
| 31 | -if (isset($_REQUEST['offendedReply'])) $offendedReply = $_REQUEST['offendedReply']; |
|
| 33 | +if (isset($_REQUEST['offendedReply'])) { |
|
| 34 | + $offendedReply = $_REQUEST['offendedReply']; |
|
| 35 | +} |
|
| 32 | 36 | |
| 33 | 37 | if (isset($offendedReply) && $offendedReply != '') { |
| 34 | 38 | //next message |
@@ -15,24 +15,29 @@ |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | if ($_REQUEST['action'] == 'Create Vote') { |
| 18 | - if (empty($question)) |
|
| 19 | - create_error('You have to specify a vote message.'); |
|
| 20 | - if (empty($_REQUEST['days'])) |
|
| 21 | - create_error('You have to specify the amount of time to run the vote for.'); |
|
| 22 | - if (!is_numeric($_REQUEST['days'])) |
|
| 23 | - create_error('The vote runtime must be a number.'); |
|
| 18 | + if (empty($question)) { |
|
| 19 | + create_error('You have to specify a vote message.'); |
|
| 20 | + } |
|
| 21 | + if (empty($_REQUEST['days'])) { |
|
| 22 | + create_error('You have to specify the amount of time to run the vote for.'); |
|
| 23 | + } |
|
| 24 | + if (!is_numeric($_REQUEST['days'])) { |
|
| 25 | + create_error('The vote runtime must be a number.'); |
|
| 26 | + } |
|
| 24 | 27 | $end = TIME + 86400 * $_REQUEST['days']; |
| 25 | 28 | |
| 26 | 29 | // put the msg into the database |
| 27 | 30 | $db->query('INSERT INTO voting (question, end) VALUES(' . $db->escapeString($question) . ',' . $db->escapeNumber($end) . ')'); |
| 28 | -} |
|
| 29 | -else if ($_REQUEST['action'] == 'Add Option') { |
|
| 30 | - if (empty($option)) |
|
| 31 | - create_error('You have to specify an option message.'); |
|
| 32 | - if (empty($_REQUEST['vote'])) |
|
| 33 | - create_error('You have to select a vote to add the option to.'); |
|
| 34 | - if (!is_numeric($_REQUEST['vote'])) |
|
| 35 | - create_error('Vote ID must be a number.'); |
|
| 31 | +} else if ($_REQUEST['action'] == 'Add Option') { |
|
| 32 | + if (empty($option)) { |
|
| 33 | + create_error('You have to specify an option message.'); |
|
| 34 | + } |
|
| 35 | + if (empty($_REQUEST['vote'])) { |
|
| 36 | + create_error('You have to select a vote to add the option to.'); |
|
| 37 | + } |
|
| 38 | + if (!is_numeric($_REQUEST['vote'])) { |
|
| 39 | + create_error('Vote ID must be a number.'); |
|
| 40 | + } |
|
| 36 | 41 | |
| 37 | 42 | // put the msg into the database |
| 38 | 43 | $db->query('INSERT INTO voting_options (vote_id, text) VALUES(' . $db->escapeNumber($_REQUEST['vote']) . ',' . $db->escapeString($option) . ')'); |
@@ -19,15 +19,17 @@ |
||
| 19 | 19 | 'Notes' => ''); |
| 20 | 20 | |
| 21 | 21 | $db2->query('SELECT notes FROM log_has_notes WHERE account_id = ' . $db2->escapeNumber($accountID)); |
| 22 | - if ($db2->nextRecord()) |
|
| 23 | - $loggedAccounts[$accountID]['Notes'] = nl2br($db2->getField('notes')); |
|
| 22 | + if ($db2->nextRecord()) { |
|
| 23 | + $loggedAccounts[$accountID]['Notes'] = nl2br($db2->getField('notes')); |
|
| 24 | + } |
|
| 24 | 25 | } |
| 25 | 26 | |
| 26 | 27 | // put hidden fields in for log type to have all fields selected on next page. |
| 27 | 28 | $logTypes = array(); |
| 28 | 29 | $db->query('SELECT log_type_id FROM log_type'); |
| 29 | - while ($db->nextRecord()) |
|
| 30 | - $logTypes[] = $db->getInt('log_type_id'); |
|
| 30 | + while ($db->nextRecord()) { |
|
| 31 | + $logTypes[] = $db->getInt('log_type_id'); |
|
| 32 | + } |
|
| 31 | 33 | $template->assign('LogTypes', $logTypes); |
| 32 | 34 | |
| 33 | 35 | $template->assign('LogConsoleFormHREF', SmrSession::getNewHREF(create_container('skeleton.php', 'log_console_detail.php'))); |