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 = new SmrMySqlDatabase(); |
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 = new SmrMySqlDatabase(); |
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() { |
@@ -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 | //Redefine MICRO_TIME and TIME, the rest of the game expects them to be the single point in time that the script is executing, with it being redefined for each page load - unfortunately NPCs are one consistent script so we have to do a hack and redefine it (or change every instance of the TIME constant). |
50 | 50 | runkit_constant_redefine('MICRO_TIME', microtime(true)); |
51 | 51 | runkit_constant_redefine('TIME', IFloor(MICRO_TIME)); |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | writeToEngine('position fen ' . $chessGame->getFENString(), false); |
56 | 56 | writeToEngine('go ' . ($chessGame->getCurrentTurnColour() == ChessGame::PLAYER_WHITE ? 'w' : 'b') . 'time ' . UCI_TIME_PER_MOVE_MS, true, false); |
57 | 57 | stream_set_blocking($fromEngine, 1); |
58 | - while(stripos($move = trim(fgets($fromEngine)), 'bestmove') !== 0) { |
|
58 | + while (stripos($move = trim(fgets($fromEngine)), 'bestmove') !== 0) { |
|
59 | 59 | debug('<-- ' . $move); |
60 | - if(stripos($move, 'Seg') === 0) { |
|
60 | + if (stripos($move, 'Seg') === 0) { |
|
61 | 61 | // Segfault |
62 | 62 | debug('UCI engine segfaulted?'); |
63 | 63 | exit; |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | fclose($toEngine); |
78 | 78 | fclose($fromEngine); |
79 | 79 | proc_close($engine); |
80 | -} catch(Throwable $e) { |
|
80 | +} catch (Throwable $e) { |
|
81 | 81 | logException($e); |
82 | 82 | exit; |
83 | 83 | } |
84 | 84 | function debug($message, $debugObject = null) { |
85 | - global $account,$var,$db; |
|
86 | - echo date('Y-m-d H:i:s - ').$message.($debugObject!==null?EOL.var_export($debugObject,true):'').EOL; |
|
87 | - $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)).')'); |
|
85 | + global $account, $var, $db; |
|
86 | + echo date('Y-m-d H:i:s - ') . $message . ($debugObject !== null ?EOL.var_export($debugObject, true) : '') . EOL; |
|
87 | + $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)) . ')'); |
|
88 | 88 | } |
@@ -32,11 +32,16 @@ |
||
32 | 32 | $ship->increaseHardware($hardware_id, $amount); |
33 | 33 | |
34 | 34 | //HoF |
35 | - if ($hardware_id == HARDWARE_COMBAT) $player->increaseHOF($amount, array('Forces', 'Bought', 'Combat Drones'), HOF_ALLIANCE); |
|
36 | - if ($hardware_id == HARDWARE_SCOUT) $player->increaseHOF($amount, array('Forces', 'Bought', 'Scout Drones'), HOF_ALLIANCE); |
|
37 | - if ($hardware_id == HARDWARE_MINE) $player->increaseHOF($amount, array('Forces', 'Bought', 'Mines'), HOF_ALLIANCE); |
|
38 | -} |
|
39 | -elseif ($action == 'Sell') { |
|
35 | + if ($hardware_id == HARDWARE_COMBAT) { |
|
36 | + $player->increaseHOF($amount, array('Forces', 'Bought', 'Combat Drones'), HOF_ALLIANCE); |
|
37 | + } |
|
38 | + if ($hardware_id == HARDWARE_SCOUT) { |
|
39 | + $player->increaseHOF($amount, array('Forces', 'Bought', 'Scout Drones'), HOF_ALLIANCE); |
|
40 | + } |
|
41 | + if ($hardware_id == HARDWARE_MINE) { |
|
42 | + $player->increaseHOF($amount, array('Forces', 'Bought', 'Mines'), HOF_ALLIANCE); |
|
43 | + } |
|
44 | + } elseif ($action == 'Sell') { |
|
40 | 45 | // We only allow selling combat drones |
41 | 46 | if ($hardware_id != HARDWARE_COMBAT) { |
42 | 47 | throw new Exception('This item cannot be sold!'); |
@@ -20,11 +20,11 @@ |
||
20 | 20 | $this->includeTemplate('includes/ForceFullCombatResults.inc', array('FullForceCombatResults'=>$CombatResults)); |
21 | 21 | } elseif ($CombatResultsType == 'PORT') { |
22 | 22 | $this->includeTemplate('includes/PortFullCombatResults.inc', array('FullPortCombatResults'=>$CombatResults, |
23 | - 'MinimalDisplay'=>false, |
|
24 | - 'AlreadyDestroyed'=>false)); |
|
23 | + 'MinimalDisplay'=>false, |
|
24 | + 'AlreadyDestroyed'=>false)); |
|
25 | 25 | } elseif ($CombatResultsType == 'PLANET') { |
26 | 26 | $this->includeTemplate('includes/PlanetFullCombatResults.inc', array('FullPlanetCombatResults'=>$CombatResults, |
27 | - 'MinimalDisplay'=>false, |
|
28 | - 'AlreadyDestroyed'=>false)); |
|
27 | + 'MinimalDisplay'=>false, |
|
28 | + 'AlreadyDestroyed'=>false)); |
|
29 | 29 | } |
30 | 30 | ?> |
@@ -3,11 +3,11 @@ |
||
3 | 3 | // Holds information linking the received message and the game data |
4 | 4 | class GameLink |
5 | 5 | { |
6 | - public $valid = false; // identifies if the message is linked to game data |
|
7 | - public $user; // Discord user associated with the message |
|
8 | - public $account; // SmrAccount instance |
|
9 | - public $alliance; // SmrAlliance instance |
|
10 | - public $player; // SmrPlayer instance |
|
6 | + public $valid = false; // identifies if the message is linked to game data |
|
7 | + public $user; // Discord user associated with the message |
|
8 | + public $account; // SmrAccount instance |
|
9 | + public $alliance; // SmrAlliance instance |
|
10 | + public $player; // SmrPlayer instance |
|
11 | 11 | |
12 | 12 | // Takes the following arguments: |
13 | 13 | // channel = Discord\Parts\Channel\Channel instance |
@@ -20,7 +20,9 @@ |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | public static function cmpNum($a, $b) { |
23 | - if ($a == $b) return 0; |
|
23 | + if ($a == $b) { |
|
24 | + return 0; |
|
25 | + } |
|
24 | 26 | return (self::$reverseOrder ? -1 : 1) * ($a < $b ? -1 : 1); |
25 | 27 | } |
26 | 28 |
@@ -7,4 +7,4 @@ |
||
7 | 7 | $msg = '<span class="green">SUCCESS: </span>Enabled game ' . $game->getDisplayName(); |
8 | 8 | |
9 | 9 | forward(create_container('skeleton.php', 'enable_game.php', |
10 | - array('processing_msg' => $msg))); |
|
10 | + array('processing_msg' => $msg))); |
@@ -1,34 +1,34 @@ discard block |
||
1 | 1 | <?php |
2 | -if(isset($ForcesCombatResults['Results']) && is_array($ForcesCombatResults['Results'])) { |
|
3 | - foreach($ForcesCombatResults['Results'] as $ForceType => $ForceResults) { |
|
4 | - $ShootingWeapon =& $ForceResults['Weapon']; |
|
5 | - $ShotHit =& $ForceResults['Hit']; |
|
6 | - $ActualDamage =& $ForceResults['ActualDamage']; |
|
7 | - $WeaponDamage =& $ForceResults['WeaponDamage']; |
|
8 | - $TargetPlayer =& $ForceResults['TargetPlayer']; |
|
2 | +if (isset($ForcesCombatResults['Results']) && is_array($ForcesCombatResults['Results'])) { |
|
3 | + foreach ($ForcesCombatResults['Results'] as $ForceType => $ForceResults) { |
|
4 | + $ShootingWeapon = & $ForceResults['Weapon']; |
|
5 | + $ShotHit = & $ForceResults['Hit']; |
|
6 | + $ActualDamage = & $ForceResults['ActualDamage']; |
|
7 | + $WeaponDamage = & $ForceResults['WeaponDamage']; |
|
8 | + $TargetPlayer = & $ForceResults['TargetPlayer']; |
|
9 | 9 | ?> |
10 | 10 | <span class="cds"><?php echo $ActualDamage['Launched'] ?? $WeaponDamage['Launched']; ?></span><?php |
11 | - if($ForceType == 'Mines') { |
|
11 | + if ($ForceType == 'Mines') { |
|
12 | 12 | ?> mines kamikaze themselves against <?php |
13 | - } else if($ForceType == 'Drones') { |
|
13 | + } else if ($ForceType == 'Drones') { |
|
14 | 14 | ?> combat drones launch at <?php |
15 | - } else if($ForceType == 'Scouts') { |
|
15 | + } else if ($ForceType == 'Scouts') { |
|
16 | 16 | ?> scout drones kamikaze themselves against <?php |
17 | 17 | } |
18 | 18 | |
19 | - if($ShotHit && $ActualDamage['TargetAlreadyDead']){ ?> the debris that was once <?php } |
|
19 | + if ($ShotHit && $ActualDamage['TargetAlreadyDead']) { ?> the debris that was once <?php } |
|
20 | 20 | echo $TargetPlayer->getDisplayName(); |
21 | 21 | if (!$ShotHit || !$ActualDamage['TargetAlreadyDead']) { |
22 | - if(!$ShotHit) { |
|
22 | + if (!$ShotHit) { |
|
23 | 23 | ?> and misses<?php |
24 | - } else if($ActualDamage['TotalDamage'] == 0) { |
|
25 | - if($WeaponDamage['Shield'] > 0) { |
|
26 | - if($ActualDamage['HasCDs']) { |
|
24 | + } else if ($ActualDamage['TotalDamage'] == 0) { |
|
25 | + if ($WeaponDamage['Shield'] > 0) { |
|
26 | + if ($ActualDamage['HasCDs']) { |
|
27 | 27 | ?> which proves ineffective against their combat drones<?php |
28 | 28 | } else { |
29 | 29 | ?> which washes harmlessly over their hull<?php |
30 | 30 | } |
31 | - } else if($WeaponDamage['Armour'] > 0) { |
|
31 | + } else if ($WeaponDamage['Armour'] > 0) { |
|
32 | 32 | ?> which is deflected by their shields<?php |
33 | 33 | } else { |
34 | 34 | ?> but it cannot do any damage<?php |
@@ -37,31 +37,31 @@ discard block |
||
37 | 37 | ?> destroying <?php |
38 | 38 | } |
39 | 39 | $DamageTypes = 0; |
40 | - if($ActualDamage['Shield'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
41 | - if($ActualDamage['NumCDs'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
42 | - if($ActualDamage['Armour'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
40 | + if ($ActualDamage['Shield'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
41 | + if ($ActualDamage['NumCDs'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
42 | + if ($ActualDamage['Armour'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
43 | 43 | |
44 | - if($ActualDamage['Shield'] > 0) { |
|
44 | + if ($ActualDamage['Shield'] > 0) { |
|
45 | 45 | ?><span class="shields"><?php echo number_format($ActualDamage['Shield']) ?></span> shields<?php |
46 | 46 | $this->doDamageTypeReductionDisplay($DamageTypes); |
47 | 47 | } |
48 | - if($ActualDamage['NumCDs'] > 0) { |
|
48 | + if ($ActualDamage['NumCDs'] > 0) { |
|
49 | 49 | ?><span class="cds"><?php echo number_format($ActualDamage['NumCDs']) ?></span> drones<?php |
50 | 50 | $this->doDamageTypeReductionDisplay($DamageTypes); |
51 | 51 | } |
52 | - if($ActualDamage['Armour'] > 0) { |
|
52 | + if ($ActualDamage['Armour'] > 0) { |
|
53 | 53 | ?><span class="red"><?php echo number_format($ActualDamage['Armour']) ?></span> plates of armour<?php |
54 | 54 | } |
55 | 55 | } ?>. |
56 | 56 | <br /><?php |
57 | 57 | if ($ShotHit && $ActualDamage['KillingShot']) { |
58 | - $this->includeTemplate('includes/TraderCombatKillMessage.inc',array('KillResults'=>$ForceResults['KillResults'],'TargetPlayer'=>$TargetPlayer)); |
|
58 | + $this->includeTemplate('includes/TraderCombatKillMessage.inc', array('KillResults'=>$ForceResults['KillResults'], 'TargetPlayer'=>$TargetPlayer)); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
62 | -if(isset($ForcesCombatResults['ForcesDestroyed']) && $ForcesCombatResults['ForcesDestroyed']) { |
|
62 | +if (isset($ForcesCombatResults['ForcesDestroyed']) && $ForcesCombatResults['ForcesDestroyed']) { |
|
63 | 63 | ?>Forces are <span class="red">DESTROYED!</span><br /><?php |
64 | 64 | } |
65 | 65 | |
66 | -$TotalDamage =& $ForcesCombatResults['TotalDamage'] ?> |
|
67 | -The forces <?php if($TotalDamage > 0){ ?>hit for a total of <span class="red"><?php echo number_format($TotalDamage) ?></span> damage in this round of combat<?php } else{ ?>do no damage this round<?php } ?>. |
|
66 | +$TotalDamage = & $ForcesCombatResults['TotalDamage'] ?> |
|
67 | +The forces <?php if ($TotalDamage > 0) { ?>hit for a total of <span class="red"><?php echo number_format($TotalDamage) ?></span> damage in this round of combat<?php } else { ?>do no damage this round<?php } ?>. |
@@ -7,7 +7,7 @@ |
||
7 | 7 | $db->query('SELECT game_id, game_name FROM game WHERE game_type=' . $db->escapeNumber(SmrGame::GAME_TYPE_DRAFT) . ' AND join_time < ' . $db->escapeNumber(TIME) . ' AND end_time > ' . $db->escapeNumber(TIME) . ' ORDER BY start_time DESC'); |
8 | 8 | while ($db->nextRecord()) { |
9 | 9 | $activeGames[] = array('game_name' => $db->getField('game_name'), |
10 | - 'game_id' => $db->getInt('game_id')); |
|
10 | + 'game_id' => $db->getInt('game_id')); |
|
11 | 11 | } |
12 | 12 | $template->assign('ActiveGames', $activeGames); |
13 | 13 |