Skip to content

Commit

Permalink
Merge pull request #975 from Page-/port-search-consts
Browse files Browse the repository at this point in the history
Move port search variables to consts rather than in-line
  • Loading branch information
Page- authored Jan 27, 2021
2 parents 1f21ed5 + 26d59bd commit 91d142c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@
const GOODS_LUXURY_ITEMS = 11;
const GOODS_NARCOTICS = 12;

/*
* Port searchs
*/
const PORT_SEARCH_BASE_CHANCE = 15;
const PORT_SEARCH_REDUCTION_PER_EVIL_GOOD = 4;
const PORT_SEARCH_REDUCTION_FOR_EVIL_SHIP = 4;

/*
* Ship types
*/
Expand Down
12 changes: 6 additions & 6 deletions src/engine/Default/shop_goods.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@
} elseif ($player->getLastPort() != $player->getSectorID()) {
// test if we are searched, but only if we hadn't a previous trade here

$base_chance = 15;
$baseChance = PORT_SEARCH_BASE_CHANCE;
if ($port->hasGood(GOODS_SLAVES)) {
$base_chance -= 4;
$baseChance -= PORT_SEARCH_REDUCTION_PER_EVIL_GOOD;
}
if ($port->hasGood(GOODS_WEAPONS)) {
$base_chance -= 4;
$baseChance -= PORT_SEARCH_REDUCTION_PER_EVIL_GOOD;
}
if ($port->hasGood(GOODS_NARCOTICS)) {
$base_chance -= 4;
$baseChance -= PORT_SEARCH_REDUCTION_PER_EVIL_GOOD;
}

if ($ship->isUnderground()) {
$base_chance -= 4;
$baseChance -= PORT_SEARCH_REDUCTION_FOR_EVIL_SHIP;
}

$rand = mt_rand(1, 100);
if ($rand <= $base_chance) {
if ($rand <= $baseChance) {
$searchedByFeds = true;
$player->increaseHOF(1, array('Trade', 'Search', 'Total'), HOF_PUBLIC);
if ($ship->hasIllegalGoods()) {
Expand Down

0 comments on commit 91d142c

Please sign in to comment.