Skip to content

Commit

Permalink
Merge pull request #471 from hemberger/remove-examine-force
Browse files Browse the repository at this point in the history
 Remove the Examine page for enemy forces
  • Loading branch information
hemberger authored Apr 30, 2018
2 parents c7fb1a4 + 6607aef commit e04879e
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 166 deletions.
24 changes: 9 additions & 15 deletions engine/Default/forces_attack_processing.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
require_once(get_file_loc('SmrForce.class.inc'));
$forces = SmrForce::getForce($player->getGameID(), $player->getSectorID(), $var['owner_id']);
$forceOwner = $forces->getOwner();

if ($player->hasNewbieTurns())
create_error('You are under newbie protection!');
if($player->hasFederalProtection())
Expand All @@ -7,9 +11,10 @@
create_error('You cannot attack forces whilst on a planet!');
if(!$player->canFight())
create_error('You are not allowed to fight!');

require_once(get_file_loc('SmrForce.class.inc'));
$forces =& SmrForce::getForce($player->getGameID(), $player->getSectorID(), $var['owner_id']);
if (!$ship->hasWeapons() && !$ship->hasCDs())
create_error('You cannot attack without weapons!');
if ($player->forceNAPAlliance($forceOwner))
create_error('You cannot attack allied forces!');

// The attack is processed slightly differently if the attacker bumped into mines
// when moving into sector
Expand All @@ -31,11 +36,6 @@
create_error('You do not have enough turns to attack these forces!');
}

$forceOwner =& $forces->getOwner();

if($player->forceNAPAlliance($forceOwner))
create_error('You have a force NAP, you cannot attack these forces!');

// take the turns
if ($bump) {
$player->takeTurns($forces->getBumpTurnCost($ship));
Expand All @@ -60,13 +60,7 @@
'Forces' => array(),
'Forced' => $bump);

$sector =& $player->getSector();
if ($bump) {
//When hitting mines by bumping only the current player attacks/gets hit.
$attackers = array(&$player);
} else {
$attackers =& $sector->getFightingTradersAgainstForces($player, $forces);
}
$attackers = $player->getSector()->getFightingTradersAgainstForces($player, $bump);

//decloak all attackers
foreach($attackers as &$attacker) {
Expand Down
101 changes: 0 additions & 101 deletions engine/Default/forces_examine.php

This file was deleted.

2 changes: 2 additions & 0 deletions engine/Default/sector_move_processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
if (!$sector->isLinked($var['target_sector']))
create_error('You cannot move to that sector!');

// If you bump into mines in the sector you are trying to leave...
if ($player->getLastSectorID() != $var['target_sector']) {
$sectorForces =& $sector->getForces();
Sorter::sortByNumMethod($sectorForces,'getMines',true);
Expand Down Expand Up @@ -138,6 +139,7 @@
}
} unset($forces);

