From 26d59bd3857bdfa301e9f1ce43a59d3b3ea753bc Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Wed, 27 Jan 2021 11:45:39 +0000 Subject: [PATCH] Move port search variables to consts rather than in-line --- src/config.php | 7 +++++++ src/engine/Default/shop_goods.php | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/config.php b/src/config.php index 8d465f4d6..79385c71a 100644 --- a/src/config.php +++ b/src/config.php @@ -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 */ diff --git a/src/engine/Default/shop_goods.php b/src/engine/Default/shop_goods.php index c25545026..7983c263c 100644 --- a/src/engine/Default/shop_goods.php +++ b/src/engine/Default/shop_goods.php @@ -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()) {