Files
Bubberstation/code/modules/unit_tests/cargo_crate_sanity.dm
Rhials f89f5ac378 Pirates can export minerals again, as well as everything else they could before (#92840)
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

Pirate export markets now check against both pirate markets AND cargo
markets when selling loot.

In layman's terms, you can sell everything you used to be able to sell,
like crates and stolen materials, instead of pirate-only loot like
credit chips or kidnapped victims.

I sure hope this doesn't break the unit tests.

This was done by making the export loop accept a list of markets, as
suggested in #91349.

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game

Closes #91349, for the most part. Parrots are still sold for 0 credits
but I'm pretty sure that issue is unrelated to the market issue.

I'll make a new issue report focusing on the parrot matter if this goes
through.

<!-- Argue for the merits of your changes and how they benefit the game,
especially if they are controversial and/or far reaching. If you can't
actually explain WHY what you are doing will improve the game, then it
probably isn't good for the game in the first place. -->

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and its effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

🆑 Rhials
fix: Pirates can sell minerals and other cargo exports on their bounty
pad again.
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
2025-09-02 19:27:48 -04:00

43 lines
2.0 KiB
Plaintext

/**
* This unit test loops through all cargo crates that are available to purchase, and confirms that they're below the expected sanity minimum when sold.
* This prevents us from merging a crate that sells for more that it costs to buy.
*/
/datum/unit_test/cargo_crate_sanity
/datum/unit_test/cargo_crate_sanity/Run()
for(var/crate in subtypesof(/datum/supply_pack))
var/datum/supply_pack/new_crate = allocate(crate)
if(new_crate.test_ignored)
continue // We can safely ignore custom supply packs like the stock market or mining supply crates, or packs that have innate randomness.
if(!new_crate?.crate_type)
continue
var/obj/crate_type = allocate(new_crate.crate_type)
var/turf/open/floor/testing_floor = get_turf(crate_type)
var/datum/export_report/minimum_cost = export_item_and_contents(crate_type, delete_unsold = TRUE, dry_run = TRUE)
var/crate_value = counterlist_sum(minimum_cost.total_value)
var/obj/results = new_crate.generate(testing_floor)
var/datum/export_report/export_log = export_item_and_contents(results, apply_elastic = TRUE, delete_unsold = TRUE, export_markets = list(EXPORT_MARKET_STATION))
// The value of the crate and all of it's contents.
var/value = counterlist_sum(export_log.total_value)
// We're selling the crate and it's contents for more value than it's supply_pack costs.
if(value > new_crate.get_cost())
TEST_FAIL("Cargo crate [new_crate.type] had a sale value of [value], Selling for more than [new_crate.get_cost()], the cost to buy")
// We're selling the crate & it's contents for less than the value of it's own crate, meaning you can buy and infinite number
if(crate_value > new_crate.get_cost())
TEST_FAIL("Cargo crate [new_crate.type] container sells for [crate_value], Selling for more than [new_crate.get_cost()], the cost to buy")
for(var/atom/stuff as anything in results.contents)
qdel(stuff)
stuff = null
qdel(results)
results = null
new_crate = null
minimum_cost = null
export_log = null