We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -1,34 +1,34 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(isset($ForcesCombatResults['Results']) && is_array($ForcesCombatResults['Results'])) { |
|
| 3 | - foreach($ForcesCombatResults['Results'] as $ForceType => $ForceResults) { |
|
| 4 | - $ShootingWeapon =& $ForceResults['Weapon']; |
|
| 5 | - $ShotHit =& $ForceResults['Hit']; |
|
| 6 | - $ActualDamage =& $ForceResults['ActualDamage']; |
|
| 7 | - $WeaponDamage =& $ForceResults['WeaponDamage']; |
|
| 8 | - $TargetPlayer =& $ForceResults['TargetPlayer']; |
|
| 2 | +if (isset($ForcesCombatResults['Results']) && is_array($ForcesCombatResults['Results'])) { |
|
| 3 | + foreach ($ForcesCombatResults['Results'] as $ForceType => $ForceResults) { |
|
| 4 | + $ShootingWeapon = & $ForceResults['Weapon']; |
|
| 5 | + $ShotHit = & $ForceResults['Hit']; |
|
| 6 | + $ActualDamage = & $ForceResults['ActualDamage']; |
|
| 7 | + $WeaponDamage = & $ForceResults['WeaponDamage']; |
|
| 8 | + $TargetPlayer = & $ForceResults['TargetPlayer']; |
|
| 9 | 9 | ?> |
| 10 | 10 | <span class="cds"><?php echo isset($ActualDamage['Launched']) ? $ActualDamage['Launched'] : $WeaponDamage['Launched']; ?></span><?php |
| 11 | - if($ForceType == 'Mines') { |
|
| 11 | + if ($ForceType == 'Mines') { |
|
| 12 | 12 | ?> mines kamikaze themselves against <?php |
| 13 | - } else if($ForceType == 'Drones') { |
|
| 13 | + } else if ($ForceType == 'Drones') { |
|
| 14 | 14 | ?> combat drones launch at <?php |
| 15 | - } else if($ForceType == 'Scouts') { |
|
| 15 | + } else if ($ForceType == 'Scouts') { |
|
| 16 | 16 | ?> scout drones kamikaze themselves against <?php |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - if($ShotHit && $ActualDamage['TargetAlreadyDead']){ ?> the debris that was once <?php } |
|
| 19 | + if ($ShotHit && $ActualDamage['TargetAlreadyDead']) { ?> the debris that was once <?php } |
|
| 20 | 20 | echo $TargetPlayer->getDisplayName(); |
| 21 | 21 | if (!$ShotHit || !$ActualDamage['TargetAlreadyDead']) { |
| 22 | - if(!$ShotHit) { |
|
| 22 | + if (!$ShotHit) { |
|
| 23 | 23 | ?> and misses<?php |
| 24 | - } else if($ActualDamage['TotalDamage'] == 0) { |
|
| 25 | - if($WeaponDamage['Shield'] > 0) { |
|
| 26 | - if($ActualDamage['HasCDs']) { |
|
| 24 | + } else if ($ActualDamage['TotalDamage'] == 0) { |
|
| 25 | + if ($WeaponDamage['Shield'] > 0) { |
|
| 26 | + if ($ActualDamage['HasCDs']) { |
|
| 27 | 27 | ?> which proves ineffective against their combat drones<?php |
| 28 | 28 | } else { |
| 29 | 29 | ?> which washes harmlessly over their hull<?php |
| 30 | 30 | } |
| 31 | - } else if($WeaponDamage['Armour'] > 0) { |
|
| 31 | + } else if ($WeaponDamage['Armour'] > 0) { |
|
| 32 | 32 | ?> which is deflected by their shields<?php |
| 33 | 33 | } else { |
| 34 | 34 | ?> but it cannot do any damage<?php |
@@ -37,31 +37,31 @@ discard block |
||
| 37 | 37 | ?> destroying <?php |
| 38 | 38 | } |
| 39 | 39 | $DamageTypes = 0; |
| 40 | - if($ActualDamage['Shield'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
| 41 | - if($ActualDamage['NumCDs'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
| 42 | - if($ActualDamage['Armour'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
| 40 | + if ($ActualDamage['Shield'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
| 41 | + if ($ActualDamage['NumCDs'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
| 42 | + if ($ActualDamage['Armour'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
| 43 | 43 | |
| 44 | - if($ActualDamage['Shield'] > 0) { |
|
| 44 | + if ($ActualDamage['Shield'] > 0) { |
|
| 45 | 45 | ?><span class="shields"><?php echo number_format($ActualDamage['Shield']) ?></span> shields<?php |
| 46 | 46 | $this->doDamageTypeReductionDisplay($DamageTypes); |
| 47 | 47 | } |
| 48 | - if($ActualDamage['NumCDs'] > 0) { |
|
| 48 | + if ($ActualDamage['NumCDs'] > 0) { |
|
| 49 | 49 | ?><span class="cds"><?php echo number_format($ActualDamage['NumCDs']) ?></span> drones<?php |
| 50 | 50 | $this->doDamageTypeReductionDisplay($DamageTypes); |
| 51 | 51 | } |
| 52 | - if($ActualDamage['Armour'] > 0) { |
|
| 52 | + if ($ActualDamage['Armour'] > 0) { |
|
| 53 | 53 | ?><span class="red"><?php echo number_format($ActualDamage['Armour']) ?></span> plates of armour<?php |
| 54 | 54 | } |
| 55 | 55 | } ?>. |
| 56 | 56 | <br /><?php |
| 57 | 57 | if ($ShotHit && $ActualDamage['KillingShot']) { |
| 58 | - $this->includeTemplate('includes/TraderCombatKillMessage.inc',array('KillResults'=>$ForceResults['KillResults'],'TargetPlayer'=>$TargetPlayer)); |
|
| 58 | + $this->includeTemplate('includes/TraderCombatKillMessage.inc', array('KillResults'=>$ForceResults['KillResults'], 'TargetPlayer'=>$TargetPlayer)); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | -if(isset($ForcesCombatResults['ForcesDestroyed']) && $ForcesCombatResults['ForcesDestroyed']) { |
|
| 62 | +if (isset($ForcesCombatResults['ForcesDestroyed']) && $ForcesCombatResults['ForcesDestroyed']) { |
|
| 63 | 63 | ?>Forces are <span class="red">DESTROYED!</span><br /><?php |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | -$TotalDamage =& $ForcesCombatResults['TotalDamage'] ?> |
|
| 67 | -The forces <?php if($TotalDamage > 0){ ?>hit for a total of <span class="red"><?php echo number_format($TotalDamage) ?></span> damage in this round of combat<?php } else{ ?>do no damage this round<?php } ?>. |
|
| 66 | +$TotalDamage = & $ForcesCombatResults['TotalDamage'] ?> |
|
| 67 | +The forces <?php if ($TotalDamage > 0) { ?>hit for a total of <span class="red"><?php echo number_format($TotalDamage) ?></span> damage in this round of combat<?php } else { ?>do no damage this round<?php } ?>. |
|
@@ -1,36 +1,36 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(is_array($TraderTeamCombatResults['Traders'])) { |
|
| 3 | - foreach($TraderTeamCombatResults['Traders'] as $AccountID => $TraderResults) { |
|
| 4 | - $ShootingPlayer =& $TraderResults['Player']; |
|
| 5 | - $TotalDamage =& $TraderResults['TotalDamage']; |
|
| 2 | +if (is_array($TraderTeamCombatResults['Traders'])) { |
|
| 3 | + foreach ($TraderTeamCombatResults['Traders'] as $AccountID => $TraderResults) { |
|
| 4 | + $ShootingPlayer = & $TraderResults['Player']; |
|
| 5 | + $TotalDamage = & $TraderResults['TotalDamage']; |
|
| 6 | 6 | |
| 7 | - if($TraderResults['DeadBeforeShot']) { |
|
| 7 | + if ($TraderResults['DeadBeforeShot']) { |
|
| 8 | 8 | echo $ShootingPlayer->getDisplayName() ?> died before they were able to attack!<br /><?php |
| 9 | 9 | } else { |
| 10 | - if(isset($TraderResults['Weapons']) && is_array($TraderResults['Weapons'])) { |
|
| 11 | - foreach($TraderResults['Weapons'] as $WeaponResults) { |
|
| 12 | - $ShootingWeapon =& $WeaponResults['Weapon']; |
|
| 13 | - $ShotHit =& $WeaponResults['Hit']; |
|
| 14 | - $ActualDamage =& $WeaponResults['ActualDamage']; |
|
| 15 | - $WeaponDamage =& $WeaponResults['WeaponDamage']; |
|
| 16 | - $TargetPlayer =& $WeaponResults['TargetPlayer']; |
|
| 10 | + if (isset($TraderResults['Weapons']) && is_array($TraderResults['Weapons'])) { |
|
| 11 | + foreach ($TraderResults['Weapons'] as $WeaponResults) { |
|
| 12 | + $ShootingWeapon = & $WeaponResults['Weapon']; |
|
| 13 | + $ShotHit = & $WeaponResults['Hit']; |
|
| 14 | + $ActualDamage = & $WeaponResults['ActualDamage']; |
|
| 15 | + $WeaponDamage = & $WeaponResults['WeaponDamage']; |
|
| 16 | + $TargetPlayer = & $WeaponResults['TargetPlayer']; |
|
| 17 | 17 | |
| 18 | 18 | echo $ShootingPlayer->getDisplayName() ?> fires their <?php echo $ShootingWeapon->getName() ?> at <?php |
| 19 | - if($ShotHit && $ActualDamage['TargetAlreadyDead']) { |
|
| 19 | + if ($ShotHit && $ActualDamage['TargetAlreadyDead']) { |
|
| 20 | 20 | ?>the debris that was once <?php |
| 21 | 21 | } |
| 22 | 22 | echo $TargetPlayer->getDisplayName(); |
| 23 | 23 | if (!$ShotHit || !$ActualDamage['TargetAlreadyDead']) { |
| 24 | - if(!$ShotHit) { |
|
| 24 | + if (!$ShotHit) { |
|
| 25 | 25 | ?> and misses<?php |
| 26 | - } else if($ActualDamage['TotalDamage'] == 0) { |
|
| 27 | - if($WeaponDamage['Shield'] > 0) { |
|
| 28 | - if($ActualDamage['HasCDs']) { |
|
| 26 | + } else if ($ActualDamage['TotalDamage'] == 0) { |
|
| 27 | + if ($WeaponDamage['Shield'] > 0) { |
|
| 28 | + if ($ActualDamage['HasCDs']) { |
|
| 29 | 29 | ?> which proves ineffective against their combat drones<?php |
| 30 | 30 | } else { |
| 31 | 31 | ?> which washes harmlessly over their hull<?php |
| 32 | 32 | } |
| 33 | - } else if($WeaponDamage['Armour'] > 0) { |
|
| 33 | + } else if ($WeaponDamage['Armour'] > 0) { |
|
| 34 | 34 | ?> which is deflected by their shields<?php |
| 35 | 35 | } else { |
| 36 | 36 | ?> but it cannot do any damage<?php |
@@ -38,94 +38,94 @@ discard block |
||
| 38 | 38 | } else { |
| 39 | 39 | ?> destroying <?php |
| 40 | 40 | $DamageTypes = 0; |
| 41 | - if($ActualDamage['Shield'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
| 42 | - if($ActualDamage['NumCDs'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
| 43 | - if($ActualDamage['Armour'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
| 41 | + if ($ActualDamage['Shield'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
| 42 | + if ($ActualDamage['NumCDs'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
| 43 | + if ($ActualDamage['Armour'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
| 44 | 44 | |
| 45 | - if($ActualDamage['Shield'] > 0) { |
|
| 45 | + if ($ActualDamage['Shield'] > 0) { |
|
| 46 | 46 | ?><span class="shields"><?php echo number_format($ActualDamage['Shield']) ?></span> shields<?php |
| 47 | 47 | $this->doDamageTypeReductionDisplay($DamageTypes); |
| 48 | 48 | } |
| 49 | - if($ActualDamage['NumCDs'] > 0) { |
|
| 49 | + if ($ActualDamage['NumCDs'] > 0) { |
|
| 50 | 50 | ?><span class="cds"><?php echo number_format($ActualDamage['NumCDs']) ?></span> combat drones<?php |
| 51 | 51 | $this->doDamageTypeReductionDisplay($DamageTypes); |
| 52 | 52 | } |
| 53 | - if($ActualDamage['Armour'] > 0) { |
|
| 53 | + if ($ActualDamage['Armour'] > 0) { |
|
| 54 | 54 | ?><span class="red"><?php echo number_format($ActualDamage['Armour']) ?></span> plates of armour<?php |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | } ?>. |
| 58 | 58 | <br /><?php |
| 59 | 59 | if ($ShotHit && $ActualDamage['KillingShot']) { |
| 60 | - $this->includeTemplate('includes/TraderCombatKillMessage.inc',array('KillResults'=>$WeaponResults['KillResults'],'TargetPlayer'=>$TargetPlayer,'ShootingPlayer'=>$ShootingPlayer)); |
|
| 60 | + $this->includeTemplate('includes/TraderCombatKillMessage.inc', array('KillResults'=>$WeaponResults['KillResults'], 'TargetPlayer'=>$TargetPlayer, 'ShootingPlayer'=>$ShootingPlayer)); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | - if(isset($TraderResults['Drones'])) { |
|
| 65 | - $Drones =& $TraderResults['Drones']; |
|
| 66 | - $ActualDamage =& $Drones['ActualDamage']; |
|
| 67 | - $WeaponDamage =& $Drones['WeaponDamage']; |
|
| 68 | - $TargetPlayer =& $Drones['TargetPlayer']; |
|
| 64 | + if (isset($TraderResults['Drones'])) { |
|
| 65 | + $Drones = & $TraderResults['Drones']; |
|
| 66 | + $ActualDamage = & $Drones['ActualDamage']; |
|
| 67 | + $WeaponDamage = & $Drones['WeaponDamage']; |
|
| 68 | + $TargetPlayer = & $Drones['TargetPlayer']; |
|
| 69 | 69 | $DamageTypes = 0; |
| 70 | - if($ActualDamage['Shield'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
| 71 | - if($ActualDamage['NumCDs'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
| 72 | - if($ActualDamage['Armour'] > 0){ $DamageTypes = $DamageTypes+1; } |
|
| 70 | + if ($ActualDamage['Shield'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
| 71 | + if ($ActualDamage['NumCDs'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
| 72 | + if ($ActualDamage['Armour'] > 0) { $DamageTypes = $DamageTypes + 1; } |
|
| 73 | 73 | |
| 74 | 74 | echo $ShootingPlayer->getDisplayName(); |
| 75 | - if($WeaponDamage['Launched'] == 0) { |
|
| 75 | + if ($WeaponDamage['Launched'] == 0) { |
|
| 76 | 76 | ?> fails to launch their combat drones<?php |
| 77 | 77 | } else { |
| 78 | 78 | ?> launches <span class="cds"><?php echo $WeaponDamage['Launched'] ?></span> combat drones at <?php |
| 79 | - if($ActualDamage['TargetAlreadyDead']) { |
|
| 79 | + if ($ActualDamage['TargetAlreadyDead']) { |
|
| 80 | 80 | ?>the debris that was once <?php |
| 81 | 81 | } |
| 82 | 82 | echo $TargetPlayer->getDisplayName(); |
| 83 | - if(!$ActualDamage['TargetAlreadyDead']) { |
|
| 84 | - if($ActualDamage['TotalDamage'] == 0) { |
|
| 85 | - if($WeaponDamage['Shield'] > 0) { |
|
| 86 | - if($ActualDamage['HasCDs']) { |
|
| 83 | + if (!$ActualDamage['TargetAlreadyDead']) { |
|
| 84 | + if ($ActualDamage['TotalDamage'] == 0) { |
|
| 85 | + if ($WeaponDamage['Shield'] > 0) { |
|
| 86 | + if ($ActualDamage['HasCDs']) { |
|
| 87 | 87 | ?> which prove ineffective against their combat drones<?php |
| 88 | 88 | } else { |
| 89 | 89 | ?> which washes harmlessly over their hull<?php |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | - if($ActualDamage['Armour'] > 0) { |
|
| 92 | + if ($ActualDamage['Armour'] > 0) { |
|
| 93 | 93 | ?> which is deflected by their shields<?php |
| 94 | 94 | } else { |
| 95 | 95 | ?> but they cannot do any damage<?php |
| 96 | 96 | } |
| 97 | 97 | } else { |
| 98 | 98 | ?> destroying <?php |
| 99 | - if($ActualDamage['Shield'] > 0) { |
|
| 99 | + if ($ActualDamage['Shield'] > 0) { |
|
| 100 | 100 | ?><span class="shields"><?php echo number_format($ActualDamage['Shield']) ?></span> shields<?php |
| 101 | 101 | $this->doDamageTypeReductionDisplay($DamageTypes); |
| 102 | 102 | } |
| 103 | - if($ActualDamage['NumCDs'] > 0) { |
|
| 103 | + if ($ActualDamage['NumCDs'] > 0) { |
|
| 104 | 104 | ?><span class="cds"><?php echo number_format($ActualDamage['NumCDs']) ?></span> combat drones<?php |
| 105 | 105 | $this->doDamageTypeReductionDisplay($DamageTypes); |
| 106 | 106 | } |
| 107 | - if($ActualDamage['Armour'] > 0) { |
|
| 107 | + if ($ActualDamage['Armour'] > 0) { |
|
| 108 | 108 | ?><span class="red"><?php echo number_format($ActualDamage['Armour']) ?></span> plates of armour<?php |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } ?>. |
| 113 | 113 | <br /><?php |
| 114 | - if($ActualDamage['KillingShot']) { |
|
| 115 | - $this->includeTemplate('includes/TraderCombatKillMessage.inc',array('KillResults'=>$Drones['KillResults'],'TargetPlayer'=>$TargetPlayer,'ShootingPlayer'=>$ShootingPlayer)); |
|
| 114 | + if ($ActualDamage['KillingShot']) { |
|
| 115 | + $this->includeTemplate('includes/TraderCombatKillMessage.inc', array('KillResults'=>$Drones['KillResults'], 'TargetPlayer'=>$TargetPlayer, 'ShootingPlayer'=>$ShootingPlayer)); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | echo $ShootingPlayer->getDisplayName(); |
| 120 | - if($TotalDamage > 0) { |
|
| 120 | + if ($TotalDamage > 0) { |
|
| 121 | 121 | ?> hits for a total of <span class="red"><?php echo $TotalDamage ?></span> damage in this round of combat<?php |
| 122 | 122 | } else { |
| 123 | 123 | ?> does no damage this round.<?php |
| 124 | - if(!$TraderResults['DeadBeforeShot']) { |
|
| 124 | + if (!$TraderResults['DeadBeforeShot']) { |
|
| 125 | 125 | ?> Maybe they should go back to the academy<?php |
| 126 | 126 | } |
| 127 | 127 | } ?>.<br /><br /><?php |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | $TotalDamage = $TraderTeamCombatResults['TotalDamage']; ?> |
| 131 | -This fleet <?php if($TotalDamage > 0){ ?>hits for a total of <span class="red"><?php echo $TotalDamage ?></span> damage in this round of combat<?php } else{ ?>does no damage this round. You call that a fleet? They need a better recruiter<?php } ?>.<br /> |
|
| 131 | +This fleet <?php if ($TotalDamage > 0) { ?>hits for a total of <span class="red"><?php echo $TotalDamage ?></span> damage in this round of combat<?php } else { ?>does no damage this round. You call that a fleet? They need a better recruiter<?php } ?>.<br /> |
|
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | |
| 47 | 47 | // Don't lose more exp than you have |
| 48 | 48 | $lost_xp = min($player->getExperience(), |
| 49 | - IRound(SmrPort::getBaseExperience($amount, $good_distance))); |
|
| 49 | + IRound(SmrPort::getBaseExperience($amount, $good_distance))); |
|
| 50 | 50 | $player->decreaseExperience($lost_xp); |
| 51 | 51 | $player->increaseHOF($lost_xp, array('Trade', 'Experience', 'Jettisoned'), HOF_PUBLIC); |
| 52 | 52 | |
@@ -1,8 +1,9 @@ discard block |
||
| 1 | 1 | <?php declare(strict_types=1); |
| 2 | 2 | $action = $_REQUEST['action']; |
| 3 | 3 | $amount = $_REQUEST['amount']; |
| 4 | -if (!is_numeric($amount)) |
|
| 4 | +if (!is_numeric($amount)) { |
|
| 5 | 5 | create_error('Numbers only please'); |
| 6 | +} |
|
| 6 | 7 | |
| 7 | 8 | // only whole numbers allowed |
| 8 | 9 | $amount = floor($amount); |
@@ -12,8 +13,9 @@ discard block |
||
| 12 | 13 | $cost = Globals::getHardwareCost($hardware_id); |
| 13 | 14 | |
| 14 | 15 | // no negative amounts are allowed |
| 15 | -if ($amount <= 0) |
|
| 16 | +if ($amount <= 0) { |
|
| 16 | 17 | create_error('You must actually enter an amount greater than zero!'); |
| 18 | +} |
|
| 17 | 19 | |
| 18 | 20 | if ($action == 'Buy') { |
| 19 | 21 | // do we have enough cash? |
@@ -30,11 +32,16 @@ discard block |
||
| 30 | 32 | $ship->increaseHardware($hardware_id, $amount); |
| 31 | 33 | |
| 32 | 34 | //HoF |
| 33 | - if ($hardware_id == HARDWARE_COMBAT) $player->increaseHOF($amount, array('Forces', 'Bought', 'Combat Drones'), HOF_ALLIANCE); |
|
| 34 | - if ($hardware_id == HARDWARE_SCOUT) $player->increaseHOF($amount, array('Forces', 'Bought', 'Scout Drones'), HOF_ALLIANCE); |
|
| 35 | - if ($hardware_id == HARDWARE_MINE) $player->increaseHOF($amount, array('Forces', 'Bought', 'Mines'), HOF_ALLIANCE); |
|
| 36 | -} |
|
| 37 | -else if ($action == 'Sell') { |
|
| 35 | + if ($hardware_id == HARDWARE_COMBAT) { |
|
| 36 | + $player->increaseHOF($amount, array('Forces', 'Bought', 'Combat Drones'), HOF_ALLIANCE); |
|
| 37 | + } |
|
| 38 | + if ($hardware_id == HARDWARE_SCOUT) { |
|
| 39 | + $player->increaseHOF($amount, array('Forces', 'Bought', 'Scout Drones'), HOF_ALLIANCE); |
|
| 40 | + } |
|
| 41 | + if ($hardware_id == HARDWARE_MINE) { |
|
| 42 | + $player->increaseHOF($amount, array('Forces', 'Bought', 'Mines'), HOF_ALLIANCE); |
|
| 43 | + } |
|
| 44 | + } else if ($action == 'Sell') { |
|
| 38 | 45 | // We only allow selling combat drones |
| 39 | 46 | if ($hardware_id != HARDWARE_COMBAT) { |
| 40 | 47 | throw new Exception('This item cannot be sold!'); |
@@ -47,8 +54,7 @@ discard block |
||
| 47 | 54 | |
| 48 | 55 | $player->increaseCredits(IRound($cost * CDS_REFUND_PERCENT) * $amount); |
| 49 | 56 | $ship->decreaseCDs($amount, true); // 2nd arg avoids under attack warning |
| 50 | -} |
|
| 51 | -else { |
|
| 57 | +} else { |
|
| 52 | 58 | throw new Exception('Action must be either Buy or Sell.'); |
| 53 | 59 | } |
| 54 | 60 | |
@@ -192,21 +192,21 @@ discard block |
||
| 192 | 192 | public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) { |
| 193 | 193 | if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
| 194 | 194 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 195 | - $damage =& $this->getModifiedDamage(); |
|
| 195 | + $damage = & $this->getModifiedDamage(); |
|
| 196 | 196 | return $damage; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) { |
| 200 | 200 | if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
| 201 | 201 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 202 | - $damage =& $this->getModifiedDamage(); |
|
| 202 | + $damage = & $this->getModifiedDamage(); |
|
| 203 | 203 | return $damage; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) { |
| 207 | 207 | if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
| 208 | 208 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 209 | - $damage =& $this->getModifiedDamage(); |
|
| 209 | + $damage = & $this->getModifiedDamage(); |
|
| 210 | 210 | |
| 211 | 211 | $planetMod = self::PLANET_DAMAGE_MOD; |
| 212 | 212 | $damage['MaxDamage'] = ICeil($damage['MaxDamage'] * $planetMod); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 227 | 227 | return $return; |
| 228 | 228 | } |
| 229 | - $damage =& $this->getModifiedDamage(); |
|
| 229 | + $damage = & $this->getModifiedDamage(); |
|
| 230 | 230 | return $damage; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -12,17 +12,19 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | protected static function initialiseDatabase() { |
| 15 | - if (self::$db == null) |
|
| 16 | - self::$db = new SmrMySqlDatabase(); |
|
| 15 | + if (self::$db == null) { |
|
| 16 | + self::$db = new SmrMySqlDatabase(); |
|
| 17 | + } |
|
| 17 | 18 | } |
| 18 | 19 | |
| 19 | 20 | public static function getWeapon($weaponTypeID, $forceUpdate = false, $db = null) { |
| 20 | 21 | if ($forceUpdate || !isset(self::$CACHE_WEAPONS[$weaponTypeID])) { |
| 21 | 22 | $w = new SmrWeapon($weaponTypeID, $db); |
| 22 | - if ($w->exists()) |
|
| 23 | - self::$CACHE_WEAPONS[$weaponTypeID] = $w; |
|
| 24 | - else |
|
| 25 | - self::$CACHE_WEAPONS[$weaponTypeID] = false; |
|
| 23 | + if ($w->exists()) { |
|
| 24 | + self::$CACHE_WEAPONS[$weaponTypeID] = $w; |
|
| 25 | + } else { |
|
| 26 | + self::$CACHE_WEAPONS[$weaponTypeID] = false; |
|
| 27 | + } |
|
| 26 | 28 | } |
| 27 | 29 | return self::$CACHE_WEAPONS[$weaponTypeID]; |
| 28 | 30 | } |
@@ -151,8 +153,9 @@ discard block |
||
| 151 | 153 | $weaponShip = $weaponPlayer->getShip(); |
| 152 | 154 | $targetShip = $targetPlayer->getShip(); |
| 153 | 155 | $mrDiff = $targetShip->getMR() - $weaponShip->getMR(); |
| 154 | - if ($mrDiff > 0) |
|
| 155 | - $modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100; |
|
| 156 | + if ($mrDiff > 0) { |
|
| 157 | + $modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100; |
|
| 158 | + } |
|
| 156 | 159 | |
| 157 | 160 | return $modifiedAccuracy; |
| 158 | 161 | } |
@@ -190,22 +193,28 @@ discard block |
||
| 190 | 193 | } |
| 191 | 194 | |
| 192 | 195 | public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) { |
| 193 | - if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 196 | + if (!$this->canShootForces()) { |
|
| 197 | + // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 194 | 198 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 199 | + } |
|
| 195 | 200 | $damage =& $this->getModifiedDamage(); |
| 196 | 201 | return $damage; |
| 197 | 202 | } |
| 198 | 203 | |
| 199 | 204 | public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) { |
| 200 | - if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 205 | + if (!$this->canShootPorts()) { |
|
| 206 | + // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 201 | 207 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 208 | + } |
|
| 202 | 209 | $damage =& $this->getModifiedDamage(); |
| 203 | 210 | return $damage; |
| 204 | 211 | } |
| 205 | 212 | |
| 206 | 213 | public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) { |
| 207 | - if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 214 | + if (!$this->canShootPlanets()) { |
|
| 215 | + // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 208 | 216 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 217 | + } |
|
| 209 | 218 | $damage =& $this->getModifiedDamage(); |
| 210 | 219 | |
| 211 | 220 | $planetMod = self::PLANET_DAMAGE_MOD; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 95 | 95 | return $return; |
| 96 | 96 | } |
| 97 | - $damage =& $this->getModifiedDamage(); |
|
| 97 | + $damage = & $this->getModifiedDamage(); |
|
| 98 | 98 | if ($targetPlayer->getShip()->isFederal()) { // do less damage to fed ships |
| 99 | 99 | $damage['MaxDamage'] = IRound($damage['MaxDamage'] * self::FED_SHIP_DAMAGE_MODIFIER); |
| 100 | 100 | $damage['Shield'] = IRound($damage['Shield'] * self::FED_SHIP_DAMAGE_MODIFIER); |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | protected function &doForceDamageToPlayer(array &$return, SmrForce $forces, AbstractSmrPlayer $targetPlayer, $minesAreAttacker = false) { |
| 134 | - $return['WeaponDamage'] =& $this->getModifiedForceDamageAgainstPlayer($forces, $targetPlayer, $minesAreAttacker); |
|
| 135 | - $return['ActualDamage'] =& $targetPlayer->getShip()->doMinesDamage($return['WeaponDamage']); |
|
| 134 | + $return['WeaponDamage'] = & $this->getModifiedForceDamageAgainstPlayer($forces, $targetPlayer, $minesAreAttacker); |
|
| 135 | + $return['ActualDamage'] = & $targetPlayer->getShip()->doMinesDamage($return['WeaponDamage']); |
|
| 136 | 136 | $return['ActualDamage']['Launched'] = ICeil($return['WeaponDamage']['Launched'] * $return['ActualDamage']['TotalDamage'] / $return['WeaponDamage']['MaxDamage']); |
| 137 | 137 | |
| 138 | 138 | if ($return['ActualDamage']['KillingShot']) { |
| 139 | - $return['KillResults'] =& $targetPlayer->killPlayerByForces($forces); |
|
| 139 | + $return['KillResults'] = & $targetPlayer->killPlayerByForces($forces); |
|
| 140 | 140 | } |
| 141 | 141 | return $return; |
| 142 | 142 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) { |
| 130 | 130 | if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
| 131 | 131 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 132 | - $damage =& $this->getModifiedDamage(); |
|
| 132 | + $damage = & $this->getModifiedDamage(); |
|
| 133 | 133 | $damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstForces($weaponPlayer, $forces) / 100); |
| 134 | 134 | $damage['Kamikaze'] = 0; |
| 135 | 135 | if ($weaponPlayer->isCombatDronesKamikazeOnMines()) { // If kamikaze then damage is same as MINE_ARMOUR |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) { |
| 152 | 152 | if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
| 153 | 153 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 154 | - $damage =& $this->getModifiedDamage(); |
|
| 154 | + $damage = & $this->getModifiedDamage(); |
|
| 155 | 155 | $damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPort($weaponPlayer, $port) / 100); |
| 156 | 156 | $damage['MaxDamage'] = ICeil($damage['Launched'] * $damage['MaxDamage']); |
| 157 | 157 | $damage['Shield'] = ICeil($damage['Launched'] * $damage['Shield']); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) { |
| 164 | 164 | if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
| 165 | 165 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 166 | - $damage =& $this->getModifiedDamage(); |
|
| 166 | + $damage = & $this->getModifiedDamage(); |
|
| 167 | 167 | $damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPlanet($weaponPlayer, $planet) / 100); |
| 168 | 168 | $planetMod = self::PLANET_DAMAGE_MOD; |
| 169 | 169 | $damage['MaxDamage'] = ICeil($damage['Launched'] * $damage['MaxDamage'] * $planetMod); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 179 | 179 | return $return; |
| 180 | 180 | } |
| 181 | - $damage =& $this->getModifiedDamage(); |
|
| 181 | + $damage = & $this->getModifiedDamage(); |
|
| 182 | 182 | if ($targetPlayer->getShip()->hasDCS()) { |
| 183 | 183 | $damage['MaxDamage'] *= DCS_PLAYER_DAMAGE_DECIMAL_PERCENT; |
| 184 | 184 | $damage['Shield'] *= DCS_PLAYER_DAMAGE_DECIMAL_PERCENT; |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 197 | 197 | return $return; |
| 198 | 198 | } |
| 199 | - $damage =& $this->getModifiedDamage(); |
|
| 199 | + $damage = & $this->getModifiedDamage(); |
|
| 200 | 200 | |
| 201 | 201 | if ($targetPlayer->getShip()->hasDCS()) { |
| 202 | 202 | $damage['MaxDamage'] *= DCS_FORCE_DAMAGE_DECIMAL_PERCENT; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 217 | 217 | return $return; |
| 218 | 218 | } |
| 219 | - $damage =& $this->getModifiedDamage(); |
|
| 219 | + $damage = & $this->getModifiedDamage(); |
|
| 220 | 220 | |
| 221 | 221 | if ($targetPlayer->getShip()->hasDCS()) { |
| 222 | 222 | $damage['MaxDamage'] *= DCS_PORT_DAMAGE_DECIMAL_PERCENT; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 236 | 236 | return $return; |
| 237 | 237 | } |
| 238 | - $damage =& $this->getModifiedDamage(); |
|
| 238 | + $damage = & $this->getModifiedDamage(); |
|
| 239 | 239 | |
| 240 | 240 | if ($targetPlayer->getShip()->hasDCS()) { |
| 241 | 241 | $damage['MaxDamage'] *= DCS_PLANET_DAMAGE_DECIMAL_PERCENT; |
@@ -13,8 +13,7 @@ discard block |
||
| 13 | 13 | $this->maxDamage = 2; |
| 14 | 14 | $this->shieldDamage = 2; |
| 15 | 15 | $this->armourDamage = 2; |
| 16 | - } |
|
| 17 | - else { |
|
| 16 | + } else { |
|
| 18 | 17 | $this->maxDamage = 1; |
| 19 | 18 | $this->shieldDamage = 1; |
| 20 | 19 | $this->armourDamage = 1; |
@@ -84,8 +83,9 @@ discard block |
||
| 84 | 83 | $weaponShip = $weaponPlayer->getShip(); |
| 85 | 84 | $targetShip = $targetPlayer->getShip(); |
| 86 | 85 | $mrDiff = $targetShip->getMR() - $weaponShip->getMR(); |
| 87 | - if ($mrDiff > 0) |
|
| 88 | - $modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100; |
|
| 86 | + if ($mrDiff > 0) { |
|
| 87 | + $modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | return max(0, min(100, $modifiedAccuracy)); |
| 91 | 91 | } |
@@ -127,8 +127,10 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) { |
| 130 | - if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 130 | + if (!$this->canShootForces()) { |
|
| 131 | + // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 131 | 132 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 133 | + } |
|
| 132 | 134 | $damage =& $this->getModifiedDamage(); |
| 133 | 135 | $damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstForces($weaponPlayer, $forces) / 100); |
| 134 | 136 | $damage['Kamikaze'] = 0; |
@@ -149,8 +151,10 @@ discard block |
||
| 149 | 151 | } |
| 150 | 152 | |
| 151 | 153 | public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) { |
| 152 | - if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 154 | + if (!$this->canShootPorts()) { |
|
| 155 | + // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 153 | 156 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 157 | + } |
|
| 154 | 158 | $damage =& $this->getModifiedDamage(); |
| 155 | 159 | $damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPort($weaponPlayer, $port) / 100); |
| 156 | 160 | $damage['MaxDamage'] = ICeil($damage['Launched'] * $damage['MaxDamage']); |
@@ -161,8 +165,10 @@ discard block |
||
| 161 | 165 | } |
| 162 | 166 | |
| 163 | 167 | public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) { |
| 164 | - if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 168 | + if (!$this->canShootPlanets()) { |
|
| 169 | + // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
| 165 | 170 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 171 | + } |
|
| 166 | 172 | $damage =& $this->getModifiedDamage(); |
| 167 | 173 | $damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPlanet($weaponPlayer, $planet) / 100); |
| 168 | 174 | $planetMod = self::PLANET_DAMAGE_MOD; |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
| 81 | 81 | return $return; |
| 82 | 82 | } |
| 83 | - $damage =& $this->getModifiedDamage(); |
|
| 83 | + $damage = & $this->getModifiedDamage(); |
|
| 84 | 84 | $damage['Launched'] = ICeil($this->getNumberOfSDs() * $this->getModifiedForceAccuracyAgainstPlayer($forces, $targetPlayer) / 100); |
| 85 | 85 | $damage['MaxDamage'] = ICeil($damage['Launched'] * $damage['MaxDamage']); |
| 86 | 86 | $damage['Shield'] = ICeil($damage['Launched'] * $damage['Shield']); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | foreach (\Globals::getGoods() as $goodId => $value) { |
| 92 | 92 | if ($goods[$goodId]===true) { |
| 93 | 93 | if ($sectors[$currentSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_SELLS && |
| 94 | - $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
|
| 94 | + $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
|
| 95 | 95 | $rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $raceID, $sectors[$targetSectorId]->getPort()->getRaceID(), $sectors[$currentSectorId]->getPort()->getGoodDistance($goodId), $sectors[$targetSectorId]->getPort()->getGoodDistance($goodId), $distance, $goodId); |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | foreach (\Globals::getGoods() as $goodId => $value) { |
| 117 | 117 | if ($goods[$goodId]===true) { |
| 118 | 118 | if ($sectors[$currentSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_SELLS && |
| 119 | - $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
|
| 119 | + $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
|
| 120 | 120 | $owr = new OneWayRoute($currentSectorId, $targetSectorId, $sectors[$currentSectorId]->getPort()->getRaceID(), $sectors[$targetSectorId]->getPort()->getRaceID(), $sectors[$currentSectorId]->getPort()->getGoodDistance($goodId), $sectors[$targetSectorId]->getPort()->getGoodDistance($goodId), $distance, $goodId); |
| 121 | 121 | $fakeReturn = new OneWayRoute($targetSectorId, $currentSectorId, $sectors[$targetSectorId]->getPort()->getRaceID(), $sectors[$currentSectorId]->getPort()->getRaceID(), 0, 0, $distance, GOOD_NOTHING); |
| 122 | 122 | $mpr = new MultiplePortRoute($owr, $fakeReturn); |
@@ -72,24 +72,24 @@ discard block |
||
| 72 | 72 | $routes = array(); |
| 73 | 73 | foreach ($distances as $currentSectorId => $d) { |
| 74 | 74 | $raceID = $sectors[$currentSectorId]->getPort()->getRaceID(); |
| 75 | - if (isset($races[$raceID])===false) { |
|
| 76 | - echo 'Error with Race ID: '.$sectors[$currentSectorId]->getPort()->getRaceID(); |
|
| 75 | + if (isset($races[$raceID]) === false) { |
|
| 76 | + echo 'Error with Race ID: ' . $sectors[$currentSectorId]->getPort()->getRaceID(); |
|
| 77 | 77 | continue; |
| 78 | 78 | } |
| 79 | - if($races[$raceID]===false) |
|
| 79 | + if ($races[$raceID] === false) |
|
| 80 | 80 | continue; |
| 81 | 81 | $rl = array(); |
| 82 | 82 | foreach ($d as $targetSectorId => $distance) { |
| 83 | 83 | if (!$races[$sectors[$targetSectorId]->getPort()->getRaceID()]) |
| 84 | 84 | continue; |
| 85 | - if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) |
|
| 85 | + if ($routesForPort !== -1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) |
|
| 86 | 86 | continue; |
| 87 | 87 | |
| 88 | - if ($goods[GOOD_NOTHING]===true) |
|
| 88 | + if ($goods[GOOD_NOTHING] === true) |
|
| 89 | 89 | $rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $raceID, $sectors[$targetSectorId]->getPort()->getRaceID(), 0, 0, $distance, GOOD_NOTHING); |
| 90 | 90 | |
| 91 | 91 | foreach (\Globals::getGoods() as $goodId => $value) { |
| 92 | - if ($goods[$goodId]===true) { |
|
| 92 | + if ($goods[$goodId] === true) { |
|
| 93 | 93 | if ($sectors[$currentSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_SELLS && |
| 94 | 94 | $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
| 95 | 95 | $rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $raceID, $sectors[$targetSectorId]->getPort()->getRaceID(), $sectors[$currentSectorId]->getPort()->getGoodDistance($goodId), $sectors[$targetSectorId]->getPort()->getGoodDistance($goodId), $distance, $goodId); |
@@ -105,16 +105,16 @@ discard block |
||
| 105 | 105 | public static function generateOneWayRoutes(array $sectors, array $distances, array $goods, array $races, int $routesForPort) : array { |
| 106 | 106 | self::initialize(); |
| 107 | 107 | foreach ($distances as $currentSectorId => $d) { |
| 108 | - if ($races[$sectors[$currentSectorId]->getPort()->getRaceID()]===false) |
|
| 108 | + if ($races[$sectors[$currentSectorId]->getPort()->getRaceID()] === false) |
|
| 109 | 109 | continue; |
| 110 | 110 | foreach ($d as $targetSectorId => $distance) { |
| 111 | - if ($races[$sectors[$targetSectorId]->getPort()->getRaceID()]===false) |
|
| 111 | + if ($races[$sectors[$targetSectorId]->getPort()->getRaceID()] === false) |
|
| 112 | 112 | continue; |
| 113 | - if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) |
|
| 113 | + if ($routesForPort !== -1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) |
|
| 114 | 114 | continue; |
| 115 | 115 | |
| 116 | 116 | foreach (\Globals::getGoods() as $goodId => $value) { |
| 117 | - if ($goods[$goodId]===true) { |
|
| 117 | + if ($goods[$goodId] === true) { |
|
| 118 | 118 | if ($sectors[$currentSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_SELLS && |
| 119 | 119 | $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
| 120 | 120 | $owr = new OneWayRoute($currentSectorId, $targetSectorId, $sectors[$currentSectorId]->getPort()->getRaceID(), $sectors[$targetSectorId]->getPort()->getRaceID(), $sectors[$currentSectorId]->getPort()->getGoodDistance($goodId), $sectors[$targetSectorId]->getPort()->getGoodDistance($goodId), $distance, $goodId); |
@@ -160,18 +160,18 @@ discard block |
||
| 160 | 160 | $i = 0; |
| 161 | 161 | krsort(self::$expRoutes, SORT_NUMERIC); |
| 162 | 162 | foreach (self::$expRoutes as $multi => $routesByMulti) { |
| 163 | - if(count($routesByMulti)+$i < $trimToBestXRoutes) { |
|
| 163 | + if (count($routesByMulti) + $i < $trimToBestXRoutes) { |
|
| 164 | 164 | $i += count($routesByMulti); |
| 165 | 165 | } |
| 166 | - else if($i > $trimToBestXRoutes) { |
|
| 166 | + else if ($i > $trimToBestXRoutes) { |
|
| 167 | 167 | unset(self::$expRoutes[$multi]); |
| 168 | 168 | } |
| 169 | 169 | else { |
| 170 | - foreach($routesByMulti as $key => $value) { |
|
| 170 | + foreach ($routesByMulti as $key => $value) { |
|
| 171 | 171 | $i++; |
| 172 | - if($i < $trimToBestXRoutes) |
|
| 172 | + if ($i < $trimToBestXRoutes) |
|
| 173 | 173 | continue; |
| 174 | - if($i === $trimToBestXRoutes) { |
|
| 174 | + if ($i === $trimToBestXRoutes) { |
|
| 175 | 175 | self::$dontAddWorseThan[self::EXP_ROUTE] = $multi; |
| 176 | 176 | continue; |
| 177 | 177 | } |
@@ -183,19 +183,19 @@ discard block |
||
| 183 | 183 | $i = 0; |
| 184 | 184 | krsort(self::$moneyRoutes, SORT_NUMERIC); |
| 185 | 185 | foreach (self::$moneyRoutes as $multi => $routesByMulti) { |
| 186 | - if(count($routesByMulti)+$i < $trimToBestXRoutes) { |
|
| 186 | + if (count($routesByMulti) + $i < $trimToBestXRoutes) { |
|
| 187 | 187 | $i += count($routesByMulti); |
| 188 | 188 | } |
| 189 | - else if($i > $trimToBestXRoutes) { |
|
| 189 | + else if ($i > $trimToBestXRoutes) { |
|
| 190 | 190 | unset(self::$moneyRoutes[$multi]); |
| 191 | 191 | continue; |
| 192 | 192 | } |
| 193 | 193 | else { |
| 194 | - foreach($routesByMulti as $key => $value) { |
|
| 194 | + foreach ($routesByMulti as $key => $value) { |
|
| 195 | 195 | $i++; |
| 196 | - if($i < $trimToBestXRoutes) |
|
| 196 | + if ($i < $trimToBestXRoutes) |
|
| 197 | 197 | continue; |
| 198 | - if($i === $trimToBestXRoutes) { |
|
| 198 | + if ($i === $trimToBestXRoutes) { |
|
| 199 | 199 | self::$dontAddWorseThan[self::MONEY_ROUTE] = $multi; |
| 200 | 200 | continue; |
| 201 | 201 | } |
@@ -52,15 +52,16 @@ discard block |
||
| 52 | 52 | private static function getContinueRoutes(int $maxNumPorts, int $startSectorId, Route $routeToContinue, array $forwardRoutes, array $routeLists, bool $lastGoodIsNothing) : void { |
| 53 | 53 | foreach ($forwardRoutes as $currentStepRoute) { |
| 54 | 54 | $currentStepBuySector = $currentStepRoute->getBuySectorId(); |
| 55 | - if ($lastGoodIsNothing && ($lastGoodIsNothing = GOOD_NOTHING === $currentStepRoute->getGoodID())) |
|
| 56 | - continue; // Don't do two nothings in a row |
|
| 55 | + if ($lastGoodIsNothing && ($lastGoodIsNothing = GOOD_NOTHING === $currentStepRoute->getGoodID())) { |
|
| 56 | + continue; |
|
| 57 | + } |
|
| 58 | + // Don't do two nothings in a row |
|
| 57 | 59 | if ($currentStepBuySector >= $startSectorId) { // Not already checked or back to start |
| 58 | 60 | if ($currentStepBuySector === $startSectorId) { // Route returns to start |
| 59 | 61 | $mpr = new MultiplePortRoute($routeToContinue, $currentStepRoute); |
| 60 | 62 | self::addExpRoute($mpr); |
| 61 | 63 | self::addMoneyRoute($mpr); |
| 62 | - } |
|
| 63 | - else if ($maxNumPorts > 1 && !$routeToContinue->containsPort($currentStepBuySector)) { |
|
| 64 | + } else if ($maxNumPorts > 1 && !$routeToContinue->containsPort($currentStepBuySector)) { |
|
| 64 | 65 | $mpr = new MultiplePortRoute($routeToContinue, $currentStepRoute); |
| 65 | 66 | self::getContinueRoutes($maxNumPorts - 1, $startSectorId, $mpr, $routeLists[$currentStepBuySector], $routeLists, $lastGoodIsNothing); |
| 66 | 67 | } |
@@ -76,17 +77,21 @@ discard block |
||
| 76 | 77 | echo 'Error with Race ID: '.$sectors[$currentSectorId]->getPort()->getRaceID(); |
| 77 | 78 | continue; |
| 78 | 79 | } |
| 79 | - if($races[$raceID]===false) |
|
| 80 | - continue; |
|
| 80 | + if($races[$raceID]===false) { |
|
| 81 | + continue; |
|
| 82 | + } |
|
| 81 | 83 | $rl = array(); |
| 82 | 84 | foreach ($d as $targetSectorId => $distance) { |
| 83 | - if (!$races[$sectors[$targetSectorId]->getPort()->getRaceID()]) |
|
| 84 | - continue; |
|
| 85 | - if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) |
|
| 86 | - continue; |
|
| 85 | + if (!$races[$sectors[$targetSectorId]->getPort()->getRaceID()]) { |
|
| 86 | + continue; |
|
| 87 | + } |
|
| 88 | + if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) { |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 87 | 91 | |
| 88 | - if ($goods[GOOD_NOTHING]===true) |
|
| 89 | - $rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $raceID, $sectors[$targetSectorId]->getPort()->getRaceID(), 0, 0, $distance, GOOD_NOTHING); |
|
| 92 | + if ($goods[GOOD_NOTHING]===true) { |
|
| 93 | + $rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $raceID, $sectors[$targetSectorId]->getPort()->getRaceID(), 0, 0, $distance, GOOD_NOTHING); |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | 96 | foreach (\Globals::getGoods() as $goodId => $value) { |
| 92 | 97 | if ($goods[$goodId]===true) { |
@@ -105,13 +110,16 @@ discard block |
||
| 105 | 110 | public static function generateOneWayRoutes(array $sectors, array $distances, array $goods, array $races, int $routesForPort) : array { |
| 106 | 111 | self::initialize(); |
| 107 | 112 | foreach ($distances as $currentSectorId => $d) { |
| 108 | - if ($races[$sectors[$currentSectorId]->getPort()->getRaceID()]===false) |
|
| 109 | - continue; |
|
| 113 | + if ($races[$sectors[$currentSectorId]->getPort()->getRaceID()]===false) { |
|
| 114 | + continue; |
|
| 115 | + } |
|
| 110 | 116 | foreach ($d as $targetSectorId => $distance) { |
| 111 | - if ($races[$sectors[$targetSectorId]->getPort()->getRaceID()]===false) |
|
| 112 | - continue; |
|
| 113 | - if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) |
|
| 114 | - continue; |
|
| 117 | + if ($races[$sectors[$targetSectorId]->getPort()->getRaceID()]===false) { |
|
| 118 | + continue; |
|
| 119 | + } |
|
| 120 | + if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) { |
|
| 121 | + continue; |
|
| 122 | + } |
|
| 115 | 123 | |
| 116 | 124 | foreach (\Globals::getGoods() as $goodId => $value) { |
| 117 | 125 | if ($goods[$goodId]===true) { |
@@ -162,15 +170,14 @@ discard block |
||
| 162 | 170 | foreach (self::$expRoutes as $multi => $routesByMulti) { |
| 163 | 171 | if(count($routesByMulti)+$i < $trimToBestXRoutes) { |
| 164 | 172 | $i += count($routesByMulti); |
| 165 | - } |
|
| 166 | - else if($i > $trimToBestXRoutes) { |
|
| 173 | + } else if($i > $trimToBestXRoutes) { |
|
| 167 | 174 | unset(self::$expRoutes[$multi]); |
| 168 | - } |
|
| 169 | - else { |
|
| 175 | + } else { |
|
| 170 | 176 | foreach($routesByMulti as $key => $value) { |
| 171 | 177 | $i++; |
| 172 | - if($i < $trimToBestXRoutes) |
|
| 173 | - continue; |
|
| 178 | + if($i < $trimToBestXRoutes) { |
|
| 179 | + continue; |
|
| 180 | + } |
|
| 174 | 181 | if($i === $trimToBestXRoutes) { |
| 175 | 182 | self::$dontAddWorseThan[self::EXP_ROUTE] = $multi; |
| 176 | 183 | continue; |
@@ -185,16 +192,15 @@ discard block |
||
| 185 | 192 | foreach (self::$moneyRoutes as $multi => $routesByMulti) { |
| 186 | 193 | if(count($routesByMulti)+$i < $trimToBestXRoutes) { |
| 187 | 194 | $i += count($routesByMulti); |
| 188 | - } |
|
| 189 | - else if($i > $trimToBestXRoutes) { |
|
| 195 | + } else if($i > $trimToBestXRoutes) { |
|
| 190 | 196 | unset(self::$moneyRoutes[$multi]); |
| 191 | 197 | continue; |
| 192 | - } |
|
| 193 | - else { |
|
| 198 | + } else { |
|
| 194 | 199 | foreach($routesByMulti as $key => $value) { |
| 195 | 200 | $i++; |
| 196 | - if($i < $trimToBestXRoutes) |
|
| 197 | - continue; |
|
| 201 | + if($i < $trimToBestXRoutes) { |
|
| 202 | + continue; |
|
| 203 | + } |
|
| 198 | 204 | if($i === $trimToBestXRoutes) { |
| 199 | 205 | self::$dontAddWorseThan[self::MONEY_ROUTE] = $multi; |
| 200 | 206 | continue; |