mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-10 08:54:15 +00:00
* PT1 MAP RESET * Lints * [MDB Ignore] Adds a unit test for typepaths that are required to be mapped onto each station map (#74985) Inspired by #74967 and #68459 , and the fact that Tramstation regresses very often - Adds a unit test, `required_map_items`, which ensures that certain typepaths which should definitely be mapped onto every map is mapped onto every map It can also be used to ensure that items which should not be mapped in multiple times are not, among other things. I included a few examples - - Min 1, max inf of each head of staff stamps - Min 1, max 1 departmental order consoles - Min 1, max inf comms console - Min 1, max 1 Pun Pun - Min 1, max 1 Poly - Min 1, max 1 Ian If, in the future, a mapper decides they (for some reason) do not want a certain previously-required item on their map, the test can be adjusted such that it allows excluding or something, but currently it should be for items which require conscious thought about. I attempted to make this a linter before realizing two things 1. Someone might make a spawner which spawns the items, or they might get placed in a locker, in any case this accounts for everything on init 2. Linters run on every map, non-station maps included So I went with a test Why is it always the CMO stamp? Not necessary (unless I find a map missing something, then this will be updated) * yay * Update VoidRaptor.dmm * Update blackmesa.dmm * wew * New sand and water sprites (ported from Bay) (#75254) * e * Update AntagInfoClock.tsx * Update LimbsPage.tsx * Update area_spawn_entries.dm * Update LimbsPage.tsx --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
63 lines
2.7 KiB
Plaintext
63 lines
2.7 KiB
Plaintext
/**
|
|
* Tests that all expected items are mapped in roundstart.
|
|
*
|
|
* How to add an item to this test:
|
|
* - Add the typepath(s) to setup_expected_types
|
|
* - In the type's initialize, REGISTER_REQUIRED_MAP_ITEM() a minimum and maximum
|
|
*/
|
|
/datum/unit_test/required_map_items
|
|
/// A list of all typepaths that we expect to be in the required items list
|
|
var/list/expected_types = list()
|
|
|
|
/// Used to fill the expected types list with all the types we look for on the map.
|
|
/// This list will just be full of typepaths that we expect.
|
|
/// More detailed information about each item (mainly, how much of each should exist) is set on a per item basis
|
|
/datum/unit_test/required_map_items/proc/setup_expected_types()
|
|
expected_types += subtypesof(/obj/item/stamp/head)
|
|
expected_types += subtypesof(/obj/machinery/computer/department_orders)
|
|
expected_types += /obj/machinery/computer/communications
|
|
expected_types += /mob/living/carbon/human/species/monkey/punpun
|
|
expected_types += /mob/living/basic/pet/dog/corgi/ian
|
|
expected_types += /mob/living/simple_animal/parrot/poly
|
|
|
|
/datum/unit_test/required_map_items/Run()
|
|
setup_expected_types()
|
|
|
|
var/list/required_map_items = GLOB.required_map_items.Copy()
|
|
for(var/got_type in expected_types)
|
|
var/datum/required_item/item = required_map_items[got_type]
|
|
var/items_found = item?.total_amount || 0
|
|
required_map_items -= got_type
|
|
if(items_found <= 0)
|
|
TEST_FAIL("Item [got_type] was not found, but is expected to be mapped in on mapload!")
|
|
continue
|
|
|
|
if(items_found < item.minimum_amount)
|
|
TEST_FAIL("Item [got_type] should have at least [item.minimum_amount] mapped in but only had [items_found] on mapload!")
|
|
continue
|
|
|
|
if(items_found > item.maximum_amount)
|
|
TEST_FAIL("Item [got_type] should have at most [item.maximum_amount] mapped in but had [items_found] on mapload!")
|
|
continue
|
|
|
|
// This primarily serves as a reminder to include the typepath in the expected types list above.
|
|
// However we can easily delete this line in the future if it runs into false positives.
|
|
TEST_ASSERT(length(required_map_items) == 0, "The following paths were found in required map items, but weren't checked: [english_list(required_map_items)]")
|
|
|
|
/// Datum for tracking required map items
|
|
/datum/required_item
|
|
/// Type (exact) being tracked
|
|
var/tracked_type
|
|
/// How many exist in the world
|
|
var/total_amount = 0
|
|
/// Min. amount of this type that should exist roundstart (inclusive)
|
|
var/minimum_amount = 1
|
|
/// Max. amount of this type that should exist roundstart (inclusive)
|
|
var/maximum_amount = 1
|
|
|
|
/datum/required_item/New(tracked_type, minimum_amount = 1, maximum_amount = 1)
|
|
src.tracked_type = tracked_type
|
|
src.minimum_amount = minimum_amount
|
|
src.maximum_amount = maximum_amount
|
|
total_amount += 1
|