We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | $this->cargo_left = $this->getCargoHolds(); |
18 | 18 | } |
19 | 19 | protected function doFullUNO() { |
20 | - foreach($this->getMaxHardware() as $hardwareTypeID => $max) { |
|
20 | + foreach ($this->getMaxHardware() as $hardwareTypeID => $max) { |
|
21 | 21 | $this->hardware[$hardwareTypeID] = $max; |
22 | 22 | $this->oldHardware[$hardwareTypeID] = $max; |
23 | 23 | } |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | public function getIllusionShip() { |
50 | - if(!isset($this->illusionShip)) { |
|
51 | - $this->illusionShip=false; |
|
50 | + if (!isset($this->illusionShip)) { |
|
51 | + $this->illusionShip = false; |
|
52 | 52 | } |
53 | 53 | return $this->illusionShip; |
54 | 54 | } |
@@ -58,20 +58,20 @@ discard block |
||
58 | 58 | $db = MySqlDatabase::getInstance(); |
59 | 59 | $db->query('REPLACE INTO cached_dummys ' . |
60 | 60 | '(type, id, info) ' . |
61 | - 'VALUES (\'DummyShip\', '.$db->escapeString($this->getPlayer()->getPlayerName()).', '.$db->escapeString($cache).')'); |
|
61 | + 'VALUES (\'DummyShip\', ' . $db->escapeString($this->getPlayer()->getPlayerName()) . ', ' . $db->escapeString($cache) . ')'); |
|
62 | 62 | unserialize($cache); |
63 | 63 | } |
64 | 64 | |
65 | 65 | public static function getCachedDummyShip(AbstractSmrPlayer $player) { |
66 | - if(!isset(self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()])) { |
|
66 | + if (!isset(self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()])) { |
|
67 | 67 | $db = MySqlDatabase::getInstance(); |
68 | 68 | $db->query('SELECT info FROM cached_dummys |
69 | 69 | WHERE type = \'DummyShip\' |
70 | 70 | AND id = ' . $db->escapeString($player->getPlayerName()) . ' LIMIT 1'); |
71 | - if($db->nextRecord()) { |
|
71 | + if ($db->nextRecord()) { |
|
72 | 72 | $return = unserialize($db->getField('info')); |
73 | 73 | $return->regenerate($player); |
74 | - self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] =& $return; |
|
74 | + self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = & $return; |
|
75 | 75 | } else { |
76 | 76 | self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = new DummyShip($player); |
77 | 77 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $db->query('SELECT id FROM cached_dummys |
85 | 85 | WHERE type = \'DummyShip\''); |
86 | 86 | $dummyNames = array(); |
87 | - while($db->nextRecord()) { |
|
87 | + while ($db->nextRecord()) { |
|
88 | 88 | $dummyNames[] = $db->getField('id'); |
89 | 89 | } |
90 | 90 | return $dummyNames; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | |
95 | 95 | public function __sleep() { |
96 | - return array('gameID','weapons'); |
|
96 | + return array('gameID', 'weapons'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | public function __wakeup() { |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | |
59 | 59 | $totalShieldDamage = 0; |
60 | 60 | foreach ($attackers as $attacker) { |
61 | - $playerResults =& $attacker->shootPlanet($planet, false); |
|
62 | - $results['Attackers']['Traders'][$attacker->getAccountID()] =& $playerResults; |
|
61 | + $playerResults = & $attacker->shootPlanet($planet, false); |
|
62 | + $results['Attackers']['Traders'][$attacker->getAccountID()] = & $playerResults; |
|
63 | 63 | $results['Attackers']['TotalDamage'] += $playerResults['TotalDamage']; |
64 | 64 | foreach ($playerResults['Weapons'] as $weapon) { |
65 | 65 | if (isset($weapon['ActualDamage'])) { // Only set if the weapon hits |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $downgradeDamage = $results['Attackers']['TotalDamage'] - $totalShieldDamage; |
73 | 73 | $results['Attackers']['Downgrades'] = $planet->checkForDowngrade($downgradeDamage); |
74 | 74 | |
75 | -$results['Planet'] =& $planet->shootPlayers($attackers); |
|
75 | +$results['Planet'] = & $planet->shootPlayers($attackers); |
|
76 | 76 | |
77 | 77 | $account->log(LOG_TYPE_PLANET_BUSTING, 'Player attacks planet, the planet does ' . $results['Planet']['TotalDamage'] . ', their team does ' . $results['Attackers']['TotalDamage'] . ' and downgrades: ' . var_export($results['Attackers']['Downgrades'], true), $planet->getSectorID()); |
78 | 78 |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | |
54 | 54 | $totalShieldDamage = 0; |
55 | 55 | foreach ($attackers as $attacker) { |
56 | - $playerResults =& $attacker->shootPort($port); |
|
57 | - $results['Attackers']['Traders'][$attacker->getAccountID()] =& $playerResults; |
|
56 | + $playerResults = & $attacker->shootPort($port); |
|
57 | + $results['Attackers']['Traders'][$attacker->getAccountID()] = & $playerResults; |
|
58 | 58 | $results['Attackers']['TotalDamage'] += $playerResults['TotalDamage']; |
59 | 59 | foreach ($playerResults['Weapons'] as $weapon) { |
60 | 60 | if (isset($weapon['ActualDamage'])) { // Only set if the weapon hits |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $downgradeDamage = $results['Attackers']['TotalDamage'] - $totalShieldDamage; |
68 | 68 | $results['Attackers']['Downgrades'] = $port->checkForDowngrade($downgradeDamage); |
69 | 69 | |
70 | -$results['Port'] =& $port->shootPlayers($attackers); |
|
70 | +$results['Port'] = & $port->shootPlayers($attackers); |
|
71 | 71 | |
72 | 72 | $account->log(LOG_TYPE_PORT_RAIDING, 'Player attacks port, the port does ' . $results['Port']['TotalDamage'] . ', their team does ' . $results['Attackers']['TotalDamage'] . ' and downgrades ' . $results['Attackers']['Downgrades'] . ' levels.', $port->getSectorID()); |
73 | 73 |
@@ -51,7 +51,7 @@ |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | public static function mysqliFactory(MySqlProperties $mysqlProperties): mysqli { |
54 | - if (!mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT)) { |
|
54 | + if (!mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT)) { |
|
55 | 55 | throw new RuntimeException('Failed to enable mysqli error reporting'); |
56 | 56 | } |
57 | 57 | return new mysqli( |
@@ -19,7 +19,7 @@ |
||
19 | 19 | create_error('Join Date is not valid!'); |
20 | 20 | } |
21 | 21 | $start = empty(Request::get('game_start')) ? $join : |
22 | - DateTime::createFromFormat('d/m/Y|', Request::get('game_start')); |
|
22 | + DateTime::createFromFormat('d/m/Y|', Request::get('game_start')); |
|
23 | 23 | if ($start === false) { |
24 | 24 | create_error('Start Date is not valid!'); |
25 | 25 | } |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php declare(strict_types=1); |
2 | 2 | |
3 | 3 | //first create the game |
4 | -$db->query('SELECT game_id FROM game WHERE game_name='.$db->escapeString(Request::get('game_name')).' LIMIT 1'); |
|
4 | +$db->query('SELECT game_id FROM game WHERE game_name=' . $db->escapeString(Request::get('game_name')) . ' LIMIT 1'); |
|
5 | 5 | if ($db->nextRecord()) { |
6 | 6 | create_error('That game name is already taken.'); |
7 | 7 | } |
8 | 8 | |
9 | 9 | $db->query('SELECT game_id FROM game ORDER BY game_id DESC LIMIT 1'); |
10 | 10 | if ($db->nextRecord()) { |
11 | - $newID = $db->getInt('game_id')+1; |
|
11 | + $newID = $db->getInt('game_id') + 1; |
|
12 | 12 | } else { |
13 | 13 | $newID = 1; |
14 | 14 | } |
@@ -18,8 +18,7 @@ discard block |
||
18 | 18 | if ($join === false) { |
19 | 19 | create_error('Join Date is not valid!'); |
20 | 20 | } |
21 | -$start = empty(Request::get('game_start')) ? $join : |
|
22 | - DateTime::createFromFormat('d/m/Y|', Request::get('game_start')); |
|
21 | +$start = empty(Request::get('game_start')) ? $join : DateTime::createFromFormat('d/m/Y|', Request::get('game_start')); |
|
23 | 22 | if ($start === false) { |
24 | 23 | create_error('Start Date is not valid!'); |
25 | 24 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | $db->query('SELECT game_id, game_name FROM game WHERE join_time < ' . $db->escapeNumber(SmrSession::getTime()) . ' AND end_time > ' . $db->escapeNumber(SmrSession::getTime()) . ' ORDER BY start_time DESC'); |
11 | 11 | while ($db->nextRecord()) { |
12 | 12 | $activeGames[] = array('game_name' => $db->getField('game_name'), |
13 | - 'game_id' => $db->getInt('game_id')); |
|
13 | + 'game_id' => $db->getInt('game_id')); |
|
14 | 14 | } |
15 | 15 | $template->assign('ActiveGames', $activeGames); |
16 | 16 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | $db->query('SELECT game_id, game_name FROM game WHERE game_type=' . $db->escapeNumber(SmrGame::GAME_TYPE_DRAFT) . ' AND join_time < ' . $db->escapeNumber(SmrSession::getTime()) . ' AND end_time > ' . $db->escapeNumber(SmrSession::getTime()) . ' ORDER BY start_time DESC'); |
11 | 11 | while ($db->nextRecord()) { |
12 | 12 | $activeGames[] = array('game_name' => $db->getField('game_name'), |
13 | - 'game_id' => $db->getInt('game_id')); |
|
13 | + 'game_id' => $db->getInt('game_id')); |
|
14 | 14 | } |
15 | 15 | $template->assign('ActiveGames', $activeGames); |
16 | 16 |
@@ -10,22 +10,22 @@ discard block |
||
10 | 10 | |
11 | 11 | debug('Script started'); |
12 | 12 | define('SCRIPT_ID', $db->getInsertID()); |
13 | - $db->query('UPDATE npc_logs SET script_id='.SCRIPT_ID.' WHERE log_id='.SCRIPT_ID); |
|
13 | + $db->query('UPDATE npc_logs SET script_id=' . SCRIPT_ID . ' WHERE log_id=' . SCRIPT_ID); |
|
14 | 14 | |
15 | 15 | define('NPC_SCRIPT', true); |
16 | 16 | |
17 | 17 | $descriptorSpec = array( |
18 | - 0 => array("pipe", "r"), // stdin is a pipe that the child will read from |
|
18 | + 0 => array("pipe", "r"), // stdin is a pipe that the child will read from |
|
19 | 19 | 1 => array("pipe", "w") // stdout is a pipe that the child will write to |
20 | 20 | ); |
21 | 21 | $engine = proc_open(UCI_CHESS_ENGINE, $descriptorSpec, $pipes); |
22 | - $toEngine =& $pipes[0]; |
|
23 | - $fromEngine =& $pipes[1]; |
|
22 | + $toEngine = & $pipes[0]; |
|
23 | + $fromEngine = & $pipes[1]; |
|
24 | 24 | |
25 | 25 | function readFromEngine($block = true) { |
26 | 26 | global $fromEngine; |
27 | 27 | stream_set_blocking($fromEngine, $block == true ? 1 : 0); |
28 | - while(($s = fgets($fromEngine)) !== false) { |
|
28 | + while (($s = fgets($fromEngine)) !== false) { |
|
29 | 29 | debug('<-- ' . trim($s)); |
30 | 30 | stream_set_blocking($fromEngine, 0); |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | global $toEngine; |
35 | 35 | debug('--> ' . $s); |
36 | 36 | fputs($toEngine, $s . EOL); |
37 | - if($read === true) { |
|
37 | + if ($read === true) { |
|
38 | 38 | readFromEngine($block); |
39 | 39 | } |
40 | 40 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | writeToEngine('isready'); |
46 | 46 | writeToEngine('ucinewgame', false); |
47 | 47 | |
48 | - while(true) { |
|
48 | + while (true) { |
|
49 | 49 | // The next "page request" must occur at an updated time. |
50 | 50 | SmrSession::updateTime(); |
51 | 51 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | writeToEngine('position fen ' . $chessGame->getFENString(), false); |
55 | 55 | writeToEngine('go ' . ($chessGame->getCurrentTurnColour() == ChessGame::PLAYER_WHITE ? 'w' : 'b') . 'time ' . UCI_TIME_PER_MOVE_MS, true, false); |
56 | 56 | stream_set_blocking($fromEngine, 1); |
57 | - while(stripos($move = trim(fgets($fromEngine)), 'bestmove') !== 0) { |
|
57 | + while (stripos($move = trim(fgets($fromEngine)), 'bestmove') !== 0) { |
|
58 | 58 | debug('<-- ' . $move); |
59 | - if(stripos($move, 'Seg') === 0) { |
|
59 | + if (stripos($move, 'Seg') === 0) { |
|
60 | 60 | // Segfault |
61 | 61 | debug('UCI engine segfaulted?'); |
62 | 62 | exit; |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | fclose($toEngine); |
77 | 77 | fclose($fromEngine); |
78 | 78 | proc_close($engine); |
79 | -} catch(Throwable $e) { |
|
79 | +} catch (Throwable $e) { |
|
80 | 80 | logException($e); |
81 | 81 | exit; |
82 | 82 | } |
83 | 83 | function debug($message, $debugObject = null) { |
84 | - global $account,$var,$db; |
|
85 | - echo date('Y-m-d H:i:s - ').$message.($debugObject!==null?EOL.var_export($debugObject,true):'').EOL; |
|
86 | - $db->query('INSERT INTO npc_logs (script_id, npc_id, time, message, debug_info, var) VALUES ('.(defined('SCRIPT_ID')?SCRIPT_ID:0).', '.(is_object($account)?$account->getAccountID():0).',NOW(),'.$db->escapeString($message).','.$db->escapeString(var_export($debugObject,true)).','.$db->escapeString(var_export($var,true)).')'); |
|
84 | + global $account, $var, $db; |
|
85 | + echo date('Y-m-d H:i:s - ') . $message . ($debugObject !== null ?EOL.var_export($debugObject, true) : '') . EOL; |
|
86 | + $db->query('INSERT INTO npc_logs (script_id, npc_id, time, message, debug_info, var) VALUES (' . (defined('SCRIPT_ID') ?SCRIPT_ID:0) . ', ' . (is_object($account) ? $account->getAccountID() : 0) . ',NOW(),' . $db->escapeString($message) . ',' . $db->escapeString(var_export($debugObject, true)) . ',' . $db->escapeString(var_export($var, true)) . ')'); |
|
87 | 87 | } |
@@ -36,10 +36,10 @@ |
||
36 | 36 | * The factories themselves are able to use dependency injection as well, so we can provide the MySqlProperties |
37 | 37 | * typehint to make sure the container constructs an instance and provides it to the factory. |
38 | 38 | */ |
39 | - mysqli::class => function (MySqlProperties $mysqlProperties): mysqli { |
|
39 | + mysqli::class => function(MySqlProperties $mysqlProperties): mysqli { |
|
40 | 40 | return MySqlDatabase::mysqliFactory($mysqlProperties); |
41 | 41 | }, |
42 | - Dotenv::class => function (): Dotenv { |
|
42 | + Dotenv::class => function(): Dotenv { |
|
43 | 43 | return Dotenv::createArrayBacked(ROOT); |
44 | 44 | }, |
45 | 45 | // Explicitly name all classes that are autowired, so we can take advantage of |