// If you bump into mines while entering the target sector...
if ($mine_owner_id) {
if ($player->hasNewbieTurns()) {
$turns = $sectorForces[$mine_owner_id]->getBumpTurnCost($ship);
Expand Down
1 change: 0 additions & 1 deletion htdocs/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@
const MAXIMUM_PVP_FLEET_SIZE = 10;
const MAXIMUM_PORT_FLEET_SIZE = 10;
const MAXIMUM_PLANET_FLEET_SIZE = 10;
const MAXIMUM_FORCES_FLEET_SIZE = 1;
const MINE_ARMOUR = 20;
const CD_ARMOUR = 3;
const SD_ARMOUR = 20;
Expand Down
6 changes: 0 additions & 6 deletions lib/Default/SmrForce.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,6 @@ class SmrForce {
return SmrSession::getNewHREF($container);
}

public function getExamineAttackForcesHREF() {
$container = create_container('skeleton.php', 'forces_examine.php');
$container['owner_id'] = $this->getOwnerID();
return SmrSession::getNewHREF($container);
}

public function getAttackForcesHREF() {
$container = create_container('forces_attack_processing.php');
$container['action'] = 'attack';
Expand Down
19 changes: 3 additions & 16 deletions lib/Default/SmrSector.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -825,22 +825,9 @@ class SmrSector {
return false;
}

public function &getFightingTradersAgainstForces(AbstractSmrPlayer $attackingPlayer, SmrForce $defendingForces) {
$forceOwner = $defendingForces->getOwner();
if($attackingPlayer->forceNAPAlliance($forceOwner)) {
throw new Exception('The trader has a force NAP.');
}
$fightingPlayers = array();
$alliancePlayers = SmrPlayer::getSectorPlayersByAlliances($this->getGameID(),$this->getSectorID(), array($attackingPlayer->getAllianceID()));
if(count($alliancePlayers) > 0) {
foreach($alliancePlayers as $accountID => $player) {
if($player->canFight()) {
if($attackingPlayer->traderAttackForceAlliance($player) && !$player->forceNAPAlliance($forceOwner))
$fightingPlayers[$accountID] = $alliancePlayers[$accountID];
}
}
}
return self::limitFightingTraders($fightingPlayers, $attackingPlayer, MAXIMUM_FORCES_FLEET_SIZE);
public function getFightingTradersAgainstForces(AbstractSmrPlayer $attackingPlayer, $bump) {
// Whether bumping or attacking, only the current player fires at forces
return array($attackingPlayer);
}

public function &getFightingTradersAgainstPort(AbstractSmrPlayer $attackingPlayer, SmrPort $defendingPort) {
Expand Down
1 change: 0 additions & 1 deletion lib/Default/SmrSession.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class SmrSession {
'donation.php' => self::ALWAYS_AVAILABLE,
'feature_request_comments.php' => self::ALWAYS_AVAILABLE,
'feature_request.php' => self::ALWAYS_AVAILABLE,
'forces_examine.php' => self::ALWAYS_AVAILABLE,
'forces_list.php' => self::ALWAYS_AVAILABLE,
'forces_mass_refresh.php' => self::ALWAYS_AVAILABLE,
'government.php' => 1,
Expand Down
5 changes: 3 additions & 2 deletions templates/Default/engine/Default/forces_attack.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
}
else {
?><span class="yellow">You have destroyed the forces.</span><?php
} ?><br />
} ?>
<br /><br />
<div class="buttonA"><?php
if($OverrideDeath) {
?><a href="<?php echo Globals::getPodScreenHREF() ?>" class="buttonA">Let there be pod</a><?php
Expand All @@ -24,4 +25,4 @@
} ?>
</div><?php
} ?>
</div>
</div>
37 changes: 13 additions & 24 deletions templates/Default/engine/Default/includes/SectorForces.inc
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,19 @@
?><span class="red">WAR</span><?php
} ?>
</td>
<td><?php
// if($SharedForceAlliance) {
echo $Owner->getLinkedDisplayName();
// }
// else {
// <span class="red">UNKNOWN</span>
// } ?>
</td>
<td align="center" class="shrink center">

<div class="buttonA">
<a href="<?php
if($SharedForceAlliance) {
echo $Force->getExamineDropForcesHREF();
}
else {
echo $Force->getExamineAttackForcesHREF();
} ?>" class="buttonA<?php if(!$SharedForceAlliance){ ?> enemyExamine<?php } ?>"> Examine </a>
</div><?php
if($SharedForceAlliance) { ?>
<br />
<br />
<td><?php echo $Owner->getLinkedDisplayName(); ?></td>
<td align="center" class="shrink center"><?php
if ($SharedForceAlliance) { ?>
<div class="buttonA">
<a class="buttonA" href="<?php echo $Force->getExamineDropForcesHREF(); ?>"> Examine </a>
</div>
<br /><br />
<div class="buttonA">
<a href="<?php echo $Force->getRefreshHREF(); ?>" class="buttonA"> Refresh </a>
</div><?php
} else { ?>
<div class="buttonA">
<a href="<?php echo $Force->getRefreshHREF() ?>" class="buttonA"> Refresh </a>
<a class="buttonA enemyExamine" href="<?php echo $Force->getAttackForcesHREF(); ?>"> Attack (<?php echo $Force->getAttackTurnCost($ThisShip); ?>) </a>
</div><?php
} ?>
</td>
Expand All @@ -98,4 +87,4 @@
</tbody>
</table><?php
} ?>
</div>
</div>

0 comments on commit e04879e

Please sign in to comment.