We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -50,7 +50,6 @@ |
||
50 | 50 | $template->assign('Body', 'login/login.php'); |
51 | 51 | $template->display('login/skeleton.php'); |
52 | 52 | |
53 | -} |
|
54 | -catch (Throwable $e) { |
|
53 | +} catch (Throwable $e) { |
|
55 | 54 | handleException($e); |
56 | 55 | } |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | $shareFrom[$fromAccountId] = array( |
20 | 20 | 'Player ID' => $otherPlayer == null ? '-' : $otherPlayer->getPlayerID(), |
21 | 21 | 'Player Name' => $otherPlayer == null ? |
22 | - '<b>Account</b>: ' . SmrAccount::getAccount($fromAccountId)->getHofDisplayName() : |
|
23 | - $otherPlayer->getPlayerName(), |
|
22 | + '<b>Account</b>: ' . SmrAccount::getAccount($fromAccountId)->getHofDisplayName() : |
|
23 | + $otherPlayer->getPlayerName(), |
|
24 | 24 | 'All Games' => $gameId == 0 ? '<span class="green">YES</span>' : '<span class="red">NO</span>', |
25 | 25 | 'Game ID' => $gameId, |
26 | 26 | ); |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | $shareTo[$toAccountId] = array( |
41 | 41 | 'Player ID' => $otherPlayer == null ? '-' : $otherPlayer->getPlayerID(), |
42 | 42 | 'Player Name' => $otherPlayer == null ? |
43 | - '<b>Account</b>: ' . SmrAccount::getAccount($toAccountId)->getHofDisplayName() : |
|
44 | - $otherPlayer->getPlayerName(), |
|
43 | + '<b>Account</b>: ' . SmrAccount::getAccount($toAccountId)->getHofDisplayName() : |
|
44 | + $otherPlayer->getPlayerName(), |
|
45 | 45 | 'All Games' => $gameId == 0 ? '<span class="green">YES</span>' : '<span class="red">NO</span>', |
46 | 46 | 'Game ID' => $gameId, |
47 | 47 | ); |
@@ -19,8 +19,7 @@ discard block |
||
19 | 19 | $shareFrom[$fromAccountId] = array( |
20 | 20 | 'Player ID' => $otherPlayer == null ? '-' : $otherPlayer->getPlayerID(), |
21 | 21 | 'Player Name' => $otherPlayer == null ? |
22 | - '<b>Account</b>: ' . SmrAccount::getAccount($fromAccountId)->getHofDisplayName() : |
|
23 | - $otherPlayer->getPlayerName(), |
|
22 | + '<b>Account</b>: ' . SmrAccount::getAccount($fromAccountId)->getHofDisplayName() : $otherPlayer->getPlayerName(), |
|
24 | 23 | 'All Games' => $gameId == 0 ? '<span class="green">YES</span>' : '<span class="red">NO</span>', |
25 | 24 | 'Game ID' => $gameId, |
26 | 25 | ); |
@@ -40,8 +39,7 @@ discard block |
||
40 | 39 | $shareTo[$toAccountId] = array( |
41 | 40 | 'Player ID' => $otherPlayer == null ? '-' : $otherPlayer->getPlayerID(), |
42 | 41 | 'Player Name' => $otherPlayer == null ? |
43 | - '<b>Account</b>: ' . SmrAccount::getAccount($toAccountId)->getHofDisplayName() : |
|
44 | - $otherPlayer->getPlayerName(), |
|
42 | + '<b>Account</b>: ' . SmrAccount::getAccount($toAccountId)->getHofDisplayName() : $otherPlayer->getPlayerName(), |
|
45 | 43 | 'All Games' => $gameId == 0 ? '<span class="green">YES</span>' : '<span class="red">NO</span>', |
46 | 44 | 'Game ID' => $gameId, |
47 | 45 | ); |
@@ -857,14 +857,14 @@ |
||
857 | 857 | |
858 | 858 | public function isFederal() { |
859 | 859 | return $this->getShipTypeID() == SHIP_TYPE_FEDERAL_DISCOVERY || |
860 | - $this->getShipTypeID() == SHIP_TYPE_FEDERAL_WARRANT || |
|
861 | - $this->getShipTypeID() == SHIP_TYPE_FEDERAL_ULTIMATUM; |
|
860 | + $this->getShipTypeID() == SHIP_TYPE_FEDERAL_WARRANT || |
|
861 | + $this->getShipTypeID() == SHIP_TYPE_FEDERAL_ULTIMATUM; |
|
862 | 862 | } |
863 | 863 | |
864 | 864 | public function isUnderground() { |
865 | 865 | return $this->getShipTypeID() == SHIP_TYPE_THIEF || |
866 | - $this->getShipTypeID() == SHIP_TYPE_ASSASSIN || |
|
867 | - $this->getShipTypeID() == SHIP_TYPE_DEATH_CRUISER; |
|
866 | + $this->getShipTypeID() == SHIP_TYPE_ASSASSIN || |
|
867 | + $this->getShipTypeID() == SHIP_TYPE_DEATH_CRUISER; |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | public function &shootPlayer(AbstractSmrPlayer $targetPlayer) { |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | public function setWeaponLocations(array $orderArray) { |
296 | 296 | $weapons = $this->weapons; |
297 | 297 | foreach ($orderArray as $newOrder => $oldOrder) { |
298 | - $this->weapons[$newOrder] =& $weapons[$oldOrder]; |
|
298 | + $this->weapons[$newOrder] = & $weapons[$oldOrder]; |
|
299 | 299 | } |
300 | 300 | $this->hasChangedWeapons = true; |
301 | 301 | } |
@@ -880,13 +880,13 @@ discard block |
||
880 | 880 | } |
881 | 881 | $results['DeadBeforeShot'] = false; |
882 | 882 | foreach ($this->weapons as $orderID => $weapon) { |
883 | - $results['Weapons'][$orderID] =& $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]); |
|
883 | + $results['Weapons'][$orderID] = & $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]); |
|
884 | 884 | if ($results['Weapons'][$orderID]['Hit']) |
885 | 885 | $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
886 | 886 | } |
887 | 887 | if ($this->hasCDs()) { |
888 | 888 | $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
889 | - $results['Drones'] =& $thisCDs->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]); |
|
889 | + $results['Drones'] = & $thisCDs->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]); |
|
890 | 890 | $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; |
891 | 891 | } |
892 | 892 | $thisPlayer->increaseExperience(IRound($results['TotalDamage'] * self::EXP_PER_DAMAGE_PLAYER)); |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | } |
905 | 905 | $results['DeadBeforeShot'] = false; |
906 | 906 | foreach ($this->weapons as $orderID => $weapon) { |
907 | - $results['Weapons'][$orderID] =& $weapon->shootForces($thisPlayer, $forces); |
|
907 | + $results['Weapons'][$orderID] = & $weapon->shootForces($thisPlayer, $forces); |
|
908 | 908 | if ($results['Weapons'][$orderID]['Hit']) { |
909 | 909 | $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
910 | 910 | $thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines'], array('Combat', 'Forces', 'Mines', 'Killed'), HOF_PUBLIC); |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | } |
919 | 919 | if ($this->hasCDs()) { |
920 | 920 | $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
921 | - $results['Drones'] =& $thisCDs->shootForces($thisPlayer, $forces); |
|
921 | + $results['Drones'] = & $thisCDs->shootForces($thisPlayer, $forces); |
|
922 | 922 | $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; |
923 | 923 | $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines'], array('Combat', 'Forces', 'Mines', 'Killed'), HOF_PUBLIC); |
924 | 924 | $thisPlayer->increaseHOF($results['Drones']['ActualDamage']['Mines'], array('Combat', 'Forces', 'Mines', 'Damage Done'), HOF_PUBLIC); |
@@ -943,13 +943,13 @@ discard block |
||
943 | 943 | } |
944 | 944 | $results['DeadBeforeShot'] = false; |
945 | 945 | foreach ($this->weapons as $orderID => $weapon) { |
946 | - $results['Weapons'][$orderID] =& $weapon->shootPort($thisPlayer, $port); |
|
946 | + $results['Weapons'][$orderID] = & $weapon->shootPort($thisPlayer, $port); |
|
947 | 947 | if ($results['Weapons'][$orderID]['Hit']) |
948 | 948 | $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
949 | 949 | } |
950 | 950 | if ($this->hasCDs()) { |
951 | 951 | $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
952 | - $results['Drones'] =& $thisCDs->shootPort($thisPlayer, $port); |
|
952 | + $results['Drones'] = & $thisCDs->shootPort($thisPlayer, $port); |
|
953 | 953 | $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; |
954 | 954 | } |
955 | 955 | $thisPlayer->increaseExperience(IRound($results['TotalDamage'] * self::EXP_PER_DAMAGE_PORT)); |
@@ -980,13 +980,13 @@ discard block |
||
980 | 980 | } |
981 | 981 | $results['DeadBeforeShot'] = false; |
982 | 982 | foreach ($this->weapons as $orderID => $weapon) { |
983 | - $results['Weapons'][$orderID] =& $weapon->shootPlanet($thisPlayer, $planet, $delayed); |
|
983 | + $results['Weapons'][$orderID] = & $weapon->shootPlanet($thisPlayer, $planet, $delayed); |
|
984 | 984 | if ($results['Weapons'][$orderID]['Hit']) |
985 | 985 | $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
986 | 986 | } |
987 | 987 | if ($this->hasCDs()) { |
988 | 988 | $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
989 | - $results['Drones'] =& $thisCDs->shootPlanet($thisPlayer, $planet, $delayed); |
|
989 | + $results['Drones'] = & $thisCDs->shootPlanet($thisPlayer, $planet, $delayed); |
|
990 | 990 | $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; |
991 | 991 | } |
992 | 992 | $thisPlayer->increaseExperience(IRound($results['TotalDamage'] * self::EXP_PER_DAMAGE_PLANET)); |
@@ -34,10 +34,11 @@ discard block |
||
34 | 34 | // determine ship |
35 | 35 | $db = new SmrMySqlDatabase(); |
36 | 36 | $db->query('SELECT * FROM ship_type WHERE ship_type_id = ' . $db->escapeNumber($shipTypeID) . ' LIMIT 1'); //TODO add game type id |
37 | - if ($db->nextRecord()) |
|
38 | - self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = self::buildBaseShip($db); |
|
39 | - else |
|
40 | - self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = false; |
|
37 | + if ($db->nextRecord()) { |
|
38 | + self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = self::buildBaseShip($db); |
|
39 | + } else { |
|
40 | + self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = false; |
|
41 | + } |
|
41 | 42 | } |
42 | 43 | return self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID]; |
43 | 44 | } |
@@ -168,10 +169,11 @@ discard block |
||
168 | 169 | |
169 | 170 | public function checkForExcessHardware() { |
170 | 171 | //check hardware to see if anything needs to be removed |
171 | - if (is_array($hardware = $this->getHardware())) |
|
172 | - foreach ($hardware as $hardwareTypeID => $amount) { |
|
172 | + if (is_array($hardware = $this->getHardware())) { |
|
173 | + foreach ($hardware as $hardwareTypeID => $amount) { |
|
173 | 174 | if ($amount > ($max = $this->getMaxHardware($hardwareTypeID))) { |
174 | 175 | $this->setHardware($hardwareTypeID, $max, true); |
176 | + } |
|
175 | 177 | } |
176 | 178 | } |
177 | 179 | } |
@@ -188,9 +190,10 @@ discard block |
||
188 | 190 | |
189 | 191 | public function getPowerUsed() { |
190 | 192 | $power = 0; |
191 | - if ($this->getNumWeapons() > 0) |
|
192 | - foreach ($this->weapons as $weapon) |
|
193 | + if ($this->getNumWeapons() > 0) { |
|
194 | + foreach ($this->weapons as $weapon) |
|
193 | 195 | $power += $weapon->getPowerLevel(); |
196 | + } |
|
194 | 197 | return $power; |
195 | 198 | } |
196 | 199 | |
@@ -211,17 +214,19 @@ discard block |
||
211 | 214 | } |
212 | 215 | |
213 | 216 | public function getDisplayAttackRating(AbstractSmrPlayer $player) { |
214 | - if ($this->hasActiveIllusion()) |
|
215 | - return $this->getIllusionAttack(); |
|
216 | - else |
|
217 | - return $this->getAttackRating(); |
|
217 | + if ($this->hasActiveIllusion()) { |
|
218 | + return $this->getIllusionAttack(); |
|
219 | + } else { |
|
220 | + return $this->getAttackRating(); |
|
221 | + } |
|
218 | 222 | } |
219 | 223 | |
220 | 224 | public function getDisplayDefenseRating() { |
221 | - if ($this->hasActiveIllusion()) |
|
222 | - return $this->getIllusionDefense(); |
|
223 | - else |
|
224 | - return $this->getDefenseRating(); |
|
225 | + if ($this->hasActiveIllusion()) { |
|
226 | + return $this->getIllusionDefense(); |
|
227 | + } else { |
|
228 | + return $this->getDefenseRating(); |
|
229 | + } |
|
225 | 230 | } |
226 | 231 | |
227 | 232 | public function getAttackRating() : int { |
@@ -267,8 +272,7 @@ discard block |
||
267 | 272 | if ($replacement < 0) { |
268 | 273 | // Shift everything up by one and put the selected weapon at the bottom |
269 | 274 | array_push($this->weapons, array_shift($this->weapons)); |
270 | - } |
|
271 | - else { |
|
275 | + } else { |
|
272 | 276 | // Swap the selected weapon with the one above it |
273 | 277 | $temp = $this->weapons[$replacement]; |
274 | 278 | $this->weapons[$replacement] = $this->weapons[$orderID]; |
@@ -282,8 +286,7 @@ discard block |
||
282 | 286 | if ($replacement >= count($this->weapons)) { |
283 | 287 | // Shift everything down by one and put the selected weapon at the top |
284 | 288 | array_unshift($this->weapons, array_pop($this->weapons)); |
285 | - } |
|
286 | - else { |
|
289 | + } else { |
|
287 | 290 | // Swap the selected weapon with the one below it |
288 | 291 | $temp = $this->weapons[$replacement]; |
289 | 292 | $this->weapons[$replacement] = $this->weapons[$orderID]; |
@@ -342,8 +345,7 @@ discard block |
||
342 | 345 | $this->setArmour(150, true); |
343 | 346 | $this->setCargoHolds(40); |
344 | 347 | $this->setShipTypeID(SHIP_TYPE_NEWBIE_MERCHANT_VESSEL); |
345 | - } |
|
346 | - else { |
|
348 | + } else { |
|
347 | 349 | $this->setShields(50, true); |
348 | 350 | $this->setArmour(50, true); |
349 | 351 | $this->setCargoHolds(5); |
@@ -363,8 +365,9 @@ discard block |
||
363 | 365 | |
364 | 366 | |
365 | 367 | public function hasActiveIllusion() { |
366 | - if (!$this->hasIllusion()) |
|
367 | - return false; |
|
368 | + if (!$this->hasIllusion()) { |
|
369 | + return false; |
|
370 | + } |
|
368 | 371 | return $this->getIllusionShip() !== false; |
369 | 372 | |
370 | 373 | } |
@@ -498,14 +501,16 @@ discard block |
||
498 | 501 | } |
499 | 502 | |
500 | 503 | public function getHardware($hardwareTypeID = false) { |
501 | - if ($hardwareTypeID === false) |
|
502 | - return $this->hardware; |
|
504 | + if ($hardwareTypeID === false) { |
|
505 | + return $this->hardware; |
|
506 | + } |
|
503 | 507 | return isset($this->hardware[$hardwareTypeID]) ? $this->hardware[$hardwareTypeID] : 0; |
504 | 508 | } |
505 | 509 | |
506 | 510 | public function setHardware($hardwareTypeID, $amount) { |
507 | - if ($this->getHardware($hardwareTypeID) == $amount) |
|
508 | - return; |
|
511 | + if ($this->getHardware($hardwareTypeID) == $amount) { |
|
512 | + return; |
|
513 | + } |
|
509 | 514 | $this->hardware[$hardwareTypeID] = $amount; |
510 | 515 | $this->hasChangedHardware[$hardwareTypeID] = true; |
511 | 516 | } |
@@ -515,14 +520,16 @@ discard block |
||
515 | 520 | } |
516 | 521 | |
517 | 522 | public function getOldHardware($hardwareTypeID = false) { |
518 | - if ($hardwareTypeID === false) |
|
519 | - return $this->oldHardware; |
|
523 | + if ($hardwareTypeID === false) { |
|
524 | + return $this->oldHardware; |
|
525 | + } |
|
520 | 526 | return isset($this->oldHardware[$hardwareTypeID]) ? $this->oldHardware[$hardwareTypeID] : 0; |
521 | 527 | } |
522 | 528 | |
523 | 529 | public function setOldHardware($hardwareTypeID, $amount) { |
524 | - if ($this->getOldHardware($hardwareTypeID) == $amount) |
|
525 | - return; |
|
530 | + if ($this->getOldHardware($hardwareTypeID) == $amount) { |
|
531 | + return; |
|
532 | + } |
|
526 | 533 | $this->oldHardware[$hardwareTypeID] = $amount; |
527 | 534 | $this->hasChangedHardware[$hardwareTypeID] = true; |
528 | 535 | } |
@@ -532,8 +539,9 @@ discard block |
||
532 | 539 | } |
533 | 540 | |
534 | 541 | public function getMaxHardware($hardwareTypeID = false) { |
535 | - if ($hardwareTypeID === false) |
|
536 | - return $this->baseShip['MaxHardware']; |
|
542 | + if ($hardwareTypeID === false) { |
|
543 | + return $this->baseShip['MaxHardware']; |
|
544 | + } |
|
537 | 545 | return $this->baseShip['MaxHardware'][$hardwareTypeID]; |
538 | 546 | } |
539 | 547 | |
@@ -542,8 +550,9 @@ discard block |
||
542 | 550 | } |
543 | 551 | |
544 | 552 | public function setShields($amount, $updateOldAmount = false) { |
545 | - if ($updateOldAmount && !$this->hasLostShields()) |
|
546 | - $this->setOldHardware(HARDWARE_SHIELDS, $amount); |
|
553 | + if ($updateOldAmount && !$this->hasLostShields()) { |
|
554 | + $this->setOldHardware(HARDWARE_SHIELDS, $amount); |
|
555 | + } |
|
547 | 556 | $this->setHardware(HARDWARE_SHIELDS, $amount); |
548 | 557 | } |
549 | 558 | |
@@ -584,8 +593,9 @@ discard block |
||
584 | 593 | } |
585 | 594 | |
586 | 595 | public function setArmour($amount, $updateOldAmount = false) { |
587 | - if ($updateOldAmount && !$this->hasLostArmour()) |
|
588 | - $this->setOldHardware(HARDWARE_ARMOUR, $amount); |
|
596 | + if ($updateOldAmount && !$this->hasLostArmour()) { |
|
597 | + $this->setOldHardware(HARDWARE_ARMOUR, $amount); |
|
598 | + } |
|
589 | 599 | $this->setHardware(HARDWARE_ARMOUR, $amount); |
590 | 600 | } |
591 | 601 | |
@@ -654,8 +664,9 @@ discard block |
||
654 | 664 | } |
655 | 665 | |
656 | 666 | public function setCDs($amount, $updateOldAmount = false) { |
657 | - if ($updateOldAmount && !$this->hasLostCDs()) |
|
658 | - $this->setOldHardware(HARDWARE_COMBAT, $amount); |
|
667 | + if ($updateOldAmount && !$this->hasLostCDs()) { |
|
668 | + $this->setOldHardware(HARDWARE_COMBAT, $amount); |
|
669 | + } |
|
659 | 670 | $this->setHardware(HARDWARE_COMBAT, $amount); |
660 | 671 | } |
661 | 672 | |
@@ -737,8 +748,9 @@ discard block |
||
737 | 748 | |
738 | 749 | public function getCargo($goodID = false) { |
739 | 750 | if ($goodID !== false) { |
740 | - if (isset($this->cargo[$goodID])) |
|
741 | - return $this->cargo[$goodID]; |
|
751 | + if (isset($this->cargo[$goodID])) { |
|
752 | + return $this->cargo[$goodID]; |
|
753 | + } |
|
742 | 754 | $cargo = 0; |
743 | 755 | return $cargo; |
744 | 756 | } |
@@ -746,16 +758,19 @@ discard block |
||
746 | 758 | } |
747 | 759 | |
748 | 760 | public function hasCargo($goodID = false) { |
749 | - if ($goodID !== false) |
|
750 | - return $this->getCargo($goodID) > 0; |
|
751 | - if (is_array($cargo = $this->getCargo())) |
|
752 | - return array_sum($cargo) > 0; |
|
761 | + if ($goodID !== false) { |
|
762 | + return $this->getCargo($goodID) > 0; |
|
763 | + } |
|
764 | + if (is_array($cargo = $this->getCargo())) { |
|
765 | + return array_sum($cargo) > 0; |
|
766 | + } |
|
753 | 767 | return false; |
754 | 768 | } |
755 | 769 | |
756 | 770 | public function setCargo($goodID, $amount) { |
757 | - if ($this->getCargo($goodID) == $amount) |
|
758 | - return; |
|
771 | + if ($this->getCargo($goodID) == $amount) { |
|
772 | + return; |
|
773 | + } |
|
759 | 774 | $this->cargo[$goodID] = $amount; |
760 | 775 | $this->hasChangedCargo = true; |
761 | 776 | // Sort cargo by goodID to make sure it shows up in the correct order |
@@ -764,14 +779,16 @@ discard block |
||
764 | 779 | } |
765 | 780 | |
766 | 781 | public function decreaseCargo($goodID, $amount) { |
767 | - if ($amount < 0) |
|
768 | - throw new Exception('Trying to decrease negative cargo.'); |
|
782 | + if ($amount < 0) { |
|
783 | + throw new Exception('Trying to decrease negative cargo.'); |
|
784 | + } |
|
769 | 785 | $this->setCargo($goodID, $this->getCargo($goodID) - $amount); |
770 | 786 | } |
771 | 787 | |
772 | 788 | public function increaseCargo($goodID, $amount) { |
773 | - if ($amount < 0) |
|
774 | - throw new Exception('Trying to increase negative cargo.'); |
|
789 | + if ($amount < 0) { |
|
790 | + throw new Exception('Trying to increase negative cargo.'); |
|
791 | + } |
|
775 | 792 | $this->setCargo($goodID, $this->getCargo($goodID) + $amount); |
776 | 793 | } |
777 | 794 | |
@@ -801,8 +818,9 @@ discard block |
||
801 | 818 | $this->setOldShields($this->getShields()); |
802 | 819 | $this->setOldCDs($this->getCDs()); |
803 | 820 | $this->setOldArmour($this->getArmour()); |
804 | - if (isset($var['UnderAttack'])) |
|
805 | - return $var['UnderAttack']; |
|
821 | + if (isset($var['UnderAttack'])) { |
|
822 | + return $var['UnderAttack']; |
|
823 | + } |
|
806 | 824 | if ($underAttack && !USING_AJAX) { |
807 | 825 | SmrSession::updateVar('UnderAttack', $underAttack); //Remember we are under attack for AJAX |
808 | 826 | } |
@@ -881,8 +899,9 @@ discard block |
||
881 | 899 | $results['DeadBeforeShot'] = false; |
882 | 900 | foreach ($this->weapons as $orderID => $weapon) { |
883 | 901 | $results['Weapons'][$orderID] =& $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]); |
884 | - if ($results['Weapons'][$orderID]['Hit']) |
|
885 | - $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
902 | + if ($results['Weapons'][$orderID]['Hit']) { |
|
903 | + $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
904 | + } |
|
886 | 905 | } |
887 | 906 | if ($this->hasCDs()) { |
888 | 907 | $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
@@ -944,8 +963,9 @@ discard block |
||
944 | 963 | $results['DeadBeforeShot'] = false; |
945 | 964 | foreach ($this->weapons as $orderID => $weapon) { |
946 | 965 | $results['Weapons'][$orderID] =& $weapon->shootPort($thisPlayer, $port); |
947 | - if ($results['Weapons'][$orderID]['Hit']) |
|
948 | - $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
966 | + if ($results['Weapons'][$orderID]['Hit']) { |
|
967 | + $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
968 | + } |
|
949 | 969 | } |
950 | 970 | if ($this->hasCDs()) { |
951 | 971 | $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
@@ -981,8 +1001,9 @@ discard block |
||
981 | 1001 | $results['DeadBeforeShot'] = false; |
982 | 1002 | foreach ($this->weapons as $orderID => $weapon) { |
983 | 1003 | $results['Weapons'][$orderID] =& $weapon->shootPlanet($thisPlayer, $planet, $delayed); |
984 | - if ($results['Weapons'][$orderID]['Hit']) |
|
985 | - $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
1004 | + if ($results['Weapons'][$orderID]['Hit']) { |
|
1005 | + $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
|
1006 | + } |
|
986 | 1007 | } |
987 | 1008 | if ($this->hasCDs()) { |
988 | 1009 | $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
@@ -1007,8 +1028,9 @@ discard block |
||
1007 | 1028 | $cdDamage = $this->doCDDamage(min($damage['MaxDamage'], $damage['Armour'])); |
1008 | 1029 | $damage['Armour'] -= $cdDamage; |
1009 | 1030 | $damage['MaxDamage'] -= $cdDamage; |
1010 | - if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) |
|
1011 | - $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour'])); |
|
1031 | + if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) { |
|
1032 | + $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour'])); |
|
1033 | + } |
|
1012 | 1034 | } |
1013 | 1035 | } |
1014 | 1036 | $return = array( |
@@ -1,36 +1,48 @@ |
||
1 | 1 | <?php declare(strict_types=1); |
2 | 2 | |
3 | -if (isset($var['from'])) $start = $var['from']; |
|
4 | -else $start = trim($_POST['from']); |
|
5 | -if (isset($var['to'])) $target = $var['to']; |
|
6 | -else $target = trim($_POST['to']); |
|
3 | +if (isset($var['from'])) { |
|
4 | + $start = $var['from']; |
|
5 | +} else { |
|
6 | + $start = trim($_POST['from']); |
|
7 | +} |
|
8 | +if (isset($var['to'])) { |
|
9 | + $target = $var['to']; |
|
10 | +} else { |
|
11 | + $target = trim($_POST['to']); |
|
12 | +} |
|
7 | 13 | |
8 | 14 | // perform some basic checks on both numbers |
9 | -if (empty($start) || empty($target)) |
|
15 | +if (empty($start) || empty($target)) { |
|
10 | 16 | create_error('Where do you want to go today?'); |
17 | +} |
|
11 | 18 | |
12 | 19 | |
13 | -if (!is_numeric($start) || !is_numeric($target)) |
|
20 | +if (!is_numeric($start) || !is_numeric($target)) { |
|
14 | 21 | create_error('Please enter only numbers!'); |
22 | +} |
|
15 | 23 | |
16 | 24 | $start = abs(str_replace('.', '', $start)); |
17 | 25 | $target = abs(str_replace('.', '', $target)); |
18 | 26 | |
19 | -if ($start == $target) |
|
27 | +if ($start == $target) { |
|
20 | 28 | create_error('Hmmmm...if ' . $start . '=' . $target . ' then that means...YOU\'RE ALREADY THERE! *cough*you\'re real smart*cough*'); |
29 | +} |
|
21 | 30 | |
22 | 31 | $startExists = false; |
23 | 32 | $targetExists = false; |
24 | 33 | $galaxies = SmrGalaxy::getGameGalaxies($player->getGameID()); |
25 | 34 | foreach ($galaxies as $galaxy) { |
26 | - if ($galaxy->contains($start)) |
|
27 | - $startExists = true; |
|
28 | - if ($galaxy->contains($target)) |
|
29 | - $targetExists = true; |
|
30 | -} |
|
31 | - |
|
32 | -if ($startExists === false || $targetExists === false) |
|
35 | + if ($galaxy->contains($start)) { |
|
36 | + $startExists = true; |
|
37 | + } |
|
38 | + if ($galaxy->contains($target)) { |
|
39 | + $targetExists = true; |
|
40 | + } |
|
41 | + } |
|
42 | + |
|
43 | +if ($startExists === false || $targetExists === false) { |
|
33 | 44 | create_error('The sectors have to exist!'); |
45 | +} |
|
34 | 46 | |
35 | 47 | $account->log(LOG_TYPE_MOVEMENT, 'Player plots to ' . $target . '.', $player->getSectorID()); |
36 | 48 |
@@ -1,17 +1,21 @@ discard block |
||
1 | 1 | <?php declare(strict_types=1); |
2 | -if (!$player->isLandedOnPlanet()) |
|
2 | +if (!$player->isLandedOnPlanet()) { |
|
3 | 3 | create_error('You are not on a planet!'); |
4 | +} |
|
4 | 5 | $amount = trim($_REQUEST['amount']); |
5 | -if (!is_numeric($amount)) |
|
6 | +if (!is_numeric($amount)) { |
|
6 | 7 | create_error('Numbers only please'); |
8 | +} |
|
7 | 9 | |
8 | 10 | // only whole numbers allowed |
9 | 11 | $amount = round($amount); |
10 | 12 | |
11 | -if ($amount <= 0) |
|
13 | +if ($amount <= 0) { |
|
12 | 14 | create_error('You must actually enter an amount > 0!'); |
13 | -if ($player->getNewbieTurns() > 0) |
|
15 | +} |
|
16 | +if ($player->getNewbieTurns() > 0) { |
|
14 | 17 | create_error('You can\'t drop defenses under newbie protection!'); |
18 | +} |
|
15 | 19 | // get a planet from the sector where the player is in |
16 | 20 | $planet = $player->getSectorPlanet(); |
17 | 21 | |
@@ -21,40 +25,44 @@ discard block |
||
21 | 25 | if ($action == 'Ship') { |
22 | 26 | if ($type_id == HARDWARE_SHIELDS) { |
23 | 27 | // do we want transfer more than we have? |
24 | - if ($amount > $planet->getShields()) |
|
25 | - create_error('You can\'t take more shields from planet than are on it!'); |
|
28 | + if ($amount > $planet->getShields()) { |
|
29 | + create_error('You can\'t take more shields from planet than are on it!'); |
|
30 | + } |
|
26 | 31 | |
27 | 32 | // do we want to transfer more than we can carry? |
28 | - if ($amount > $ship->getMaxShields() - $ship->getShields()) |
|
29 | - create_error('You can\'t take more shields than you can carry!'); |
|
33 | + if ($amount > $ship->getMaxShields() - $ship->getShields()) { |
|
34 | + create_error('You can\'t take more shields than you can carry!'); |
|
35 | + } |
|
30 | 36 | |
31 | 37 | // now transfer |
32 | 38 | $planet->decreaseShields($amount); |
33 | 39 | $ship->increaseShields($amount); |
34 | 40 | $account->log(LOG_TYPE_PLANETS, 'Player takes ' . $amount . ' shields from planet.', $player->getSectorID()); |
35 | - } |
|
36 | - else if ($type_id == HARDWARE_COMBAT) { |
|
41 | + } else if ($type_id == HARDWARE_COMBAT) { |
|
37 | 42 | // do we want transfer more than we have? |
38 | - if ($amount > $planet->getCDs()) |
|
39 | - create_error('You can\'t take more drones from planet than are on it!'); |
|
43 | + if ($amount > $planet->getCDs()) { |
|
44 | + create_error('You can\'t take more drones from planet than are on it!'); |
|
45 | + } |
|
40 | 46 | |
41 | 47 | // do we want to transfer more than we can carry? |
42 | - if ($amount > $ship->getMaxCDs() - $ship->getCDs()) |
|
43 | - create_error('You can\'t take more drones than you can carry!'); |
|
48 | + if ($amount > $ship->getMaxCDs() - $ship->getCDs()) { |
|
49 | + create_error('You can\'t take more drones than you can carry!'); |
|
50 | + } |
|
44 | 51 | |
45 | 52 | // now transfer |
46 | 53 | $planet->decreaseCDs($amount); |
47 | 54 | $ship->increaseCDs($amount); |
48 | 55 | $account->log(LOG_TYPE_PLANETS, 'Player takes ' . $amount . ' drones from planet.', $player->getSectorID()); |
49 | - } |
|
50 | - else if ($type_id == HARDWARE_ARMOUR) { |
|
56 | + } else if ($type_id == HARDWARE_ARMOUR) { |
|
51 | 57 | // do we want transfer more than we have? |
52 | - if ($amount > $planet->getArmour()) |
|
53 | - create_error('You can\'t take more armour from planet than are on it!'); |
|
58 | + if ($amount > $planet->getArmour()) { |
|
59 | + create_error('You can\'t take more armour from planet than are on it!'); |
|
60 | + } |
|
54 | 61 | |
55 | 62 | // do we want to transfer more than we can carry? |
56 | - if ($amount > $ship->getMaxArmour() - $ship->getArmour()) |
|
57 | - create_error('You can\'t take more armour than you can carry!'); |
|
63 | + if ($amount > $ship->getMaxArmour() - $ship->getArmour()) { |
|
64 | + create_error('You can\'t take more armour than you can carry!'); |
|
65 | + } |
|
58 | 66 | |
59 | 67 | // now transfer |
60 | 68 | $planet->decreaseArmour($amount); |
@@ -62,32 +70,34 @@ discard block |
||
62 | 70 | $account->log(LOG_TYPE_PLANETS, 'Player takes ' . $amount . ' armour from planet.', $player->getSectorID()); |
63 | 71 | } |
64 | 72 | |
65 | -} |
|
66 | -elseif ($action == 'Planet') { |
|
73 | +} elseif ($action == 'Planet') { |
|
67 | 74 | // does the user wants to transfer shields? |
68 | 75 | if ($type_id == HARDWARE_SHIELDS) { |
69 | 76 | // do we want transfer more than we have? |
70 | - if ($amount > $ship->getShields()) |
|
71 | - create_error('You can\'t transfer more shields than you carry!'); |
|
77 | + if ($amount > $ship->getShields()) { |
|
78 | + create_error('You can\'t transfer more shields than you carry!'); |
|
79 | + } |
|
72 | 80 | |
73 | 81 | // do we want to transfer more than the planet can hold? |
74 | - if ($amount + $planet->getShields() > $planet->getMaxShields()) |
|
75 | - create_error('The planet can\'t hold more than ' . $planet->getMaxShields() . ' shields!'); |
|
82 | + if ($amount + $planet->getShields() > $planet->getMaxShields()) { |
|
83 | + create_error('The planet can\'t hold more than ' . $planet->getMaxShields() . ' shields!'); |
|
84 | + } |
|
76 | 85 | |
77 | 86 | // now transfer |
78 | 87 | $planet->increaseShields($amount); |
79 | 88 | $ship->decreaseShields($amount); |
80 | 89 | $account->log(LOG_TYPE_PLANETS, 'Player puts ' . $amount . ' shields on planet.', $player->getSectorID()); |
81 | 90 | // does the user wants to transfer drones? |
82 | - } |
|
83 | - else if ($type_id == HARDWARE_COMBAT) { |
|
91 | + } else if ($type_id == HARDWARE_COMBAT) { |
|
84 | 92 | // do we want transfer more than we have? |
85 | - if ($amount > $ship->getCDs()) |
|
86 | - create_error('You can\'t transfer more combat drones than you carry!'); |
|
93 | + if ($amount > $ship->getCDs()) { |
|
94 | + create_error('You can\'t transfer more combat drones than you carry!'); |
|
95 | + } |
|
87 | 96 | |
88 | 97 | // do we want to transfer more than we can carry? |
89 | - if ($amount + $planet->getCDs() > $planet->getMaxCDs()) |
|
90 | - create_error('The planet can\'t hold more than ' . $planet->getMaxCDs() . ' drones!'); |
|
98 | + if ($amount + $planet->getCDs() > $planet->getMaxCDs()) { |
|
99 | + create_error('The planet can\'t hold more than ' . $planet->getMaxCDs() . ' drones!'); |
|
100 | + } |
|
91 | 101 | |
92 | 102 | // now transfer |
93 | 103 | $planet->increaseCDs($amount); |
@@ -97,12 +107,14 @@ discard block |
||
97 | 107 | // does the user wish to transfare armour? |
98 | 108 | else if ($type_id == HARDWARE_ARMOUR) { |
99 | 109 | // do we want transfer more than we have? |
100 | - if ($amount >= $ship->getArmour()) |
|
101 | - create_error('You can\'t transfer more armour than what you carry minus one!'); |
|
110 | + if ($amount >= $ship->getArmour()) { |
|
111 | + create_error('You can\'t transfer more armour than what you carry minus one!'); |
|
112 | + } |
|
102 | 113 | |
103 | 114 | // do we want to transfer more than we can carry? |
104 | - if ($amount + $planet->getArmour() > $planet->getMaxArmour()) |
|
105 | - create_error('The planet can\'t hold more than ' . $planet->getMaxArmour() . ' armour!'); |
|
115 | + if ($amount + $planet->getArmour() > $planet->getMaxArmour()) { |
|
116 | + create_error('The planet can\'t hold more than ' . $planet->getMaxArmour() . ' armour!'); |
|
117 | + } |
|
106 | 118 | |
107 | 119 | // now transfer |
108 | 120 | $planet->increaseArmour($amount); |
@@ -110,9 +122,9 @@ discard block |
||
110 | 122 | $account->log(LOG_TYPE_PLANETS, 'Player puts ' . $amount . ' armour on planet.', $player->getSectorID()); |
111 | 123 | } |
112 | 124 | |
113 | -} |
|
114 | -else |
|
125 | +} else { |
|
115 | 126 | create_error('You must choose if you want to transfer to planet or to the ship!'); |
127 | +} |
|
116 | 128 | |
117 | 129 | $ship->removeUnderAttack(); |
118 | 130 |
@@ -1,14 +1,17 @@ discard block |
||
1 | 1 | <?php declare(strict_types=1); |
2 | -if (!$player->isLandedOnPlanet()) |
|
2 | +if (!$player->isLandedOnPlanet()) { |
|
3 | 3 | create_error('You are not on a planet!'); |
4 | +} |
|
4 | 5 | $amount = $_REQUEST['amount']; |
5 | -if (!is_numeric($amount)) |
|
6 | +if (!is_numeric($amount)) { |
|
6 | 7 | create_error('Numbers only please'); |
8 | +} |
|
7 | 9 | |
8 | 10 | $amount = floor($amount); |
9 | 11 | |
10 | -if ($amount <= 0) |
|
12 | +if ($amount <= 0) { |
|
11 | 13 | create_error('You must actually enter an amount > 0!'); |
14 | +} |
|
12 | 15 | |
13 | 16 | // get a planet from the sector where the player is in |
14 | 17 | $planet = $player->getSectorPlanet(); |
@@ -17,12 +20,14 @@ discard block |
||
17 | 20 | if ($action == 'Ship') { |
18 | 21 | |
19 | 22 | // do we want transfer more than we have? |
20 | - if ($amount > $planet->getStockpile($var['good_id'])) |
|
21 | - create_error('You can\'t take more than on planet!'); |
|
23 | + if ($amount > $planet->getStockpile($var['good_id'])) { |
|
24 | + create_error('You can\'t take more than on planet!'); |
|
25 | + } |
|
22 | 26 | |
23 | 27 | // do we want to transfer more than we can carry? |
24 | - if ($amount > $ship->getEmptyHolds()) |
|
25 | - create_error('You can\'t take more than you can carry!'); |
|
28 | + if ($amount > $ship->getEmptyHolds()) { |
|
29 | + create_error('You can\'t take more than you can carry!'); |
|
30 | + } |
|
26 | 31 | |
27 | 32 | // now transfer |
28 | 33 | $planet->decreaseStockpile($var['good_id'], $amount); |
@@ -30,15 +35,16 @@ discard block |
||
30 | 35 | $account->log(LOG_TYPE_PLANETS, 'Player takes ' . $amount . ' ' . Globals::getGoodName($var['good_id']) . ' from planet.', $player->getSectorID()); |
31 | 36 | |
32 | 37 | // transfer to planet |
33 | -} |
|
34 | -elseif ($action == 'Planet') { |
|
38 | +} elseif ($action == 'Planet') { |
|
35 | 39 | // do we want transfer more than we have? |
36 | - if ($amount > $ship->getCargo($var['good_id'])) |
|
37 | - create_error('You can\'t store more than you carry!'); |
|
40 | + if ($amount > $ship->getCargo($var['good_id'])) { |
|
41 | + create_error('You can\'t store more than you carry!'); |
|
42 | + } |
|
38 | 43 | |
39 | 44 | // do we want to transfer more than the planet can hold? |
40 | - if ($amount > $planet->getRemainingStockpile($var['good_id'])) |
|
41 | - create_error('This planet cannot store more than ' . SmrPlanet::MAX_STOCKPILE . ' of each good!'); |
|
45 | + if ($amount > $planet->getRemainingStockpile($var['good_id'])) { |
|
46 | + create_error('This planet cannot store more than ' . SmrPlanet::MAX_STOCKPILE . ' of each good!'); |
|
47 | + } |
|
42 | 48 | |
43 | 49 | // now transfer |
44 | 50 | $planet->increaseStockpile($var['good_id'], $amount); |
@@ -1,33 +1,37 @@ |
||
1 | 1 | <?php declare(strict_types=1); |
2 | -if (!$player->isLandedOnPlanet()) |
|
2 | +if (!$player->isLandedOnPlanet()) { |
|
3 | 3 | create_error('You are not on a planet!'); |
4 | +} |
|
4 | 5 | $planet = $player->getSectorPlanet(); |
5 | 6 | $action = $_REQUEST['action']; |
6 | 7 | |
7 | 8 | // Player has requested a planetary fund transaction |
8 | 9 | if ($action == 'Deposit' || $action == 'Withdraw') { |
9 | 10 | $amount = $_REQUEST['amount']; |
10 | - if (!is_numeric($amount)) |
|
11 | - create_error('Numbers only please!'); |
|
11 | + if (!is_numeric($amount)) { |
|
12 | + create_error('Numbers only please!'); |
|
13 | + } |
|
12 | 14 | |
13 | 15 | // only whole numbers allowed |
14 | 16 | $amount = floor($amount); |
15 | 17 | |
16 | 18 | // no negative amounts are allowed |
17 | - if ($amount <= 0) |
|
18 | - create_error('You must actually enter an amount > 0!'); |
|
19 | + if ($amount <= 0) { |
|
20 | + create_error('You must actually enter an amount > 0!'); |
|
21 | + } |
|
19 | 22 | |
20 | 23 | if ($action == 'Deposit') { |
21 | - if ($player->getCredits() < $amount) |
|
22 | - create_error('You don\'t own that much money!'); |
|
24 | + if ($player->getCredits() < $amount) { |
|
25 | + create_error('You don\'t own that much money!'); |
|
26 | + } |
|
23 | 27 | |
24 | 28 | $player->decreaseCredits($amount); |
25 | 29 | $planet->increaseCredits($amount); |
26 | 30 | $account->log(LOG_TYPE_BANK, 'Player puts ' . $amount . ' credits on planet', $player->getSectorID()); |
27 | - } |
|
28 | - elseif ($action == 'Withdraw') { |
|
29 | - if ($planet->getCredits() < $amount) |
|
30 | - create_error('There are not enough credits in the planetary account!'); |
|
31 | + } elseif ($action == 'Withdraw') { |
|
32 | + if ($planet->getCredits() < $amount) { |
|
33 | + create_error('There are not enough credits in the planetary account!'); |
|
34 | + } |
|
31 | 35 | |
32 | 36 | $player->increaseCredits($amount); |
33 | 37 | $planet->decreaseCredits($amount); |
@@ -1,14 +1,16 @@ discard block |
||
1 | 1 | <?php declare(strict_types=1); |
2 | -if (!$player->isLandedOnPlanet()) |
|
2 | +if (!$player->isLandedOnPlanet()) { |
|
3 | 3 | create_error('You are not on a planet!'); |
4 | +} |
|
4 | 5 | // get a planet from the sector where the player is in |
5 | 6 | $planet = $player->getSectorPlanet(); |
6 | 7 | $action = $_REQUEST['action']; |
7 | 8 | $password = isset($_REQUEST['password']) ? $_REQUEST['password'] : ''; |
8 | 9 | |
9 | 10 | if ($action == 'Take Ownership') { |
10 | - if ($planet->hasOwner() && $planet->getPassword() != $password) |
|
11 | - create_error('You are not allowed to take ownership!'); |
|
11 | + if ($planet->hasOwner() && $planet->getPassword() != $password) { |
|
12 | + create_error('You are not allowed to take ownership!'); |
|
13 | + } |
|
12 | 14 | |
13 | 15 | // delete all previous ownerships |
14 | 16 | $db->query('UPDATE planet SET owner_id = 0, password = NULL |
@@ -20,8 +22,7 @@ discard block |
||
20 | 22 | $planet->removePassword(); |
21 | 23 | $planet->update(); |
22 | 24 | $account->log(LOG_TYPE_PLANETS, 'Player takes ownership of planet.', $player->getSectorID()); |
23 | -} |
|
24 | -else if ($action == 'Rename') { |
|
25 | +} else if ($action == 'Rename') { |
|
25 | 26 | $name = trim($_REQUEST['name']); |
26 | 27 | if (empty($name)) { |
27 | 28 | create_error('You cannot leave your planet nameless!'); |
@@ -31,8 +32,7 @@ discard block |
||
31 | 32 | $planet->update(); |
32 | 33 | $account->log(LOG_TYPE_PLANETS, 'Player renames planet to ' . $name . '.', $player->getSectorID()); |
33 | 34 | |
34 | -} |
|
35 | -else if ($action == 'Set Password') { |
|
35 | +} else if ($action == 'Set Password') { |
|
36 | 36 | // set password |
37 | 37 | $planet->setPassword($password); |
38 | 38 | $planet->update(); |
@@ -1,17 +1,21 @@ discard block |
||
1 | 1 | <?php declare(strict_types=1); |
2 | 2 | |
3 | 3 | function checkPortTradeable($port, $player) { |
4 | - if ($port->getSectorID() != $player->getSectorID()) |
|
5 | - return 'That port is not in this sector!'; |
|
4 | + if ($port->getSectorID() != $player->getSectorID()) { |
|
5 | + return 'That port is not in this sector!'; |
|
6 | + } |
|
6 | 7 | |
7 | - if (!$port->exists()) |
|
8 | - return 'There is no port in this sector!'; |
|
8 | + if (!$port->exists()) { |
|
9 | + return 'There is no port in this sector!'; |
|
10 | + } |
|
9 | 11 | |
10 | - if ($player->getRelation($port->getRaceID()) <= RELATIONS_WAR) |
|
11 | - return 'We will not trade with our enemies!'; |
|
12 | + if ($player->getRelation($port->getRaceID()) <= RELATIONS_WAR) { |
|
13 | + return 'We will not trade with our enemies!'; |
|
14 | + } |
|
12 | 15 | |
13 | - if ($port->getReinforceTime() > TIME) |
|
14 | - return 'We are still repairing damage caused during the last raid.'; |
|
16 | + if ($port->getReinforceTime() > TIME) { |
|
17 | + return 'We are still repairing damage caused during the last raid.'; |
|
18 | + } |
|
15 | 19 | |
16 | 20 | return true; |
17 | 21 | } |
@@ -50,39 +54,43 @@ discard block |
||
50 | 54 | if (abs($port_off_rel) > abs($trader_off_rel)) { |
51 | 55 | // get a random number between |
52 | 56 | // (port_off) and (100 +/- $trader_off_rel) |
53 | - if (100 + $trader_off_rel < $port_off) |
|
54 | - $offer_modifier = mt_rand(100 + $trader_off_rel, $port_off); |
|
55 | - else |
|
56 | - $offer_modifier = mt_rand($port_off, 100 + $trader_off_rel); |
|
57 | + if (100 + $trader_off_rel < $port_off) { |
|
58 | + $offer_modifier = mt_rand(100 + $trader_off_rel, $port_off); |
|
59 | + } else { |
|
60 | + $offer_modifier = mt_rand($port_off, 100 + $trader_off_rel); |
|
61 | + } |
|
57 | 62 | |
58 | 63 | $container['offered_price'] = round($container['ideal_price'] * $offer_modifier / 100); |
59 | 64 | } |
65 | + } else { |
|
66 | + $container['overall_number_of_bargains'] = mt_rand(2, 5); |
|
67 | + } |
|
60 | 68 | } |
61 | - else |
|
62 | - $container['overall_number_of_bargains'] = mt_rand(2, 5); |
|
63 | -} |
|
64 | 69 | |
65 | 70 | function get_amount() { |
66 | 71 | global $var; |
67 | 72 | |
68 | 73 | // retrieve amount |
69 | - if (isset($var['amount'])) |
|
70 | - $amount = $var['amount']; |
|
71 | - else if (isset($_REQUEST['amount'])) |
|
72 | - $amount = $_REQUEST['amount']; |
|
73 | - else |
|
74 | - $amount = 0; |
|
74 | + if (isset($var['amount'])) { |
|
75 | + $amount = $var['amount']; |
|
76 | + } else if (isset($_REQUEST['amount'])) { |
|
77 | + $amount = $_REQUEST['amount']; |
|
78 | + } else { |
|
79 | + $amount = 0; |
|
80 | + } |
|
75 | 81 | |
76 | 82 | // only numbers |
77 | - if (!is_numeric($amount)) |
|
78 | - create_error('You must actually enter a number!'); |
|
83 | + if (!is_numeric($amount)) { |
|
84 | + create_error('You must actually enter a number!'); |
|
85 | + } |
|
79 | 86 | |
80 | 87 | // we take as it is but round it |
81 | 88 | $amount = floor($amount); |
82 | 89 | |
83 | 90 | // no negative amounts are allowed |
84 | - if ($amount <= 0) |
|
85 | - create_error('You must actually enter an amount > 0!'); |
|
91 | + if ($amount <= 0) { |
|
92 | + create_error('You must actually enter an amount > 0!'); |
|
93 | + } |
|
86 | 94 | |
87 | 95 | return $amount; |
88 | 96 | } |
@@ -91,23 +99,26 @@ discard block |
||
91 | 99 | global $var; |
92 | 100 | |
93 | 101 | // we get it from form |
94 | - if (isset($_REQUEST['bargain_price'])) |
|
95 | - $price = $_REQUEST['bargain_price']; |
|
96 | - else if (isset($var['bargain_price'])) |
|
97 | - $price = $var['bargain_price']; |
|
98 | - else |
|
99 | - $price = 0; |
|
102 | + if (isset($_REQUEST['bargain_price'])) { |
|
103 | + $price = $_REQUEST['bargain_price']; |
|
104 | + } else if (isset($var['bargain_price'])) { |
|
105 | + $price = $var['bargain_price']; |
|
106 | + } else { |
|
107 | + $price = 0; |
|
108 | + } |
|
100 | 109 | |
101 | 110 | // only numbers |
102 | - if (!is_numeric($price)) |
|
103 | - create_error('You must actually enter a number!'); |
|
111 | + if (!is_numeric($price)) { |
|
112 | + create_error('You must actually enter a number!'); |
|
113 | + } |
|
104 | 114 | |
105 | 115 | // we take as it is but round it |
106 | 116 | $price = floor($price); |
107 | 117 | |
108 | 118 | // no negative amounts are allowed |
109 | - if ($price < 0) |
|
110 | - create_error('No negative prices are allowed!'); |
|
119 | + if ($price < 0) { |
|
120 | + create_error('No negative prices are allowed!'); |
|
121 | + } |
|
111 | 122 | |
112 | 123 | return $price; |
113 | 124 | } |