Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrutinizer Auto-Fixes #1007

Merged
merged 2 commits into from Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/lib/Default/AbstractSmrCombatWeapon.class.php
Expand Up @@ -67,7 +67,7 @@ abstract public function getModifiedForceDamageAgainstPlayer(SmrForce $forces, A
abstract public function getModifiedPlanetDamageAgainstPlayer(SmrPlanet $planet, AbstractSmrPlayer $targetPlayer);

protected function doPlayerDamageToForce(array $return, AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
$return['WeaponDamage'] = $this->getModifiedDamageAgainstForces($weaponPlayer,$forces);
$return['WeaponDamage'] = $this->getModifiedDamageAgainstForces($weaponPlayer, $forces);
$return['ActualDamage'] = $forces->doWeaponDamage($return['WeaponDamage']);
if ($return['ActualDamage']['KillingShot']) {
$return['KillResults'] = $forces->killForcesByPlayer($weaponPlayer);
Expand All @@ -76,7 +76,7 @@ protected function doPlayerDamageToForce(array $return, AbstractSmrPlayer $weapo
}

protected function doPlayerDamageToPlayer(array $return, AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) {
$return['WeaponDamage'] = $this->getModifiedDamageAgainstPlayer($weaponPlayer,$targetPlayer);
$return['WeaponDamage'] = $this->getModifiedDamageAgainstPlayer($weaponPlayer, $targetPlayer);
$return['ActualDamage'] = $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);

if ($return['ActualDamage']['KillingShot']) {
Expand All @@ -86,7 +86,7 @@ protected function doPlayerDamageToPlayer(array $return, AbstractSmrPlayer $weap
}

protected function doPlayerDamageToPort(array $return, AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
$return['WeaponDamage'] = $this->getModifiedDamageAgainstPort($weaponPlayer,$port);
$return['WeaponDamage'] = $this->getModifiedDamageAgainstPort($weaponPlayer, $port);
$return['ActualDamage'] = $port->doWeaponDamage($return['WeaponDamage']);
if ($return['ActualDamage']['KillingShot']) {
$return['KillResults'] = $port->killPortByPlayer($weaponPlayer);
Expand All @@ -95,16 +95,16 @@ protected function doPlayerDamageToPort(array $return, AbstractSmrPlayer $weapon
}

protected function doPlayerDamageToPlanet(array $return, AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet, $delayed) {
$return['WeaponDamage'] = $this->getModifiedDamageAgainstPlanet($weaponPlayer,$planet);
$return['ActualDamage'] = $planet->doWeaponDamage($return['WeaponDamage'],$delayed);
$return['WeaponDamage'] = $this->getModifiedDamageAgainstPlanet($weaponPlayer, $planet);
$return['ActualDamage'] = $planet->doWeaponDamage($return['WeaponDamage'], $delayed);
if ($return['ActualDamage']['KillingShot']) {
$return['KillResults'] = $planet->killPlanetByPlayer($weaponPlayer);
}
return $return;
}

protected function doPortDamageToPlayer(array $return, SmrPort $port, AbstractSmrPlayer $targetPlayer) {
$return['WeaponDamage'] = $this->getModifiedPortDamageAgainstPlayer($port,$targetPlayer);
$return['WeaponDamage'] = $this->getModifiedPortDamageAgainstPlayer($port, $targetPlayer);
$return['ActualDamage'] = $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);

if ($return['ActualDamage']['KillingShot']) {
Expand All @@ -114,7 +114,7 @@ protected function doPortDamageToPlayer(array $return, SmrPort $port, AbstractSm
}

protected function doPlanetDamageToPlayer(array $return, SmrPlanet $planet, AbstractSmrPlayer $targetPlayer) {
$return['WeaponDamage'] = $this->getModifiedPlanetDamageAgainstPlayer($planet,$targetPlayer);
$return['WeaponDamage'] = $this->getModifiedPlanetDamageAgainstPlayer($planet, $targetPlayer);
$return['ActualDamage'] = $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);

if ($return['ActualDamage']['KillingShot']) {
Expand All @@ -124,7 +124,7 @@ protected function doPlanetDamageToPlayer(array $return, SmrPlanet $planet, Abst
}

protected function doForceDamageToPlayer(array $return, SmrForce $forces, AbstractSmrPlayer $targetPlayer) {
$return['WeaponDamage'] = $this->getModifiedForceDamageAgainstPlayer($forces,$targetPlayer);
$return['WeaponDamage'] = $this->getModifiedForceDamageAgainstPlayer($forces, $targetPlayer);
$return['ActualDamage'] = $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);

if ($return['ActualDamage']['KillingShot']) {
Expand Down
18 changes: 9 additions & 9 deletions src/lib/Default/DummyShip.class.php
Expand Up @@ -16,7 +16,7 @@ public function __construct(AbstractSmrPlayer $player) {
}

protected function doFullUNO() {
foreach($this->getMaxHardware() as $hardwareTypeID => $max) {
foreach ($this->getMaxHardware() as $hardwareTypeID => $max) {
$this->hardware[$hardwareTypeID] = $max;
$this->oldHardware[$hardwareTypeID] = $max;
}
Expand Down Expand Up @@ -46,8 +46,8 @@ public function disableIllusion() {
}

public function getIllusionShip() {
if(!isset($this->illusionShip)) {
$this->illusionShip=false;
if (!isset($this->illusionShip)) {
$this->illusionShip = false;
}
return $this->illusionShip;
}
Expand All @@ -57,20 +57,20 @@ public function cacheDummyShip() {
$db = MySqlDatabase::getInstance();
$db->query('REPLACE INTO cached_dummys ' .
'(type, id, info) ' .
'VALUES (\'DummyShip\', '.$db->escapeString($this->getPlayer()->getPlayerName()).', '.$db->escapeString($cache).')');
'VALUES (\'DummyShip\', ' . $db->escapeString($this->getPlayer()->getPlayerName()) . ', ' . $db->escapeString($cache) . ')');
unserialize($cache);
}

public static function getCachedDummyShip(AbstractSmrPlayer $player) {
if(!isset(self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()])) {
if (!isset(self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()])) {
$db = MySqlDatabase::getInstance();
$db->query('SELECT info FROM cached_dummys
WHERE type = \'DummyShip\'
AND id = ' . $db->escapeString($player->getPlayerName()) . ' LIMIT 1');
if($db->nextRecord()) {
if ($db->nextRecord()) {
$return = unserialize($db->getField('info'));
$return->regenerate($player);
self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] =& $return;
self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = & $return;
hemberger marked this conversation as resolved.
Show resolved Hide resolved
} else {
self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = new DummyShip($player);
}
Expand All @@ -83,7 +83,7 @@ public static function getDummyShipNames() {
$db->query('SELECT id FROM cached_dummys
WHERE type = \'DummyShip\'');
$dummyNames = array();
while($db->nextRecord()) {
while ($db->nextRecord()) {
$dummyNames[] = $db->getField('id');
}
return $dummyNames;
Expand All @@ -92,7 +92,7 @@ public static function getDummyShipNames() {


public function __sleep() {
return array('gameID','weapons');
return array('gameID', 'weapons');
}

public function __wakeup() {
Expand Down
Expand Up @@ -16,24 +16,24 @@
$WeaponDamage = $WeaponResults['WeaponDamage'];
}

echo $ShootingPlayer->getDisplayName() ?> fires their <?php echo $ShootingWeapon->getName() ?> at<?php if ($ShotHit && $ActualDamage['TargetAlreadyDead']){ ?> the debris that was once<?php } ?> the forces<?php
echo $ShootingPlayer->getDisplayName() ?> fires their <?php echo $ShootingWeapon->getName() ?> at<?php if ($ShotHit && $ActualDamage['TargetAlreadyDead']) { ?> the debris that was once<?php } ?> the forces<?php
if (!$ShotHit || !$ActualDamage['TargetAlreadyDead']) {
if (!$ShotHit) {
?> and misses<?php
} elseif ($ActualDamage['TotalDamage'] == 0) {
if ($WeaponDamage['Shield'] > 0) {
?> which proves ineffective against the <?php if ($ActualDamage['HasMines']){ ?>mines<?php } elseif ($ActualDamage['HasCDs']){ ?>combat drones<?php } else{ ?>scout drones<?php }
?> which proves ineffective against the <?php if ($ActualDamage['HasMines']) { ?>mines<?php } elseif ($ActualDamage['HasCDs']) { ?>combat drones<?php } else { ?>scout drones<?php }
} elseif ($WeaponDamage['Armour'] > 0) {
?> which is deflected by the <?php if ($ActualDamage['HasMines']){ ?>mines<?php } elseif ($ActualDamage['HasCDs']){ ?>combat drones<?php } else{ ?>scout drones<?php } ?> shields<?php
?> which is deflected by the <?php if ($ActualDamage['HasMines']) { ?>mines<?php } elseif ($ActualDamage['HasCDs']) { ?>combat drones<?php } else { ?>scout drones<?php } ?> shields<?php
} else {
?> but it cannot do any damage<?php
}
} else {
?> destroying <?php
$DamageTypes = 0;
if ($ActualDamage['NumMines'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['NumCDs'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['NumSDs'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['NumMines'] > 0) { $DamageTypes = $DamageTypes + 1; }
if ($ActualDamage['NumCDs'] > 0) { $DamageTypes = $DamageTypes + 1; }
if ($ActualDamage['NumSDs'] > 0) { $DamageTypes = $DamageTypes + 1; }

if ($ActualDamage['NumMines'] > 0) {
?><span class="red"><?php echo number_format($ActualDamage['NumMines']) ?></span> mines<?php
Expand Down Expand Up @@ -63,22 +63,22 @@
if ($WeaponDamage['Launched'] == 0) {
?> fails to launch their combat drones<?php
} else {
?> launches <span class="cds"><?php echo $WeaponDamage['Launched'] ?></span> combat drones at<?php if ($ActualDamage['TargetAlreadyDead']){ ?> the debris that was once <?php } ?> the forces<?php
?> launches <span class="cds"><?php echo $WeaponDamage['Launched'] ?></span> combat drones at<?php if ($ActualDamage['TargetAlreadyDead']) { ?> the debris that was once <?php } ?> the forces<?php
if (!$ActualDamage['TargetAlreadyDead']) {
if ($ActualDamage['TotalDamage'] == 0) {
if ($WeaponDamage['Shield'] > 0) {
?> which prove ineffective against the <?php if ($ActualDamage['HasMines']){ ?>mines<?php } elseif ($ActualDamage['HasCDs']){ ?>combat drones<?php } else{ ?>scout drones<?php }
?> which prove ineffective against the <?php if ($ActualDamage['HasMines']) { ?>mines<?php } elseif ($ActualDamage['HasCDs']) { ?>combat drones<?php } else { ?>scout drones<?php }
} elseif ($WeaponDamage['Armour'] > 0) {
?> which is deflected by the <?php
if ($ActualDamage['HasMines']){ ?>mines<?php } elseif ($ActualDamage['HasCDs']){ ?>combat drones<?php } else{ ?>scout drones<?php } ?> shields<?php
if ($ActualDamage['HasMines']) { ?>mines<?php } elseif ($ActualDamage['HasCDs']) { ?>combat drones<?php } else { ?>scout drones<?php } ?> shields<?php
} else {
?> but they cannot do any damage<?php
}
} else {
$DamageTypes = 0;
if ($ActualDamage['NumMines'] > $WeaponDamage['Kamikaze']) { $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['NumCDs'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['NumSDs'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['NumMines'] > $WeaponDamage['Kamikaze']) { $DamageTypes = $DamageTypes + 1; }
if ($ActualDamage['NumCDs'] > 0) { $DamageTypes = $DamageTypes + 1; }
if ($ActualDamage['NumSDs'] > 0) { $DamageTypes = $DamageTypes + 1; }

if ($WeaponDamage['Kamikaze'] == 0) {
?> destroying <?php
Expand Down Expand Up @@ -120,4 +120,4 @@
}
}
$TotalDamage = $TraderTeamCombatResults['TotalDamage']; ?>
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 } ?>.
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 } ?>.
Expand Up @@ -16,7 +16,7 @@
?> scout drones kamikaze themselves against <?php
}

if ($ShotHit && $ActualDamage['TargetAlreadyDead']){ ?> the debris that was once <?php }
if ($ShotHit && $ActualDamage['TargetAlreadyDead']) { ?> the debris that was once <?php }
echo $TargetPlayer->getDisplayName();
if (!$ShotHit || !$ActualDamage['TargetAlreadyDead']) {
if (!$ShotHit) {
Expand All @@ -37,9 +37,9 @@
?> destroying <?php
}
$DamageTypes = 0;
if ($ActualDamage['Shield'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['NumCDs'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['Armour'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['Shield'] > 0) { $DamageTypes = $DamageTypes + 1; }
if ($ActualDamage['NumCDs'] > 0) { $DamageTypes = $DamageTypes + 1; }
if ($ActualDamage['Armour'] > 0) { $DamageTypes = $DamageTypes + 1; }

if ($ActualDamage['Shield'] > 0) {
?><span class="shields"><?php echo number_format($ActualDamage['Shield']) ?></span> shields<?php
Expand All @@ -55,7 +55,7 @@
} ?>.
<br /><?php
if ($ShotHit && $ActualDamage['KillingShot']) {
$this->includeTemplate('includes/TraderCombatKillMessage.inc.php',array('KillResults'=>$ForceResults['KillResults'],'TargetPlayer'=>$TargetPlayer));
$this->includeTemplate('includes/TraderCombatKillMessage.inc.php', array('KillResults'=>$ForceResults['KillResults'], 'TargetPlayer'=>$TargetPlayer));
}
}
}
Expand All @@ -64,4 +64,4 @@
}

$TotalDamage = $ForcesCombatResults['TotalDamage'] ?>
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 } ?>.
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 } ?>.
Expand Up @@ -20,7 +20,7 @@
}
$TargetPlayer = $WeaponResults['TargetPlayer'];

echo $CombatPlanet->getCombatName() ?> fires a <?php echo $ShootingWeapon->getName(); ?> at <?php if ($ShotHit && $ActualDamage['TargetAlreadyDead']){ ?> the debris that was once <?php } echo $TargetPlayer->getDisplayName();
echo $CombatPlanet->getCombatName() ?> fires a <?php echo $ShootingWeapon->getName(); ?> at <?php if ($ShotHit && $ActualDamage['TargetAlreadyDead']) { ?> the debris that was once <?php } echo $TargetPlayer->getDisplayName();
if (!$ShotHit || !$ActualDamage['TargetAlreadyDead']) {
if (!$ShotHit) {
?> and misses<?php
Expand All @@ -39,9 +39,9 @@
} else {
?> destroying <?php
$DamageTypes = 0;
if ($ActualDamage['Shield'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['NumCDs'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['Armour'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['Shield'] > 0) { $DamageTypes = $DamageTypes + 1; }
if ($ActualDamage['NumCDs'] > 0) { $DamageTypes = $DamageTypes + 1; }
if ($ActualDamage['Armour'] > 0) { $DamageTypes = $DamageTypes + 1; }

if ($ActualDamage['Shield'] > 0) {
?><span class="shields"><?php echo number_format($ActualDamage['Shield']); ?></span> shields<?php
Expand All @@ -58,7 +58,7 @@
} ?>.
<br /><?php
if ($ShotHit && $ActualDamage['KillingShot']) {
$this->includeTemplate('includes/TraderCombatKillMessage.inc.php',array('KillResults'=>$WeaponResults['KillResults'],'TargetPlayer'=>$TargetPlayer));
$this->includeTemplate('includes/TraderCombatKillMessage.inc.php', array('KillResults'=>$WeaponResults['KillResults'], 'TargetPlayer'=>$TargetPlayer));
}
}
}
Expand All @@ -68,15 +68,15 @@
$WeaponDamage = $Drones['WeaponDamage'];
$TargetPlayer = $Drones['TargetPlayer'];
$DamageTypes = 0;
if ($ActualDamage['Shield'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['NumCDs'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['Armour'] > 0){ $DamageTypes = $DamageTypes+1; }
if ($ActualDamage['Shield'] > 0) { $DamageTypes = $DamageTypes + 1; }
if ($ActualDamage['NumCDs'] > 0) { $DamageTypes = $DamageTypes + 1; }
if ($ActualDamage['Armour'] > 0) { $DamageTypes = $DamageTypes + 1; }

echo $CombatPlanet->getCombatName();
if ($WeaponDamage['Launched'] == 0) {
?> fails to launch it's combat drones<?php
} else {
?> launches <span class="cds"><?php echo $WeaponDamage['Launched'] ?></span> combat drones at <?php if ($ActualDamage['TargetAlreadyDead']){ ?>the debris that was once <?php } echo $TargetPlayer->getDisplayName();
?> launches <span class="cds"><?php echo $WeaponDamage['Launched'] ?></span> combat drones at <?php if ($ActualDamage['TargetAlreadyDead']) { ?>the debris that was once <?php } echo $TargetPlayer->getDisplayName();
if (!$ActualDamage['TargetAlreadyDead']) {
if ($ActualDamage['TotalDamage'] == 0) {
if ($WeaponDamage['Shield'] > 0) {
Expand Down Expand Up @@ -108,7 +108,7 @@
} ?>.
<br /><?php
if ($ActualDamage['KillingShot']) {
$this->includeTemplate('includes/TraderCombatKillMessage.inc.php',array('KillResults'=>$Drones['KillResults'],'TargetPlayer'=>$TargetPlayer));
$this->includeTemplate('includes/TraderCombatKillMessage.inc.php', array('KillResults'=>$Drones['KillResults'], 'TargetPlayer'=>$TargetPlayer));
}
}

Expand Down