We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -20,9 +20,9 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // Set the body text, giving preference to HTML |
| 23 | - if(!empty($newsletterHtml)) { |
|
| 23 | + if (!empty($newsletterHtml)) { |
|
| 24 | 24 | $mail->msgHTML($newsletterHtml); |
| 25 | - if(!empty($newsletterText)) { |
|
| 25 | + if (!empty($newsletterText)) { |
|
| 26 | 26 | $mail->AltBody = $newsletterText; |
| 27 | 27 | } |
| 28 | 28 | } else { |
@@ -37,12 +37,12 @@ discard block |
||
| 37 | 37 | set_mail_body($mail, $var['newsletter_html'], $var['newsletter_text'], |
| 38 | 38 | $_REQUEST['salutation']); |
| 39 | 39 | |
| 40 | -if($_REQUEST['to_email']=='*') { |
|
| 40 | +if ($_REQUEST['to_email'] == '*') { |
|
| 41 | 41 | // Send the newsletter to all players. |
| 42 | 42 | // Disable output buffering here so we can monitor the progress. |
| 43 | - header('X-Accel-Buffering: no'); // disable Nginx output buffering |
|
| 44 | - ob_implicit_flush(); // instruct PHP to flush after every output call |
|
| 45 | - ob_end_flush(); // turn off PHP output buffering |
|
| 43 | + header('X-Accel-Buffering: no'); // disable Nginx output buffering |
|
| 44 | + ob_implicit_flush(); // instruct PHP to flush after every output call |
|
| 45 | + ob_end_flush(); // turn off PHP output buffering |
|
| 46 | 46 | |
| 47 | 47 | $db->query('SELECT account_id, email, login FROM account WHERE validated="TRUE" AND email NOT IN ("[email protected]","[email protected]") AND NOT(EXISTS(SELECT account_id FROM account_is_closed WHERE account_is_closed.account_id=account.account_id))'); |
| 48 | 48 | |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | while ($db->nextRecord()) { |
| 61 | 61 | // get account data |
| 62 | - $account_id = $db->getField('account_id'); |
|
| 63 | - $to_email = $db->getField('email'); |
|
| 64 | - $to_name = $db->getField('login'); |
|
| 62 | + $account_id = $db->getField('account_id'); |
|
| 63 | + $to_email = $db->getField('email'); |
|
| 64 | + $to_name = $db->getField('login'); |
|
| 65 | 65 | |
| 66 | 66 | // Reset the message body with personalized salutation, if requested |
| 67 | 67 | if ($_REQUEST['salutation']) { |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // debug output |
| 73 | - echo '['.$account_id.'] Preparing mail for '.$to_name.' ('.$to_email.')... '; |
|
| 73 | + echo '[' . $account_id . '] Preparing mail for ' . $to_name . ' (' . $to_email . ')... '; |
|
| 74 | 74 | |
| 75 | 75 | // set a bounce address we can process later |
| 76 | 76 | $mail->addReplyTo('bounce_' . $account_id . '@smrealms.de', 'SMR Support'); |
| 77 | 77 | $mail->addAddress($to_email, $to_name); |
| 78 | 78 | |
| 79 | 79 | if (!$mail->send()) { |
| 80 | - echo 'error.'.EOL . $mail->ErrorInfo; |
|
| 80 | + echo 'error.' . EOL . $mail->ErrorInfo; |
|
| 81 | 81 | exit; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $sent++; |
| 85 | 85 | echo 'sent.<br />'; |
| 86 | 86 | if (($sent % 10) == 0) { |
| 87 | - echo 'Sent '. $sent . ' of ' . $total . ' mails.<br /><br />'; |
|
| 87 | + echo 'Sent ' . $sent . ' of ' . $total . ' mails.<br /><br />'; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // Clear all addresses for next loop |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $mail->clearAddresses(); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - echo '<br />Done! Total '.$sent.' mails sent.'; |
|
| 95 | + echo '<br />Done! Total ' . $sent . ' mails sent.'; |
|
| 96 | 96 | release_lock(); |
| 97 | 97 | exit(); |
| 98 | 98 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $mail->addAddress($_REQUEST['to_email'], $_REQUEST['to_email']); |
| 103 | 103 | |
| 104 | 104 | if (!$mail->send()) { |
| 105 | - echo 'error.'.EOL . $mail->ErrorInfo; |
|
| 105 | + echo 'error.' . EOL . $mail->ErrorInfo; |
|
| 106 | 106 | exit; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | private $path = array(); |
| 12 | 12 | private $warpMap = array(); |
| 13 | 13 | |
| 14 | - public function __construct($gameID,$_startSectorId) { |
|
| 14 | + public function __construct($gameID, $_startSectorId) { |
|
| 15 | 15 | $this->gameID = $gameID; |
| 16 | 16 | $this->addToPath($_startSectorId); |
| 17 | 17 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function getTotalSectors() { |
| 32 | - return $this->getDistance()+$this->getNumWarps(); |
|
| 32 | + return $this->getDistance() + $this->getNumWarps(); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function getNumWarps() { |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | * @return integer |
| 49 | 49 | */ |
| 50 | 50 | public function getEndSectorID() { |
| 51 | - return $this->path[count($this->path)-1]; |
|
| 51 | + return $this->path[count($this->path) - 1]; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function &getEndSector() { |
| 55 | - return SmrSector::getSector($this->gameID,$this->getEndSectorID()); |
|
| 55 | + return SmrSector::getSector($this->gameID, $this->getEndSectorID()); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public function isInPath($sectorID) { |
| 103 | - return in_array($sectorID,$this->getPath()); |
|
| 103 | + return in_array($sectorID, $this->getPath()); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | protected $hasChangedCargo = false; |
| 24 | 24 | protected $hasChangedHardware = array(); |
| 25 | 25 | |
| 26 | - public static function &getBaseShip($gameTypeID,$shipTypeID,$forceUpdate = false) { |
|
| 27 | - if($forceUpdate || !isset(self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID])) { |
|
| 26 | + public static function &getBaseShip($gameTypeID, $shipTypeID, $forceUpdate = false) { |
|
| 27 | + if ($forceUpdate || !isset(self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID])) { |
|
| 28 | 28 | // determine ship |
| 29 | 29 | $db = new SmrMySqlDatabase(); |
| 30 | - $db->query('SELECT * FROM ship_type WHERE ship_type_id = '.$db->escapeNumber($shipTypeID).' LIMIT 1'); //TODO add game type id |
|
| 31 | - if($db->nextRecord()) |
|
| 30 | + $db->query('SELECT * FROM ship_type WHERE ship_type_id = ' . $db->escapeNumber($shipTypeID) . ' LIMIT 1'); //TODO add game type id |
|
| 31 | + if ($db->nextRecord()) |
|
| 32 | 32 | self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = self::buildBaseShip($db); |
| 33 | 33 | else |
| 34 | 34 | self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = false; |
@@ -40,40 +40,40 @@ discard block |
||
| 40 | 40 | $ship = array(); |
| 41 | 41 | $ship['Type'] = 'Ship'; |
| 42 | 42 | $ship['Name'] = $db->getField('ship_name'); |
| 43 | - $ship['ShipTypeID'] = $db->getField('ship_type_id'); |
|
| 44 | - $ship['RaceID'] = $db->getField('race_id'); |
|
| 45 | - $ship['Hardpoint'] = $db->getField('hardpoint'); |
|
| 43 | + $ship['ShipTypeID'] = $db->getField('ship_type_id'); |
|
| 44 | + $ship['RaceID'] = $db->getField('race_id'); |
|
| 45 | + $ship['Hardpoint'] = $db->getField('hardpoint'); |
|
| 46 | 46 | $ship['Speed'] = $db->getField('speed'); |
| 47 | - $ship['Cost'] = $db->getField('cost'); |
|
| 48 | - $ship['AlignRestriction'] = $db->getField('buyer_restriction'); |
|
| 47 | + $ship['Cost'] = $db->getField('cost'); |
|
| 48 | + $ship['AlignRestriction'] = $db->getField('buyer_restriction'); |
|
| 49 | 49 | $ship['Level'] = $db->getField('lvl_needed'); |
| 50 | 50 | |
| 51 | 51 | $maxPower = 0; |
| 52 | - switch($ship['Hardpoint']) { |
|
| 52 | + switch ($ship['Hardpoint']) { |
|
| 53 | 53 | default: |
| 54 | - $maxPower+=1*$ship['Hardpoint']-10; |
|
| 54 | + $maxPower += 1 * $ship['Hardpoint'] - 10; |
|
| 55 | 55 | case 10: |
| 56 | - $maxPower+=2; |
|
| 56 | + $maxPower += 2; |
|
| 57 | 57 | case 9: |
| 58 | - $maxPower+=2; |
|
| 58 | + $maxPower += 2; |
|
| 59 | 59 | case 8: |
| 60 | - $maxPower+=2; |
|
| 60 | + $maxPower += 2; |
|
| 61 | 61 | case 7: |
| 62 | - $maxPower+=2; |
|
| 62 | + $maxPower += 2; |
|
| 63 | 63 | case 6: |
| 64 | - $maxPower+=3; |
|
| 64 | + $maxPower += 3; |
|
| 65 | 65 | case 5: |
| 66 | - $maxPower+=3; |
|
| 66 | + $maxPower += 3; |
|
| 67 | 67 | case 4: |
| 68 | - $maxPower+=3; |
|
| 68 | + $maxPower += 3; |
|
| 69 | 69 | case 3: |
| 70 | - $maxPower+=4; |
|
| 70 | + $maxPower += 4; |
|
| 71 | 71 | case 2: |
| 72 | - $maxPower+=4; |
|
| 72 | + $maxPower += 4; |
|
| 73 | 73 | case 1: |
| 74 | - $maxPower+=5; |
|
| 74 | + $maxPower += 5; |
|
| 75 | 75 | case 0: |
| 76 | - $maxPower+=0; |
|
| 76 | + $maxPower += 0; |
|
| 77 | 77 | } |
| 78 | 78 | $ship['MaxPower'] = $maxPower; |
| 79 | 79 | |
@@ -81,38 +81,38 @@ discard block |
||
| 81 | 81 | // get supported hardware from db |
| 82 | 82 | $db2 = new SmrMySqlDatabase(); |
| 83 | 83 | $db2->query('SELECT hardware_type_id, max_amount FROM ship_type_support_hardware ' . |
| 84 | - 'WHERE ship_type_id = '.$db2->escapeNumber($ship['ShipTypeID']).' ORDER BY hardware_type_id'); |
|
| 84 | + 'WHERE ship_type_id = ' . $db2->escapeNumber($ship['ShipTypeID']) . ' ORDER BY hardware_type_id'); |
|
| 85 | 85 | |
| 86 | 86 | while ($db2->nextRecord()) { |
| 87 | 87 | // adding hardware to array |
| 88 | 88 | $ship['MaxHardware'][$db2->getField('hardware_type_id')] = $db2->getField('max_amount'); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $ship['BaseMR'] = round( |
|
| 91 | + $ship['BaseMR'] = round( |
|
| 92 | 92 | 700 - |
| 93 | 93 | ( |
| 94 | 94 | ( |
| 95 | 95 | $ship['MaxHardware'][HARDWARE_SHIELDS] |
| 96 | 96 | +$ship['MaxHardware'][HARDWARE_ARMOUR] |
| 97 | - +$ship['MaxHardware'][HARDWARE_COMBAT]*3 |
|
| 98 | - )/25 |
|
| 97 | + +$ship['MaxHardware'][HARDWARE_COMBAT] * 3 |
|
| 98 | + ) / 25 |
|
| 99 | 99 | +( |
| 100 | - $ship['MaxHardware'][HARDWARE_CARGO]/100 |
|
| 101 | - -$ship['Speed']*5 |
|
| 102 | - +$ship['Hardpoint']*5 |
|
| 103 | - +$ship['MaxHardware'][HARDWARE_COMBAT]/5 |
|
| 100 | + $ship['MaxHardware'][HARDWARE_CARGO] / 100 |
|
| 101 | + -$ship['Speed'] * 5 |
|
| 102 | + +$ship['Hardpoint'] * 5 |
|
| 103 | + +$ship['MaxHardware'][HARDWARE_COMBAT] / 5 |
|
| 104 | 104 | ) |
| 105 | 105 | ) |
| 106 | 106 | ); |
| 107 | 107 | return $ship; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public static function &getAllBaseShips($gameTypeID,$forceUpdate = false) { |
|
| 110 | + public static function &getAllBaseShips($gameTypeID, $forceUpdate = false) { |
|
| 111 | 111 | // determine ship |
| 112 | 112 | $db = new SmrMySqlDatabase(); |
| 113 | 113 | $db->query('SELECT * FROM ship_type ORDER BY ship_type_id ASC'); //TODO add game type id |
| 114 | - while($db->nextRecord()) { |
|
| 115 | - if(!isset(self::$CACHE_BASE_SHIPS[$gameTypeID][$db->getInt('ship_type_id')])) { |
|
| 114 | + while ($db->nextRecord()) { |
|
| 115 | + if (!isset(self::$CACHE_BASE_SHIPS[$gameTypeID][$db->getInt('ship_type_id')])) { |
|
| 116 | 116 | self::$CACHE_BASE_SHIPS[$gameTypeID][$db->getInt('ship_type_id')] = self::buildBaseShip($db); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | protected function regenerateBaseShip() { |
| 129 | - $this->baseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->gameID),$this->player->getShipTypeID()); |
|
| 129 | + $this->baseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->gameID), $this->player->getShipTypeID()); |
|
| 130 | 130 | $this->checkForExcess(); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | public function checkForExcessCargo() { |
| 147 | - if($this->hasCargo()) { |
|
| 147 | + if ($this->hasCargo()) { |
|
| 148 | 148 | foreach ($this->getCargo() as $goodID => $amount) { |
| 149 | 149 | $excess = array_sum($this->getCargo()) - $this->getCargoHolds(); |
| 150 | 150 | if ($excess > 0) { |
@@ -157,28 +157,28 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | public function checkForExcessHardware() { |
| 159 | 159 | //check hardware to see if anything needs to be removed |
| 160 | - if(is_array($hardware = $this->getHardware())) |
|
| 160 | + if (is_array($hardware = $this->getHardware())) |
|
| 161 | 161 | foreach ($hardware as $hardwareTypeID => $amount) { |
| 162 | - if ($amount > ($max=$this->getMaxHardware($hardwareTypeID))) { |
|
| 163 | - $this->setHardware($hardwareTypeID,$max,true); |
|
| 162 | + if ($amount > ($max = $this->getMaxHardware($hardwareTypeID))) { |
|
| 163 | + $this->setHardware($hardwareTypeID, $max, true); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | public function getPowerUsed() { |
| 169 | 169 | $power = 0; |
| 170 | - if($this->getNumWeapons()>0) |
|
| 170 | + if ($this->getNumWeapons() > 0) |
|
| 171 | 171 | foreach ($this->weapons as $weapon) |
| 172 | 172 | $power += $weapon->getPowerLevel(); |
| 173 | 173 | return $power; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | public function getRemainingPower() { |
| 177 | - return $this->getMaxPower()-$this->getPowerUsed(); |
|
| 177 | + return $this->getMaxPower() - $this->getPowerUsed(); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | public function hasRemainingPower() { |
| 181 | - return $this->getRemainingPower()>0; |
|
| 181 | + return $this->getRemainingPower() > 0; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | public function getMaxPower() { |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | public function getDisplayAttackRating(AbstractSmrPlayer $player) { |
| 193 | - if($this->hasActiveIllusion()) |
|
| 193 | + if ($this->hasActiveIllusion()) |
|
| 194 | 194 | return $this->getIllusionAttack(); |
| 195 | 195 | else |
| 196 | 196 | return $this->getAttackRating(); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | public function getDisplayDefenseRating() { |
| 200 | - if($this->hasActiveIllusion()) |
|
| 200 | + if ($this->hasActiveIllusion()) |
|
| 201 | 201 | return $this->getIllusionDefense(); |
| 202 | 202 | else |
| 203 | 203 | return $this->getDefenseRating(); |
@@ -229,9 +229,9 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | |
| 231 | 231 | public function &addWeapon($weaponTypeID) { |
| 232 | - if($this->hasOpenWeaponSlots() && $this->hasRemainingPower()) { |
|
| 232 | + if ($this->hasOpenWeaponSlots() && $this->hasRemainingPower()) { |
|
| 233 | 233 | $weapon = SmrWeapon::getWeapon($weaponTypeID); |
| 234 | - if($this->getRemainingPower()>=$weapon->getPowerLevel()) { |
|
| 234 | + if ($this->getRemainingPower() >= $weapon->getPowerLevel()) { |
|
| 235 | 235 | $this->weapons[count($this->weapons)] = $weapon; |
| 236 | 236 | $this->hasChangedWeapons = true; |
| 237 | 237 | return $weapon; |
@@ -243,13 +243,13 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | public function moveWeaponUp($orderID) { |
| 245 | 245 | $replacement = $orderID - 1; |
| 246 | - if($replacement < 0) { |
|
| 246 | + if ($replacement < 0) { |
|
| 247 | 247 | // Shift everything up by one and put the selected weapon at the bottom |
| 248 | - $temp =& $this->weapons[$orderID]; |
|
| 249 | - for($i=1;$i<count($this->weapons);++$i) { |
|
| 250 | - $this->weapons[$i-1] =& $this->weapons[$i]; //If we go above the bounds of the array it will keep on going due to assign by ref. Hence $i-1 =& $i not $i =& $i+1 |
|
| 248 | + $temp = & $this->weapons[$orderID]; |
|
| 249 | + for ($i = 1; $i < count($this->weapons); ++$i) { |
|
| 250 | + $this->weapons[$i - 1] = & $this->weapons[$i]; //If we go above the bounds of the array it will keep on going due to assign by ref. Hence $i-1 =& $i not $i =& $i+1 |
|
| 251 | 251 | } |
| 252 | - $this->weapons[count($this->weapons)-1] =& $temp; |
|
| 252 | + $this->weapons[count($this->weapons) - 1] = & $temp; |
|
| 253 | 253 | } |
| 254 | 254 | else { |
| 255 | 255 | $temp = $this->weapons[$replacement]; |
@@ -261,13 +261,13 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | public function moveWeaponDown($orderID) { |
| 263 | 263 | $replacement = $orderID + 1; |
| 264 | - if($replacement >= count($this->weapons)) { |
|
| 264 | + if ($replacement >= count($this->weapons)) { |
|
| 265 | 265 | // Shift everything down by one and put the selected weapon at the top |
| 266 | - $temp =& $this->weapons[count($this->weapons)-1]; |
|
| 267 | - for($i=count($this->weapons)-1;$i>0;--$i) { |
|
| 268 | - $this->weapons[$i] =& $this->weapons[$i-1]; |
|
| 266 | + $temp = & $this->weapons[count($this->weapons) - 1]; |
|
| 267 | + for ($i = count($this->weapons) - 1; $i > 0; --$i) { |
|
| 268 | + $this->weapons[$i] = & $this->weapons[$i - 1]; |
|
| 269 | 269 | } |
| 270 | - $this->weapons[0] =& $temp; |
|
| 270 | + $this->weapons[0] = & $temp; |
|
| 271 | 271 | } |
| 272 | 272 | else { |
| 273 | 273 | $temp = $this->weapons[$replacement]; |
@@ -278,22 +278,22 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | public function setWeaponLocations(array $orderArray) { |
| 281 | - $weapons=$this->weapons; |
|
| 282 | - foreach($orderArray as $newOrder => $oldOrder) { |
|
| 283 | - $this->weapons[$newOrder] =& $weapons[$oldOrder]; |
|
| 281 | + $weapons = $this->weapons; |
|
| 282 | + foreach ($orderArray as $newOrder => $oldOrder) { |
|
| 283 | + $this->weapons[$newOrder] = & $weapons[$oldOrder]; |
|
| 284 | 284 | } |
| 285 | 285 | $this->hasChangedWeapons = true; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | public function removeLastWeapon() { |
| 289 | - $this->removeWeapon($this->getNumWeapons()-1); |
|
| 289 | + $this->removeWeapon($this->getNumWeapons() - 1); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | public function removeWeapon($orderID) { |
| 293 | 293 | // Shift everything after the removed weapon up by one and put the selected weapon at the bottom |
| 294 | - for($i=$orderID+1;$i<count($this->weapons);++$i) { |
|
| 295 | - $this->weapons[$i-1] =& $this->weapons[$i]; //If we go above the bounds of the array it will keep on going due to assign by ref. Hence $i-1 =& $i not $i =& $i+1 |
|
| 296 | - } unset($this->weapons[count($this->weapons)-1]); |
|
| 294 | + for ($i = $orderID + 1; $i < count($this->weapons); ++$i) { |
|
| 295 | + $this->weapons[$i - 1] = & $this->weapons[$i]; //If we go above the bounds of the array it will keep on going due to assign by ref. Hence $i-1 =& $i not $i =& $i+1 |
|
| 296 | + } unset($this->weapons[count($this->weapons) - 1]); |
|
| 297 | 297 | $this->hasChangedWeapons = true; |
| 298 | 298 | } |
| 299 | 299 | |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | public function removeAllCargo() { |
| 306 | - if(is_array($this->cargo)) { |
|
| 307 | - foreach($this->cargo as $goodID => $amount) { |
|
| 308 | - $this->setCargo($goodID,0); |
|
| 306 | + if (is_array($this->cargo)) { |
|
| 307 | + foreach ($this->cargo as $goodID => $amount) { |
|
| 308 | + $this->setCargo($goodID, 0); |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | } |
@@ -323,15 +323,15 @@ discard block |
||
| 323 | 323 | $this->removeAllCargo(); |
| 324 | 324 | $this->removeAllHardware(); |
| 325 | 325 | |
| 326 | - if($isNewbie) { |
|
| 327 | - $this->setShields(75,true); |
|
| 328 | - $this->setArmour(150,true); |
|
| 326 | + if ($isNewbie) { |
|
| 327 | + $this->setShields(75, true); |
|
| 328 | + $this->setArmour(150, true); |
|
| 329 | 329 | $this->setCargoHolds(40); |
| 330 | 330 | $this->setShipTypeID(SHIP_TYPE_NEWBIE_MERCHANT_VESSEL); |
| 331 | 331 | } |
| 332 | 332 | else { |
| 333 | - $this->setShields(50,true); |
|
| 334 | - $this->setArmour(50,true); |
|
| 333 | + $this->setShields(50, true); |
|
| 334 | + $this->setArmour(50, true); |
|
| 335 | 335 | $this->setCargoHolds(5); |
| 336 | 336 | $this->setShipTypeID(SHIP_TYPE_ESCAPE_POD); |
| 337 | 337 | } |
@@ -349,9 +349,9 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | |
| 351 | 351 | public function hasActiveIllusion() { |
| 352 | - if(!$this->hasIllusion()) |
|
| 352 | + if (!$this->hasIllusion()) |
|
| 353 | 353 | return false; |
| 354 | - return $this->getIllusionShip()!==false; |
|
| 354 | + return $this->getIllusionShip() !== false; |
|
| 355 | 355 | |
| 356 | 356 | } |
| 357 | 357 | |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | public function getCostToUpgrade($upgradeShipID) { |
| 446 | - $upgadeBaseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->getGameID()),$upgradeShipID); |
|
| 446 | + $upgadeBaseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->getGameID()), $upgradeShipID); |
|
| 447 | 447 | return $upgadeBaseShip['Cost'] - floor($this->getCost() * SHIP_REFUND_PERCENT); |
| 448 | 448 | } |
| 449 | 449 | |
@@ -452,11 +452,11 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | protected function getCostToUNOAgainstShip($shipID) { |
| 455 | - $baseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->getGameID()),$shipID); |
|
| 455 | + $baseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->getGameID()), $shipID); |
|
| 456 | 456 | $cost = 0; |
| 457 | 457 | $hardwareTypes = array(HARDWARE_SHIELDS, HARDWARE_ARMOUR, HARDWARE_CARGO); |
| 458 | - foreach($hardwareTypes as $hardwareTypeID) { |
|
| 459 | - $cost += max(0,$baseShip['MaxHardware'][$hardwareTypeID]-$this->getHardware($hardwareTypeID))*Globals::getHardwareCost($hardwareTypeID); |
|
| 458 | + foreach ($hardwareTypes as $hardwareTypeID) { |
|
| 459 | + $cost += max(0, $baseShip['MaxHardware'][$hardwareTypeID] - $this->getHardware($hardwareTypeID)) * Globals::getHardwareCost($hardwareTypeID); |
|
| 460 | 460 | } |
| 461 | 461 | return $cost; |
| 462 | 462 | } |
@@ -474,41 +474,41 @@ discard block |
||
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | public function getHardware($hardwareTypeID = false) { |
| 477 | - if($hardwareTypeID === false) |
|
| 477 | + if ($hardwareTypeID === false) |
|
| 478 | 478 | return $this->hardware; |
| 479 | 479 | return isset($this->hardware[$hardwareTypeID]) ? $this->hardware[$hardwareTypeID] : 0; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - public function setHardware($hardwareTypeID,$amount) { |
|
| 483 | - if($this->getHardware($hardwareTypeID) == $amount) |
|
| 482 | + public function setHardware($hardwareTypeID, $amount) { |
|
| 483 | + if ($this->getHardware($hardwareTypeID) == $amount) |
|
| 484 | 484 | return; |
| 485 | 485 | $this->hardware[$hardwareTypeID] = $amount; |
| 486 | 486 | $this->hasChangedHardware[$hardwareTypeID] = true; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - public function increaseHardware($hardwareTypeID,$amount) { |
|
| 490 | - $this->setHardware($hardwareTypeID,$this->getHardware($hardwareTypeID)+$amount); |
|
| 489 | + public function increaseHardware($hardwareTypeID, $amount) { |
|
| 490 | + $this->setHardware($hardwareTypeID, $this->getHardware($hardwareTypeID) + $amount); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | public function getOldHardware($hardwareTypeID = false) { |
| 494 | - if($hardwareTypeID === false) |
|
| 494 | + if ($hardwareTypeID === false) |
|
| 495 | 495 | return $this->oldHardware; |
| 496 | 496 | return isset($this->oldHardware[$hardwareTypeID]) ? $this->oldHardware[$hardwareTypeID] : 0; |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - public function setOldHardware($hardwareTypeID,$amount) { |
|
| 500 | - if($this->getOldHardware($hardwareTypeID) == $amount) |
|
| 499 | + public function setOldHardware($hardwareTypeID, $amount) { |
|
| 500 | + if ($this->getOldHardware($hardwareTypeID) == $amount) |
|
| 501 | 501 | return; |
| 502 | 502 | $this->oldHardware[$hardwareTypeID] = $amount; |
| 503 | 503 | $this->hasChangedHardware[$hardwareTypeID] = true; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | public function hasMaxHardware($hardwareTypeID) { |
| 507 | - return $this->getHardware($hardwareTypeID)==$this->getMaxHardware($hardwareTypeID); |
|
| 507 | + return $this->getHardware($hardwareTypeID) == $this->getMaxHardware($hardwareTypeID); |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | public function getMaxHardware($hardwareTypeID = false) { |
| 511 | - if($hardwareTypeID === false) |
|
| 511 | + if ($hardwareTypeID === false) |
|
| 512 | 512 | return $this->baseShip['MaxHardware']; |
| 513 | 513 | return $this->baseShip['MaxHardware'][$hardwareTypeID]; |
| 514 | 514 | } |
@@ -517,18 +517,18 @@ discard block |
||
| 517 | 517 | return $this->getHardware(HARDWARE_SHIELDS); |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - public function setShields($amount,$updateOldAmount=false) { |
|
| 521 | - if($updateOldAmount && !$this->hasLostShields()) |
|
| 522 | - $this->setOldHardware(HARDWARE_SHIELDS,$amount); |
|
| 523 | - $this->setHardware(HARDWARE_SHIELDS,$amount); |
|
| 520 | + public function setShields($amount, $updateOldAmount = false) { |
|
| 521 | + if ($updateOldAmount && !$this->hasLostShields()) |
|
| 522 | + $this->setOldHardware(HARDWARE_SHIELDS, $amount); |
|
| 523 | + $this->setHardware(HARDWARE_SHIELDS, $amount); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | public function decreaseShields($amount) { |
| 527 | - $this->setShields($this->getShields()-$amount); |
|
| 527 | + $this->setShields($this->getShields() - $amount); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | public function increaseShields($amount) { |
| 531 | - $this->setShields($this->getShields()+$amount); |
|
| 531 | + $this->setShields($this->getShields() + $amount); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | public function getOldShields() { |
@@ -536,19 +536,19 @@ discard block |
||
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | public function setOldShields($amount) { |
| 539 | - $this->setOldHardware(HARDWARE_SHIELDS,$amount); |
|
| 539 | + $this->setOldHardware(HARDWARE_SHIELDS, $amount); |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | public function hasShields() { |
| 543 | - return $this->getShields()>0; |
|
| 543 | + return $this->getShields() > 0; |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | public function hasLostShields() { |
| 547 | - return $this->getShields()<$this->getOldShields(); |
|
| 547 | + return $this->getShields() < $this->getOldShields(); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | public function hasMaxShields() { |
| 551 | - return $this->getShields()==$this->getMaxShields(); |
|
| 551 | + return $this->getShields() == $this->getMaxShields(); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | public function getMaxShields() { |
@@ -559,18 +559,18 @@ discard block |
||
| 559 | 559 | return $this->getHardware(HARDWARE_ARMOUR); |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - public function setArmour($amount,$updateOldAmount=false) { |
|
| 563 | - if($updateOldAmount && !$this->hasLostArmour()) |
|
| 564 | - $this->setOldHardware(HARDWARE_ARMOUR,$amount); |
|
| 565 | - $this->setHardware(HARDWARE_ARMOUR,$amount); |
|
| 562 | + public function setArmour($amount, $updateOldAmount = false) { |
|
| 563 | + if ($updateOldAmount && !$this->hasLostArmour()) |
|
| 564 | + $this->setOldHardware(HARDWARE_ARMOUR, $amount); |
|
| 565 | + $this->setHardware(HARDWARE_ARMOUR, $amount); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | public function decreaseArmour($amount) { |
| 569 | - $this->setArmour($this->getArmour()-$amount); |
|
| 569 | + $this->setArmour($this->getArmour() - $amount); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | public function increaseArmour($amount) { |
| 573 | - $this->setArmour($this->getArmour()+$amount); |
|
| 573 | + $this->setArmour($this->getArmour() + $amount); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | public function getOldArmour() { |
@@ -578,19 +578,19 @@ discard block |
||
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | public function setOldArmour($amount) { |
| 581 | - $this->setOldHardware(HARDWARE_ARMOUR,$amount); |
|
| 581 | + $this->setOldHardware(HARDWARE_ARMOUR, $amount); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | public function hasArmour() { |
| 585 | - return $this->getArmour()>0; |
|
| 585 | + return $this->getArmour() > 0; |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | public function hasLostArmour() { |
| 589 | - return $this->getArmour()<$this->getOldArmour(); |
|
| 589 | + return $this->getArmour() < $this->getOldArmour(); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | public function hasMaxArmour() { |
| 593 | - return $this->getArmour()==$this->getMaxArmour(); |
|
| 593 | + return $this->getArmour() == $this->getMaxArmour(); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | public function getMaxArmour() { |
@@ -598,53 +598,53 @@ discard block |
||
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | public function isDead() { |
| 601 | - return !$this->hasArmour()&&!$this->hasShields(); |
|
| 601 | + return !$this->hasArmour() && !$this->hasShields(); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | public function canAcceptCDs() { |
| 605 | - return $this->getCDs()<$this->getMaxCDs(); |
|
| 605 | + return $this->getCDs() < $this->getMaxCDs(); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | public function canAcceptSDs() { |
| 609 | - return $this->getSDs()<$this->getMaxSDs(); |
|
| 609 | + return $this->getSDs() < $this->getMaxSDs(); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | public function canAcceptMines() { |
| 613 | - return $this->getMines()<$this->getMaxMines(); |
|
| 613 | + return $this->getMines() < $this->getMaxMines(); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | public function hasCDs() { |
| 617 | - return $this->getCDs()>0; |
|
| 617 | + return $this->getCDs() > 0; |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | public function hasSDs() { |
| 621 | - return $this->getSDs()>0; |
|
| 621 | + return $this->getSDs() > 0; |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | public function hasMines() { |
| 625 | - return $this->getMines()>0; |
|
| 625 | + return $this->getMines() > 0; |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | public function getCDs() { |
| 629 | 629 | return $this->getHardware(HARDWARE_COMBAT); |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - public function setCDs($amount,$updateOldAmount=false) { |
|
| 633 | - if($updateOldAmount && !$this->hasLostCDs()) |
|
| 634 | - $this->setOldHardware(HARDWARE_COMBAT,$amount); |
|
| 635 | - $this->setHardware(HARDWARE_COMBAT,$amount); |
|
| 632 | + public function setCDs($amount, $updateOldAmount = false) { |
|
| 633 | + if ($updateOldAmount && !$this->hasLostCDs()) |
|
| 634 | + $this->setOldHardware(HARDWARE_COMBAT, $amount); |
|
| 635 | + $this->setHardware(HARDWARE_COMBAT, $amount); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | 639 | * Decreases the ship CDs. Use $updateOldAmount=true to prevent |
| 640 | 640 | * this change from triggering `isUnderAttack`. |
| 641 | 641 | */ |
| 642 | - public function decreaseCDs($amount,$updateOldAmount=false) { |
|
| 643 | - $this->setCDs($this->getCDs()-$amount,$updateOldAmount); |
|
| 642 | + public function decreaseCDs($amount, $updateOldAmount = false) { |
|
| 643 | + $this->setCDs($this->getCDs() - $amount, $updateOldAmount); |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | public function increaseCDs($amount) { |
| 647 | - $this->setCDs($this->getCDs()+$amount); |
|
| 647 | + $this->setCDs($this->getCDs() + $amount); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | public function getOldCDs() { |
@@ -652,11 +652,11 @@ discard block |
||
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | public function setOldCDs($amount) { |
| 655 | - $this->setOldHardware(HARDWARE_COMBAT,$amount); |
|
| 655 | + $this->setOldHardware(HARDWARE_COMBAT, $amount); |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | public function hasLostCDs() { |
| 659 | - return $this->getCDs()<$this->getOldCDs(); |
|
| 659 | + return $this->getCDs() < $this->getOldCDs(); |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | public function getMaxCDs() { |
@@ -668,15 +668,15 @@ discard block |
||
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | public function setSDs($amount) { |
| 671 | - $this->setHardware(HARDWARE_SCOUT,$amount); |
|
| 671 | + $this->setHardware(HARDWARE_SCOUT, $amount); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | public function decreaseSDs($amount) { |
| 675 | - $this->setSDs($this->getSDs()-$amount); |
|
| 675 | + $this->setSDs($this->getSDs() - $amount); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | public function increaseSDs($amount) { |
| 679 | - $this->setSDs($this->getSDs()+$amount); |
|
| 679 | + $this->setSDs($this->getSDs() + $amount); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | public function getMaxSDs() { |
@@ -688,15 +688,15 @@ discard block |
||
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | public function setMines($amount) { |
| 691 | - $this->setHardware(HARDWARE_MINE,$amount); |
|
| 691 | + $this->setHardware(HARDWARE_MINE, $amount); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | public function decreaseMines($amount) { |
| 695 | - $this->setMines($this->getMines()-$amount); |
|
| 695 | + $this->setMines($this->getMines() - $amount); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | public function increaseMines($amount) { |
| 699 | - $this->setMines($this->getMines()+$amount); |
|
| 699 | + $this->setMines($this->getMines() + $amount); |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | public function getMaxMines() { |
@@ -708,12 +708,12 @@ discard block |
||
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | public function setCargoHolds($amount) { |
| 711 | - $this->setHardware(HARDWARE_CARGO,$amount); |
|
| 711 | + $this->setHardware(HARDWARE_CARGO, $amount); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - public function &getCargo($goodID=false) { |
|
| 715 | - if($goodID!==false) { |
|
| 716 | - if(isset($this->cargo[$goodID])) |
|
| 714 | + public function &getCargo($goodID = false) { |
|
| 715 | + if ($goodID !== false) { |
|
| 716 | + if (isset($this->cargo[$goodID])) |
|
| 717 | 717 | return $this->cargo[$goodID]; |
| 718 | 718 | $cargo = 0; |
| 719 | 719 | return $cargo; |
@@ -721,16 +721,16 @@ discard block |
||
| 721 | 721 | return $this->cargo; |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | - public function hasCargo($goodID=false) { |
|
| 725 | - if($goodID!==false) |
|
| 726 | - return $this->getCargo($goodID)>0; |
|
| 727 | - if(is_array($cargo = $this->getCargo())) |
|
| 728 | - return array_sum($cargo)>0; |
|
| 724 | + public function hasCargo($goodID = false) { |
|
| 725 | + if ($goodID !== false) |
|
| 726 | + return $this->getCargo($goodID) > 0; |
|
| 727 | + if (is_array($cargo = $this->getCargo())) |
|
| 728 | + return array_sum($cargo) > 0; |
|
| 729 | 729 | return false; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - public function setCargo($goodID,$amount) { |
|
| 733 | - if($this->getCargo($goodID) == $amount) |
|
| 732 | + public function setCargo($goodID, $amount) { |
|
| 733 | + if ($this->getCargo($goodID) == $amount) |
|
| 734 | 734 | return; |
| 735 | 735 | $this->cargo[$goodID] = $amount; |
| 736 | 736 | $this->hasChangedCargo = true; |
@@ -739,20 +739,20 @@ discard block |
||
| 739 | 739 | ksort($this->cargo); |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - public function decreaseCargo($goodID,$amount) { |
|
| 743 | - if($amount < 0) |
|
| 742 | + public function decreaseCargo($goodID, $amount) { |
|
| 743 | + if ($amount < 0) |
|
| 744 | 744 | throw new Exception('Trying to decrease negative cargo.'); |
| 745 | - $this->setCargo($goodID,$this->getCargo($goodID)-$amount); |
|
| 745 | + $this->setCargo($goodID, $this->getCargo($goodID) - $amount); |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | - public function increaseCargo($goodID,$amount) { |
|
| 749 | - if($amount < 0) |
|
| 748 | + public function increaseCargo($goodID, $amount) { |
|
| 749 | + if ($amount < 0) |
|
| 750 | 750 | throw new Exception('Trying to increase negative cargo.'); |
| 751 | - $this->setCargo($goodID,$this->getCargo($goodID)+$amount); |
|
| 751 | + $this->setCargo($goodID, $this->getCargo($goodID) + $amount); |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | public function getEmptyHolds() { |
| 755 | - return $this->getCargoHolds()-$this->getUsedHolds(); |
|
| 755 | + return $this->getCargoHolds() - $this->getUsedHolds(); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | public function getUsedHolds() { |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | public function hasMaxCargoHolds() { |
| 763 | - return $this->getCargoHolds()==$this->getMaxCargoHolds(); |
|
| 763 | + return $this->getCargoHolds() == $this->getMaxCargoHolds(); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | public function getMaxCargoHolds() { |
@@ -777,16 +777,16 @@ discard block |
||
| 777 | 777 | $this->setOldShields($this->getShields()); |
| 778 | 778 | $this->setOldCDs($this->getCDs()); |
| 779 | 779 | $this->setOldArmour($this->getArmour()); |
| 780 | - if(isset($var['UnderAttack'])) |
|
| 780 | + if (isset($var['UnderAttack'])) |
|
| 781 | 781 | return $var['UnderAttack']; |
| 782 | - if($underAttack && !USING_AJAX) { |
|
| 783 | - SmrSession::updateVar('UnderAttack',$underAttack); //Remember we are under attack for AJAX |
|
| 782 | + if ($underAttack && !USING_AJAX) { |
|
| 783 | + SmrSession::updateVar('UnderAttack', $underAttack); //Remember we are under attack for AJAX |
|
| 784 | 784 | } |
| 785 | 785 | return $underAttack; |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | public function hasWeapons() { |
| 789 | - return $this->getNumWeapons()>0; |
|
| 789 | + return $this->getNumWeapons() > 0; |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | public function &getWeapons() { |
@@ -802,11 +802,11 @@ discard block |
||
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | public function getOpenWeaponSlots() { |
| 805 | - return $this->getHardpoints()-$this->getNumWeapons(); |
|
| 805 | + return $this->getHardpoints() - $this->getNumWeapons(); |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | public function hasOpenWeaponSlots() { |
| 809 | - return $this->getOpenWeaponSlots()>0; |
|
| 809 | + return $this->getOpenWeaponSlots() > 0; |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | public function getHardpoints() { |
@@ -816,8 +816,8 @@ discard block |
||
| 816 | 816 | public function getTotalShieldDamage() { |
| 817 | 817 | $weapons = $this->getWeapons(); |
| 818 | 818 | $shieldDamage = 0; |
| 819 | - foreach($weapons as $weapon) { |
|
| 820 | - $shieldDamage+=$weapon->getShieldDamage(); |
|
| 819 | + foreach ($weapons as $weapon) { |
|
| 820 | + $shieldDamage += $weapon->getShieldDamage(); |
|
| 821 | 821 | } |
| 822 | 822 | return $shieldDamage; |
| 823 | 823 | } |
@@ -825,8 +825,8 @@ discard block |
||
| 825 | 825 | public function getTotalArmourDamage() { |
| 826 | 826 | $weapons = $this->getWeapons(); |
| 827 | 827 | $armourDamage = 0; |
| 828 | - foreach($weapons as $weapon) { |
|
| 829 | - $armourDamage+=$weapon->getArmourDamage(); |
|
| 828 | + foreach ($weapons as $weapon) { |
|
| 829 | + $armourDamage += $weapon->getArmourDamage(); |
|
| 830 | 830 | } |
| 831 | 831 | return $armourDamage; |
| 832 | 832 | } |
@@ -846,86 +846,86 @@ discard block |
||
| 846 | 846 | public function &shootPlayers(array $targetPlayers) { |
| 847 | 847 | $thisPlayer = $this->getPlayer(); |
| 848 | 848 | $results = array('Player' => $thisPlayer, 'TotalDamage' => 0); |
| 849 | - if($thisPlayer->isDead()) { |
|
| 849 | + if ($thisPlayer->isDead()) { |
|
| 850 | 850 | $results['DeadBeforeShot'] = true; |
| 851 | 851 | return $results; |
| 852 | 852 | } |
| 853 | 853 | $results['DeadBeforeShot'] = false; |
| 854 | - foreach($this->weapons as $orderID => $weapon) { |
|
| 855 | - $results['Weapons'][$orderID] =& $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]); |
|
| 856 | - if($results['Weapons'][$orderID]['Hit']) |
|
| 854 | + foreach ($this->weapons as $orderID => $weapon) { |
|
| 855 | + $results['Weapons'][$orderID] = & $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]); |
|
| 856 | + if ($results['Weapons'][$orderID]['Hit']) |
|
| 857 | 857 | $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
| 858 | 858 | } |
| 859 | - if($this->hasCDs()) { |
|
| 860 | - $thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs()); |
|
| 861 | - $results['Drones'] =& $thisCDs->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]); |
|
| 859 | + if ($this->hasCDs()) { |
|
| 860 | + $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
|
| 861 | + $results['Drones'] = & $thisCDs->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]); |
|
| 862 | 862 | $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; |
| 863 | 863 | } |
| 864 | - $thisPlayer->increaseExperience(round($results['TotalDamage']/4)); // 1/4 weapon damage to exp. |
|
| 865 | - $thisPlayer->increaseHOF($results['TotalDamage'],array('Combat','Player','Damage Done'), HOF_PUBLIC); |
|
| 866 | - $thisPlayer->increaseHOF(1,array('Combat','Player','Shots'), HOF_PUBLIC); |
|
| 864 | + $thisPlayer->increaseExperience(round($results['TotalDamage'] / 4)); // 1/4 weapon damage to exp. |
|
| 865 | + $thisPlayer->increaseHOF($results['TotalDamage'], array('Combat', 'Player', 'Damage Done'), HOF_PUBLIC); |
|
| 866 | + $thisPlayer->increaseHOF(1, array('Combat', 'Player', 'Shots'), HOF_PUBLIC); |
|
| 867 | 867 | return $results; |
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | public function &shootForces(SmrForce $forces) { |
| 871 | 871 | $thisPlayer = $this->getPlayer(); |
| 872 | 872 | $results = array('Player' => $thisPlayer, 'TotalDamage' => 0); |
| 873 | - if($thisPlayer->isDead()) { |
|
| 873 | + if ($thisPlayer->isDead()) { |
|
| 874 | 874 | $results['DeadBeforeShot'] = true; |
| 875 | 875 | return $results; |
| 876 | 876 | } |
| 877 | 877 | $results['DeadBeforeShot'] = false; |
| 878 | - foreach($this->weapons as $orderID => $weapon) { |
|
| 879 | - $results['Weapons'][$orderID] =& $weapon->shootForces($thisPlayer, $forces); |
|
| 880 | - if($results['Weapons'][$orderID]['Hit']) { |
|
| 878 | + foreach ($this->weapons as $orderID => $weapon) { |
|
| 879 | + $results['Weapons'][$orderID] = & $weapon->shootForces($thisPlayer, $forces); |
|
| 880 | + if ($results['Weapons'][$orderID]['Hit']) { |
|
| 881 | 881 | $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
| 882 | - $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines'],array('Combat','Forces','Mines','Killed'), HOF_PUBLIC); |
|
| 883 | - $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['Mines'],array('Combat','Forces','Mines','Damage Done'), HOF_PUBLIC); |
|
| 884 | - $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumCDs'],array('Combat','Forces','Combat Drones','Killed'), HOF_PUBLIC); |
|
| 885 | - $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['CDs'],array('Combat','Forces','Combat Drones','Damage Done'), HOF_PUBLIC); |
|
| 886 | - $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumSDs'],array('Combat','Forces','Scout Drones','Killed'), HOF_PUBLIC); |
|
| 887 | - $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['SDs'],array('Combat','Forces','Scout Drones','Damage Done'), HOF_PUBLIC); |
|
| 888 | - $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines']+$results['Weapons'][$orderID]['ActualDamage']['NumCDs']+$results['Weapons'][$orderID]['ActualDamage']['NumSDs'],array('Combat','Forces','Killed'), HOF_PUBLIC); |
|
| 882 | + $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines'], array('Combat', 'Forces', 'Mines', 'Killed'), HOF_PUBLIC); |
|
| 883 | + $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['Mines'], array('Combat', 'Forces', 'Mines', 'Damage Done'), HOF_PUBLIC); |
|
| 884 | + $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumCDs'], array('Combat', 'Forces', 'Combat Drones', 'Killed'), HOF_PUBLIC); |
|
| 885 | + $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['CDs'], array('Combat', 'Forces', 'Combat Drones', 'Damage Done'), HOF_PUBLIC); |
|
| 886 | + $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumSDs'], array('Combat', 'Forces', 'Scout Drones', 'Killed'), HOF_PUBLIC); |
|
| 887 | + $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['SDs'], array('Combat', 'Forces', 'Scout Drones', 'Damage Done'), HOF_PUBLIC); |
|
| 888 | + $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines'] + $results['Weapons'][$orderID]['ActualDamage']['NumCDs'] + $results['Weapons'][$orderID]['ActualDamage']['NumSDs'], array('Combat', 'Forces', 'Killed'), HOF_PUBLIC); |
|
| 889 | 889 | } |
| 890 | 890 | } |
| 891 | - if($this->hasCDs()) { |
|
| 892 | - $thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs()); |
|
| 893 | - $results['Drones'] =& $thisCDs->shootForces($thisPlayer, $forces); |
|
| 891 | + if ($this->hasCDs()) { |
|
| 892 | + $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
|
| 893 | + $results['Drones'] = & $thisCDs->shootForces($thisPlayer, $forces); |
|
| 894 | 894 | $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; |
| 895 | - $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines'],array('Combat','Forces','Mines','Killed'), HOF_PUBLIC); |
|
| 896 | - $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['Mines'],array('Combat','Forces','Mines','Damage Done'), HOF_PUBLIC); |
|
| 897 | - $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumCDs'],array('Combat','Forces','Combat Drones','Killed'), HOF_PUBLIC); |
|
| 898 | - $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['CDs'],array('Combat','Forces','Combat Drones','Damage Done'), HOF_PUBLIC); |
|
| 899 | - $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumSDs'],array('Combat','Forces','Scout Drones','Killed'), HOF_PUBLIC); |
|
| 900 | - $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['SDs'],array('Combat','Forces','Scout Drones','Damage Done'), HOF_PUBLIC); |
|
| 901 | - $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines']+$results['Drones']['ActualDamage']['NumCDs']+$results['Drones']['ActualDamage']['NumSDs'],array('Combat','Forces','Killed'), HOF_PUBLIC); |
|
| 895 | + $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines'], array('Combat', 'Forces', 'Mines', 'Killed'), HOF_PUBLIC); |
|
| 896 | + $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['Mines'], array('Combat', 'Forces', 'Mines', 'Damage Done'), HOF_PUBLIC); |
|
| 897 | + $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumCDs'], array('Combat', 'Forces', 'Combat Drones', 'Killed'), HOF_PUBLIC); |
|
| 898 | + $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['CDs'], array('Combat', 'Forces', 'Combat Drones', 'Damage Done'), HOF_PUBLIC); |
|
| 899 | + $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumSDs'], array('Combat', 'Forces', 'Scout Drones', 'Killed'), HOF_PUBLIC); |
|
| 900 | + $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['SDs'], array('Combat', 'Forces', 'Scout Drones', 'Damage Done'), HOF_PUBLIC); |
|
| 901 | + $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines'] + $results['Drones']['ActualDamage']['NumCDs'] + $results['Drones']['ActualDamage']['NumSDs'], array('Combat', 'Forces', 'Killed'), HOF_PUBLIC); |
|
| 902 | 902 | } |
| 903 | - $thisPlayer->increaseExperience(round($results['TotalDamage']/20)); // 1/20 weapon damage to exp. |
|
| 904 | - $thisPlayer->increaseHOF($results['TotalDamage'],array('Combat','Forces','Damage Done'), HOF_PUBLIC); |
|
| 905 | - $thisPlayer->increaseHOF(1,array('Combat','Forces','Shots'), HOF_PUBLIC); |
|
| 903 | + $thisPlayer->increaseExperience(round($results['TotalDamage'] / 20)); // 1/20 weapon damage to exp. |
|
| 904 | + $thisPlayer->increaseHOF($results['TotalDamage'], array('Combat', 'Forces', 'Damage Done'), HOF_PUBLIC); |
|
| 905 | + $thisPlayer->increaseHOF(1, array('Combat', 'Forces', 'Shots'), HOF_PUBLIC); |
|
| 906 | 906 | return $results; |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | public function &shootPort(SmrPort $port) { |
| 910 | 910 | $thisPlayer = $this->getPlayer(); |
| 911 | 911 | $results = array('Player' => $thisPlayer, 'TotalDamage' => 0); |
| 912 | - if($thisPlayer->isDead()) { |
|
| 912 | + if ($thisPlayer->isDead()) { |
|
| 913 | 913 | $results['DeadBeforeShot'] = true; |
| 914 | 914 | return $results; |
| 915 | 915 | } |
| 916 | 916 | $results['DeadBeforeShot'] = false; |
| 917 | - foreach($this->weapons as $orderID => $weapon) { |
|
| 918 | - $results['Weapons'][$orderID] =& $weapon->shootPort($thisPlayer, $port); |
|
| 919 | - if($results['Weapons'][$orderID]['Hit']) |
|
| 917 | + foreach ($this->weapons as $orderID => $weapon) { |
|
| 918 | + $results['Weapons'][$orderID] = & $weapon->shootPort($thisPlayer, $port); |
|
| 919 | + if ($results['Weapons'][$orderID]['Hit']) |
|
| 920 | 920 | $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
| 921 | 921 | } |
| 922 | - if($this->hasCDs()) { |
|
| 923 | - $thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs()); |
|
| 924 | - $results['Drones'] =& $thisCDs->shootPort($thisPlayer, $port); |
|
| 922 | + if ($this->hasCDs()) { |
|
| 923 | + $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
|
| 924 | + $results['Drones'] = & $thisCDs->shootPort($thisPlayer, $port); |
|
| 925 | 925 | $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; |
| 926 | 926 | } |
| 927 | - $thisPlayer->increaseExperience(round($results['TotalDamage']/20)); // 1/20 weapon damage to exp. |
|
| 928 | - $thisPlayer->increaseHOF($results['TotalDamage'],array('Combat','Port','Damage Done'), HOF_PUBLIC); |
|
| 927 | + $thisPlayer->increaseExperience(round($results['TotalDamage'] / 20)); // 1/20 weapon damage to exp. |
|
| 928 | + $thisPlayer->increaseHOF($results['TotalDamage'], array('Combat', 'Port', 'Damage Done'), HOF_PUBLIC); |
|
| 929 | 929 | // $thisPlayer->increaseHOF(1,array('Combat','Port','Shots')); //in SmrPortt::attackedBy() |
| 930 | 930 | |
| 931 | 931 | // Change alignment if we reach a damage threshold. |
@@ -934,10 +934,10 @@ discard block |
||
| 934 | 934 | $relations = Globals::getRaceRelations($thisPlayer->getGameID(), $thisPlayer->getRaceID()); |
| 935 | 935 | if ($relations[$port->getRaceID()] <= RELATIONS_WAR) { |
| 936 | 936 | $thisPlayer->increaseAlignment(1); |
| 937 | - $thisPlayer->increaseHOF(1, array('Combat','Port','Alignment','Gain'), HOF_PUBLIC); |
|
| 937 | + $thisPlayer->increaseHOF(1, array('Combat', 'Port', 'Alignment', 'Gain'), HOF_PUBLIC); |
|
| 938 | 938 | } else { |
| 939 | 939 | $thisPlayer->decreaseAlignment(1); |
| 940 | - $thisPlayer->increaseHOF(1, array('Combat','Port','Alignment','Loss'), HOF_PUBLIC); |
|
| 940 | + $thisPlayer->increaseHOF(1, array('Combat', 'Port', 'Alignment', 'Loss'), HOF_PUBLIC); |
|
| 941 | 941 | } |
| 942 | 942 | } |
| 943 | 943 | return $results; |
@@ -946,23 +946,23 @@ discard block |
||
| 946 | 946 | public function &shootPlanet(SmrPlanet $planet, $delayed) { |
| 947 | 947 | $thisPlayer = $this->getPlayer(); |
| 948 | 948 | $results = array('Player' => $thisPlayer, 'TotalDamage' => 0); |
| 949 | - if($thisPlayer->isDead()) { |
|
| 949 | + if ($thisPlayer->isDead()) { |
|
| 950 | 950 | $results['DeadBeforeShot'] = true; |
| 951 | 951 | return $results; |
| 952 | 952 | } |
| 953 | 953 | $results['DeadBeforeShot'] = false; |
| 954 | - foreach($this->weapons as $orderID => $weapon) { |
|
| 955 | - $results['Weapons'][$orderID] =& $weapon->shootPlanet($thisPlayer, $planet, $delayed); |
|
| 956 | - if($results['Weapons'][$orderID]['Hit']) |
|
| 954 | + foreach ($this->weapons as $orderID => $weapon) { |
|
| 955 | + $results['Weapons'][$orderID] = & $weapon->shootPlanet($thisPlayer, $planet, $delayed); |
|
| 956 | + if ($results['Weapons'][$orderID]['Hit']) |
|
| 957 | 957 | $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
| 958 | 958 | } |
| 959 | - if($this->hasCDs()) { |
|
| 960 | - $thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs()); |
|
| 961 | - $results['Drones'] =& $thisCDs->shootPlanet($thisPlayer, $planet, $delayed); |
|
| 959 | + if ($this->hasCDs()) { |
|
| 960 | + $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
|
| 961 | + $results['Drones'] = & $thisCDs->shootPlanet($thisPlayer, $planet, $delayed); |
|
| 962 | 962 | $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; |
| 963 | 963 | } |
| 964 | - $thisPlayer->increaseExperience(round($results['TotalDamage']/20)); // 1/20 weapon damage to exp. |
|
| 965 | - $thisPlayer->increaseHOF($results['TotalDamage'],array('Combat','Planet','Damage Done'), HOF_PUBLIC); |
|
| 964 | + $thisPlayer->increaseExperience(round($results['TotalDamage'] / 20)); // 1/20 weapon damage to exp. |
|
| 965 | + $thisPlayer->increaseHOF($results['TotalDamage'], array('Combat', 'Planet', 'Damage Done'), HOF_PUBLIC); |
|
| 966 | 966 | // $thisPlayer->increaseHOF(1,array('Combat','Planet','Shots')); //in SmrPlanet::attackedBy() |
| 967 | 967 | return $results; |
| 968 | 968 | } |
@@ -972,15 +972,15 @@ discard block |
||
| 972 | 972 | $armourDamage = 0; |
| 973 | 973 | $cdDamage = 0; |
| 974 | 974 | $shieldDamage = 0; |
| 975 | - if(!$alreadyDead) { |
|
| 976 | - $shieldDamage = $this->doShieldDamage(min($damage['MaxDamage'],$damage['Shield'])); |
|
| 975 | + if (!$alreadyDead) { |
|
| 976 | + $shieldDamage = $this->doShieldDamage(min($damage['MaxDamage'], $damage['Shield'])); |
|
| 977 | 977 | $damage['MaxDamage'] -= $shieldDamage; |
| 978 | - if(!$this->hasShields() && ($shieldDamage == 0 || $damage['Rollover'])) { |
|
| 979 | - $cdDamage = $this->doCDDamage(min($damage['MaxDamage'],$damage['Armour'])); |
|
| 978 | + if (!$this->hasShields() && ($shieldDamage == 0 || $damage['Rollover'])) { |
|
| 979 | + $cdDamage = $this->doCDDamage(min($damage['MaxDamage'], $damage['Armour'])); |
|
| 980 | 980 | $damage['Armour'] -= $cdDamage; |
| 981 | 981 | $damage['MaxDamage'] -= $cdDamage; |
| 982 | - if(!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) |
|
| 983 | - $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'],$damage['Armour'])); |
|
| 982 | + if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) |
|
| 983 | + $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour'])); |
|
| 984 | 984 | } |
| 985 | 985 | } |
| 986 | 986 | $return = array( |
@@ -988,10 +988,10 @@ discard block |
||
| 988 | 988 | 'TargetAlreadyDead' => $alreadyDead, |
| 989 | 989 | 'Shield' => $shieldDamage, |
| 990 | 990 | 'CDs' => $cdDamage, |
| 991 | - 'NumCDs' => $cdDamage/CD_ARMOUR, |
|
| 991 | + 'NumCDs' => $cdDamage / CD_ARMOUR, |
|
| 992 | 992 | 'Armour' => $armourDamage, |
| 993 | 993 | 'HasCDs' => $this->hasCDs(), |
| 994 | - 'TotalDamage' => $shieldDamage+$cdDamage+$armourDamage |
|
| 994 | + 'TotalDamage' => $shieldDamage + $cdDamage + $armourDamage |
|
| 995 | 995 | ); |
| 996 | 996 | return $return; |
| 997 | 997 | } |
@@ -1001,11 +1001,11 @@ discard block |
||
| 1001 | 1001 | $armourDamage = 0; |
| 1002 | 1002 | $cdDamage = 0; |
| 1003 | 1003 | $shieldDamage = 0; |
| 1004 | - if(!$alreadyDead) { |
|
| 1005 | - $shieldDamage = $this->doShieldDamage(min($damage['MaxDamage'],$damage['Shield'])); |
|
| 1004 | + if (!$alreadyDead) { |
|
| 1005 | + $shieldDamage = $this->doShieldDamage(min($damage['MaxDamage'], $damage['Shield'])); |
|
| 1006 | 1006 | $damage['MaxDamage'] -= $shieldDamage; |
| 1007 | - if(!$this->hasShields() && ($shieldDamage == 0 || $damage['Rollover'])) { //skip CDs if it's mines |
|
| 1008 | - $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'],$damage['Armour'])); |
|
| 1007 | + if (!$this->hasShields() && ($shieldDamage == 0 || $damage['Rollover'])) { //skip CDs if it's mines |
|
| 1008 | + $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour'])); |
|
| 1009 | 1009 | } |
| 1010 | 1010 | } |
| 1011 | 1011 | $return = array( |
@@ -1013,28 +1013,28 @@ discard block |
||
| 1013 | 1013 | 'TargetAlreadyDead' => $alreadyDead, |
| 1014 | 1014 | 'Shield' => $shieldDamage, |
| 1015 | 1015 | 'CDs' => $cdDamage, |
| 1016 | - 'NumCDs' => $cdDamage/CD_ARMOUR, |
|
| 1016 | + 'NumCDs' => $cdDamage / CD_ARMOUR, |
|
| 1017 | 1017 | 'Armour' => $armourDamage, |
| 1018 | 1018 | 'HasCDs' => $this->hasCDs(), |
| 1019 | - 'TotalDamage' => $shieldDamage+$cdDamage+$armourDamage |
|
| 1019 | + 'TotalDamage' => $shieldDamage + $cdDamage + $armourDamage |
|
| 1020 | 1020 | ); |
| 1021 | 1021 | return $return; |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | protected function doShieldDamage($damage) { |
| 1025 | - $actualDamage = min($this->getShields(),$damage); |
|
| 1025 | + $actualDamage = min($this->getShields(), $damage); |
|
| 1026 | 1026 | $this->decreaseShields($actualDamage); |
| 1027 | 1027 | return $actualDamage; |
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | protected function doCDDamage($damage) { |
| 1031 | - $actualDamage = min($this->getCDs(),floor($damage/CD_ARMOUR)); |
|
| 1031 | + $actualDamage = min($this->getCDs(), floor($damage / CD_ARMOUR)); |
|
| 1032 | 1032 | $this->decreaseCDs($actualDamage); |
| 1033 | - return $actualDamage*CD_ARMOUR; |
|
| 1033 | + return $actualDamage * CD_ARMOUR; |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | protected function doArmourDamage($damage) { |
| 1037 | - $actualDamage = min($this->getArmour(),$damage); |
|
| 1037 | + $actualDamage = min($this->getArmour(), $damage); |
|
| 1038 | 1038 | $this->decreaseArmour($actualDamage); |
| 1039 | 1039 | return $actualDamage; |
| 1040 | 1040 | } |
@@ -1046,17 +1046,17 @@ discard block |
||
| 1046 | 1046 | ( |
| 1047 | 1047 | $this->getShields() |
| 1048 | 1048 | +$this->getArmour() |
| 1049 | - +$this->getCDs()*3 |
|
| 1050 | - )/25 |
|
| 1049 | + +$this->getCDs() * 3 |
|
| 1050 | + ) / 25 |
|
| 1051 | 1051 | +( |
| 1052 | - $this->getCargoHolds()/100 |
|
| 1053 | - -$this->getSpeed()*5 |
|
| 1054 | - +($this->getHardpoints()/*+$ship['Increases']['Ship Power']*/)*5 |
|
| 1052 | + $this->getCargoHolds() / 100 |
|
| 1053 | + -$this->getSpeed() * 5 |
|
| 1054 | + +($this->getHardpoints()/*+$ship['Increases']['Ship Power']*/) * 5 |
|
| 1055 | 1055 | /*+( |
| 1056 | 1056 | $ship['Increases']['Mines'] |
| 1057 | 1057 | +$ship['Increases']['Scout Drones'] |
| 1058 | 1058 | )/12*/ |
| 1059 | - +$this->getCDs()/5 |
|
| 1059 | + +$this->getCDs() / 5 |
|
| 1060 | 1060 | ) |
| 1061 | 1061 | ) |
| 1062 | 1062 | ); |
@@ -28,10 +28,11 @@ discard block |
||
| 28 | 28 | // determine ship |
| 29 | 29 | $db = new SmrMySqlDatabase(); |
| 30 | 30 | $db->query('SELECT * FROM ship_type WHERE ship_type_id = '.$db->escapeNumber($shipTypeID).' LIMIT 1'); //TODO add game type id |
| 31 | - if($db->nextRecord()) |
|
| 32 | - self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = self::buildBaseShip($db); |
|
| 33 | - else |
|
| 34 | - self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = false; |
|
| 31 | + if($db->nextRecord()) { |
|
| 32 | + self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = self::buildBaseShip($db); |
|
| 33 | + } else { |
|
| 34 | + self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = false; |
|
| 35 | + } |
|
| 35 | 36 | } |
| 36 | 37 | return self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID]; |
| 37 | 38 | } |
@@ -157,19 +158,21 @@ discard block |
||
| 157 | 158 | |
| 158 | 159 | public function checkForExcessHardware() { |
| 159 | 160 | //check hardware to see if anything needs to be removed |
| 160 | - if(is_array($hardware = $this->getHardware())) |
|
| 161 | - foreach ($hardware as $hardwareTypeID => $amount) { |
|
| 161 | + if(is_array($hardware = $this->getHardware())) { |
|
| 162 | + foreach ($hardware as $hardwareTypeID => $amount) { |
|
| 162 | 163 | if ($amount > ($max=$this->getMaxHardware($hardwareTypeID))) { |
| 163 | 164 | $this->setHardware($hardwareTypeID,$max,true); |
| 165 | + } |
|
| 164 | 166 | } |
| 165 | 167 | } |
| 166 | 168 | } |
| 167 | 169 | |
| 168 | 170 | public function getPowerUsed() { |
| 169 | 171 | $power = 0; |
| 170 | - if($this->getNumWeapons()>0) |
|
| 171 | - foreach ($this->weapons as $weapon) |
|
| 172 | + if($this->getNumWeapons()>0) { |
|
| 173 | + foreach ($this->weapons as $weapon) |
|
| 172 | 174 | $power += $weapon->getPowerLevel(); |
| 175 | + } |
|
| 173 | 176 | return $power; |
| 174 | 177 | } |
| 175 | 178 | |
@@ -190,17 +193,19 @@ discard block |
||
| 190 | 193 | } |
| 191 | 194 | |
| 192 | 195 | public function getDisplayAttackRating(AbstractSmrPlayer $player) { |
| 193 | - if($this->hasActiveIllusion()) |
|
| 194 | - return $this->getIllusionAttack(); |
|
| 195 | - else |
|
| 196 | - return $this->getAttackRating(); |
|
| 196 | + if($this->hasActiveIllusion()) { |
|
| 197 | + return $this->getIllusionAttack(); |
|
| 198 | + } else { |
|
| 199 | + return $this->getAttackRating(); |
|
| 200 | + } |
|
| 197 | 201 | } |
| 198 | 202 | |
| 199 | 203 | public function getDisplayDefenseRating() { |
| 200 | - if($this->hasActiveIllusion()) |
|
| 201 | - return $this->getIllusionDefense(); |
|
| 202 | - else |
|
| 203 | - return $this->getDefenseRating(); |
|
| 204 | + if($this->hasActiveIllusion()) { |
|
| 205 | + return $this->getIllusionDefense(); |
|
| 206 | + } else { |
|
| 207 | + return $this->getDefenseRating(); |
|
| 208 | + } |
|
| 204 | 209 | } |
| 205 | 210 | |
| 206 | 211 | public function getAttackRating() { |
@@ -250,8 +255,7 @@ discard block |
||
| 250 | 255 | $this->weapons[$i-1] =& $this->weapons[$i]; //If we go above the bounds of the array it will keep on going due to assign by ref. Hence $i-1 =& $i not $i =& $i+1 |
| 251 | 256 | } |
| 252 | 257 | $this->weapons[count($this->weapons)-1] =& $temp; |
| 253 | - } |
|
| 254 | - else { |
|
| 258 | + } else { |
|
| 255 | 259 | $temp = $this->weapons[$replacement]; |
| 256 | 260 | $this->weapons[$replacement] = $this->weapons[$orderID]; |
| 257 | 261 | $this->weapons[$orderID] = $temp; |
@@ -268,8 +272,7 @@ discard block |
||
| 268 | 272 | $this->weapons[$i] =& $this->weapons[$i-1]; |
| 269 | 273 | } |
| 270 | 274 | $this->weapons[0] =& $temp; |
| 271 | - } |
|
| 272 | - else { |
|
| 275 | + } else { |
|
| 273 | 276 | $temp = $this->weapons[$replacement]; |
| 274 | 277 | $this->weapons[$replacement] = $this->weapons[$orderID]; |
| 275 | 278 | $this->weapons[$orderID] = $temp; |
@@ -328,8 +331,7 @@ discard block |
||
| 328 | 331 | $this->setArmour(150,true); |
| 329 | 332 | $this->setCargoHolds(40); |
| 330 | 333 | $this->setShipTypeID(SHIP_TYPE_NEWBIE_MERCHANT_VESSEL); |
| 331 | - } |
|
| 332 | - else { |
|
| 334 | + } else { |
|
| 333 | 335 | $this->setShields(50,true); |
| 334 | 336 | $this->setArmour(50,true); |
| 335 | 337 | $this->setCargoHolds(5); |
@@ -349,8 +351,9 @@ discard block |
||
| 349 | 351 | |
| 350 | 352 | |
| 351 | 353 | public function hasActiveIllusion() { |
| 352 | - if(!$this->hasIllusion()) |
|
| 353 | - return false; |
|
| 354 | + if(!$this->hasIllusion()) { |
|
| 355 | + return false; |
|
| 356 | + } |
|
| 354 | 357 | return $this->getIllusionShip()!==false; |
| 355 | 358 | |
| 356 | 359 | } |
@@ -474,14 +477,16 @@ discard block |
||
| 474 | 477 | } |
| 475 | 478 | |
| 476 | 479 | public function getHardware($hardwareTypeID = false) { |
| 477 | - if($hardwareTypeID === false) |
|
| 478 | - return $this->hardware; |
|
| 480 | + if($hardwareTypeID === false) { |
|
| 481 | + return $this->hardware; |
|
| 482 | + } |
|
| 479 | 483 | return isset($this->hardware[$hardwareTypeID]) ? $this->hardware[$hardwareTypeID] : 0; |
| 480 | 484 | } |
| 481 | 485 | |
| 482 | 486 | public function setHardware($hardwareTypeID,$amount) { |
| 483 | - if($this->getHardware($hardwareTypeID) == $amount) |
|
| 484 | - return; |
|
| 487 | + if($this->getHardware($hardwareTypeID) == $amount) { |
|
| 488 | + return; |
|
| 489 | + } |
|
| 485 | 490 | $this->hardware[$hardwareTypeID] = $amount; |
| 486 | 491 | $this->hasChangedHardware[$hardwareTypeID] = true; |
| 487 | 492 | } |
@@ -491,14 +496,16 @@ discard block |
||
| 491 | 496 | } |
| 492 | 497 | |
| 493 | 498 | public function getOldHardware($hardwareTypeID = false) { |
| 494 | - if($hardwareTypeID === false) |
|
| 495 | - return $this->oldHardware; |
|
| 499 | + if($hardwareTypeID === false) { |
|
| 500 | + return $this->oldHardware; |
|
| 501 | + } |
|
| 496 | 502 | return isset($this->oldHardware[$hardwareTypeID]) ? $this->oldHardware[$hardwareTypeID] : 0; |
| 497 | 503 | } |
| 498 | 504 | |
| 499 | 505 | public function setOldHardware($hardwareTypeID,$amount) { |
| 500 | - if($this->getOldHardware($hardwareTypeID) == $amount) |
|
| 501 | - return; |
|
| 506 | + if($this->getOldHardware($hardwareTypeID) == $amount) { |
|
| 507 | + return; |
|
| 508 | + } |
|
| 502 | 509 | $this->oldHardware[$hardwareTypeID] = $amount; |
| 503 | 510 | $this->hasChangedHardware[$hardwareTypeID] = true; |
| 504 | 511 | } |
@@ -508,8 +515,9 @@ discard block |
||
| 508 | 515 | } |
| 509 | 516 | |
| 510 | 517 | public function getMaxHardware($hardwareTypeID = false) { |
| 511 | - if($hardwareTypeID === false) |
|
| 512 | - return $this->baseShip['MaxHardware']; |
|
| 518 | + if($hardwareTypeID === false) { |
|
| 519 | + return $this->baseShip['MaxHardware']; |
|
| 520 | + } |
|
| 513 | 521 | return $this->baseShip['MaxHardware'][$hardwareTypeID]; |
| 514 | 522 | } |
| 515 | 523 | |
@@ -518,8 +526,9 @@ discard block |
||
| 518 | 526 | } |
| 519 | 527 | |
| 520 | 528 | public function setShields($amount,$updateOldAmount=false) { |
| 521 | - if($updateOldAmount && !$this->hasLostShields()) |
|
| 522 | - $this->setOldHardware(HARDWARE_SHIELDS,$amount); |
|
| 529 | + if($updateOldAmount && !$this->hasLostShields()) { |
|
| 530 | + $this->setOldHardware(HARDWARE_SHIELDS,$amount); |
|
| 531 | + } |
|
| 523 | 532 | $this->setHardware(HARDWARE_SHIELDS,$amount); |
| 524 | 533 | } |
| 525 | 534 | |
@@ -560,8 +569,9 @@ discard block |
||
| 560 | 569 | } |
| 561 | 570 | |
| 562 | 571 | public function setArmour($amount,$updateOldAmount=false) { |
| 563 | - if($updateOldAmount && !$this->hasLostArmour()) |
|
| 564 | - $this->setOldHardware(HARDWARE_ARMOUR,$amount); |
|
| 572 | + if($updateOldAmount && !$this->hasLostArmour()) { |
|
| 573 | + $this->setOldHardware(HARDWARE_ARMOUR,$amount); |
|
| 574 | + } |
|
| 565 | 575 | $this->setHardware(HARDWARE_ARMOUR,$amount); |
| 566 | 576 | } |
| 567 | 577 | |
@@ -630,8 +640,9 @@ discard block |
||
| 630 | 640 | } |
| 631 | 641 | |
| 632 | 642 | public function setCDs($amount,$updateOldAmount=false) { |
| 633 | - if($updateOldAmount && !$this->hasLostCDs()) |
|
| 634 | - $this->setOldHardware(HARDWARE_COMBAT,$amount); |
|
| 643 | + if($updateOldAmount && !$this->hasLostCDs()) { |
|
| 644 | + $this->setOldHardware(HARDWARE_COMBAT,$amount); |
|
| 645 | + } |
|
| 635 | 646 | $this->setHardware(HARDWARE_COMBAT,$amount); |
| 636 | 647 | } |
| 637 | 648 | |
@@ -713,8 +724,9 @@ discard block |
||
| 713 | 724 | |
| 714 | 725 | public function &getCargo($goodID=false) { |
| 715 | 726 | if($goodID!==false) { |
| 716 | - if(isset($this->cargo[$goodID])) |
|
| 717 | - return $this->cargo[$goodID]; |
|
| 727 | + if(isset($this->cargo[$goodID])) { |
|
| 728 | + return $this->cargo[$goodID]; |
|
| 729 | + } |
|
| 718 | 730 | $cargo = 0; |
| 719 | 731 | return $cargo; |
| 720 | 732 | } |
@@ -722,16 +734,19 @@ discard block |
||
| 722 | 734 | } |
| 723 | 735 | |
| 724 | 736 | public function hasCargo($goodID=false) { |
| 725 | - if($goodID!==false) |
|
| 726 | - return $this->getCargo($goodID)>0; |
|
| 727 | - if(is_array($cargo = $this->getCargo())) |
|
| 728 | - return array_sum($cargo)>0; |
|
| 737 | + if($goodID!==false) { |
|
| 738 | + return $this->getCargo($goodID)>0; |
|
| 739 | + } |
|
| 740 | + if(is_array($cargo = $this->getCargo())) { |
|
| 741 | + return array_sum($cargo)>0; |
|
| 742 | + } |
|
| 729 | 743 | return false; |
| 730 | 744 | } |
| 731 | 745 | |
| 732 | 746 | public function setCargo($goodID,$amount) { |
| 733 | - if($this->getCargo($goodID) == $amount) |
|
| 734 | - return; |
|
| 747 | + if($this->getCargo($goodID) == $amount) { |
|
| 748 | + return; |
|
| 749 | + } |
|
| 735 | 750 | $this->cargo[$goodID] = $amount; |
| 736 | 751 | $this->hasChangedCargo = true; |
| 737 | 752 | // Sort cargo by goodID to make sure it shows up in the correct order |
@@ -740,14 +755,16 @@ discard block |
||
| 740 | 755 | } |
| 741 | 756 | |
| 742 | 757 | public function decreaseCargo($goodID,$amount) { |
| 743 | - if($amount < 0) |
|
| 744 | - throw new Exception('Trying to decrease negative cargo.'); |
|
| 758 | + if($amount < 0) { |
|
| 759 | + throw new Exception('Trying to decrease negative cargo.'); |
|
| 760 | + } |
|
| 745 | 761 | $this->setCargo($goodID,$this->getCargo($goodID)-$amount); |
| 746 | 762 | } |
| 747 | 763 | |
| 748 | 764 | public function increaseCargo($goodID,$amount) { |
| 749 | - if($amount < 0) |
|
| 750 | - throw new Exception('Trying to increase negative cargo.'); |
|
| 765 | + if($amount < 0) { |
|
| 766 | + throw new Exception('Trying to increase negative cargo.'); |
|
| 767 | + } |
|
| 751 | 768 | $this->setCargo($goodID,$this->getCargo($goodID)+$amount); |
| 752 | 769 | } |
| 753 | 770 | |
@@ -777,8 +794,9 @@ discard block |
||
| 777 | 794 | $this->setOldShields($this->getShields()); |
| 778 | 795 | $this->setOldCDs($this->getCDs()); |
| 779 | 796 | $this->setOldArmour($this->getArmour()); |
| 780 | - if(isset($var['UnderAttack'])) |
|
| 781 | - return $var['UnderAttack']; |
|
| 797 | + if(isset($var['UnderAttack'])) { |
|
| 798 | + return $var['UnderAttack']; |
|
| 799 | + } |
|
| 782 | 800 | if($underAttack && !USING_AJAX) { |
| 783 | 801 | SmrSession::updateVar('UnderAttack',$underAttack); //Remember we are under attack for AJAX |
| 784 | 802 | } |
@@ -853,8 +871,9 @@ discard block |
||
| 853 | 871 | $results['DeadBeforeShot'] = false; |
| 854 | 872 | foreach($this->weapons as $orderID => $weapon) { |
| 855 | 873 | $results['Weapons'][$orderID] =& $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]); |
| 856 | - if($results['Weapons'][$orderID]['Hit']) |
|
| 857 | - $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
| 874 | + if($results['Weapons'][$orderID]['Hit']) { |
|
| 875 | + $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
| 876 | + } |
|
| 858 | 877 | } |
| 859 | 878 | if($this->hasCDs()) { |
| 860 | 879 | $thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs()); |
@@ -916,8 +935,9 @@ discard block |
||
| 916 | 935 | $results['DeadBeforeShot'] = false; |
| 917 | 936 | foreach($this->weapons as $orderID => $weapon) { |
| 918 | 937 | $results['Weapons'][$orderID] =& $weapon->shootPort($thisPlayer, $port); |
| 919 | - if($results['Weapons'][$orderID]['Hit']) |
|
| 920 | - $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
| 938 | + if($results['Weapons'][$orderID]['Hit']) { |
|
| 939 | + $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
| 940 | + } |
|
| 921 | 941 | } |
| 922 | 942 | if($this->hasCDs()) { |
| 923 | 943 | $thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs()); |
@@ -953,8 +973,9 @@ discard block |
||
| 953 | 973 | $results['DeadBeforeShot'] = false; |
| 954 | 974 | foreach($this->weapons as $orderID => $weapon) { |
| 955 | 975 | $results['Weapons'][$orderID] =& $weapon->shootPlanet($thisPlayer, $planet, $delayed); |
| 956 | - if($results['Weapons'][$orderID]['Hit']) |
|
| 957 | - $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
| 976 | + if($results['Weapons'][$orderID]['Hit']) { |
|
| 977 | + $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
| 978 | + } |
|
| 958 | 979 | } |
| 959 | 980 | if($this->hasCDs()) { |
| 960 | 981 | $thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs()); |
@@ -979,8 +1000,9 @@ discard block |
||
| 979 | 1000 | $cdDamage = $this->doCDDamage(min($damage['MaxDamage'],$damage['Armour'])); |
| 980 | 1001 | $damage['Armour'] -= $cdDamage; |
| 981 | 1002 | $damage['MaxDamage'] -= $cdDamage; |
| 982 | - if(!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) |
|
| 983 | - $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'],$damage['Armour'])); |
|
| 1003 | + if(!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) { |
|
| 1004 | + $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'],$damage['Armour'])); |
|
| 1005 | + } |
|
| 984 | 1006 | } |
| 985 | 1007 | } |
| 986 | 1008 | $return = array( |