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

Move port search variables to consts rather than in-line #975

Merged
merged 1 commit into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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