mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 20:20:33 +01:00
## About The Pull Request - infuser entries global is now an assoc list type -> singleton. makes it easier to pick specific entries as needed - separated infusion behavior onto both movable level (for machine occupants and things that can potentially be infused) and human level (for the actual infusion into a human) - [x] tested ## Why It's Good For The Game Upcoming plans is to fix up maintenance sect's organ replacement system that just so happens to work a lot like how infusions do with actual infusion mechanics, and that requires this prerequisite. In general outside of that vision I see a lot of potential in alternate infusion sources, from wherever they may be. ## Changelog no player side changes, this is a refactor
76 lines
4.6 KiB
Plaintext
76 lines
4.6 KiB
Plaintext
/// Checks that all "organ_set_bonus" status effects have unique "id" vars.
|
|
/// Required to ensure that the status effects are treated as "unique".
|
|
/datum/unit_test/organ_set_bonus_id
|
|
|
|
/datum/unit_test/organ_set_bonus_id/Run()
|
|
var/list/bonus_effects = typesof(/datum/status_effect/organ_set_bonus)
|
|
var/list/existing_ids = list()
|
|
for(var/datum/status_effect/organ_set_bonus/bonus_effect as anything in bonus_effects)
|
|
var/effect_id = initial(bonus_effect.id)
|
|
TEST_ASSERT(!(effect_id in existing_ids), "The ID of [bonus_effect] was duplicated in another status effect.")
|
|
existing_ids += effect_id
|
|
|
|
/// Checks that all implantable DNA Infuser organs are set up correctly and without error.
|
|
/// Tests the "organ set bonus" Elements and Status Effects, which are for the DNA Infuser.
|
|
/// This test ensures that the "organ_set_bonus" status effects activate and deactivate when expected.
|
|
/datum/unit_test/organ_set_bonus_sanity
|
|
|
|
/datum/unit_test/organ_set_bonus_sanity/Run()
|
|
/// List of infuser_entry typepaths which contain species-changing organs.
|
|
/// Species change swaps out all the organs, making test_organ un-usable after insertion.
|
|
var/list/species_changing_entries = typecacheof(list(
|
|
/datum/infuser_entry/fly,
|
|
))
|
|
// Fetch the globally instantiated DNA Infuser entries.
|
|
for(var/datum/infuser_entry/infuser_entry as anything in flatten_list(GLOB.infuser_entries))
|
|
var/output_organs = infuser_entry.output_organs
|
|
var/mob/living/carbon/human/lab_rat = allocate(/mob/living/carbon/human/consistent)
|
|
var/list/obj/item/organ/inserted_organs = list()
|
|
|
|
// Attempt to insert entire list of mutant organs for the given infusion_entry.
|
|
for(var/obj/item/organ/organ as anything in output_organs)
|
|
organ = new organ()
|
|
TEST_ASSERT(organ.Insert(lab_rat, special = TRUE, movement_flags = DELETE_IF_REPLACED), "The organ `[organ.type]` for `[infuser_entry.type]` was not inserted in the mob when expected, Insert() returned falsy when TRUE was expected.")
|
|
inserted_organs += organ
|
|
|
|
// Search for added Status Effect.
|
|
var/datum/status_effect/organ_set_bonus/added_status = locate(/datum/status_effect/organ_set_bonus) in lab_rat.status_effects
|
|
|
|
// If threshold_desc is filled-in, it implies the organ_set_bonus Status Effect should be activated.
|
|
// Without it, we'll assume there isn't a Status Effect to look for.
|
|
var/has_threshold = (infuser_entry.threshold_desc != DNA_INFUSION_NO_THRESHOLD)
|
|
// How many organs the Status Effect requires to be inserted before it will activate.
|
|
var/total_organs_needed = added_status?.organs_needed || 0
|
|
// How many organs are available from the infuser entry.
|
|
var/total_organs = length(infuser_entry.output_organs)
|
|
// Quantity of successfully inserted organs.
|
|
var/total_inserted = length(inserted_organs)
|
|
|
|
// If Status Effect exists, ensure it has a matching threshold description and vice versa.
|
|
// Otherwise, ensure both are falsy.
|
|
TEST_ASSERT((added_status && has_threshold) || (!added_status && !has_threshold), "The threshold_desc variable for `[infuser_entry.type]` was an empty string when a description was expected.")
|
|
|
|
if(has_threshold)
|
|
TEST_ASSERT(added_status, "The `/datum/status_effect/organ_set_bonus` for `[infuser_entry.type]` was not added to the mob when expected.")
|
|
TEST_ASSERT(total_organs_needed, "The `needed_organs` variable for `[added_status.type]` should be a positive number.")
|
|
TEST_ASSERT(total_organs_needed <= total_organs, "The `output_organs` list for `[infuser_entry.type]` had a length of `[length(infuser_entry.output_organs)]` when a minimum of at least [total_organs_needed] organs was specified in `[added_status.type]`.")
|
|
TEST_ASSERT(added_status.bonus_active, "The `[added_status.type]` bonus was not activated after inserting [total_inserted] of the [total_organs_needed] required organs in the mob, when it was expected.")
|
|
|
|
// Nothing to do.
|
|
if(total_inserted == 0)
|
|
continue
|
|
|
|
// Bonus of the Fly mutation swaps out all the organs, making it rather permanent.
|
|
// As a result, the inserted_organs list is un-usable by this point.
|
|
if(species_changing_entries[infuser_entry.type])
|
|
continue
|
|
|
|
// Remove all the organs which were just added.
|
|
for(var/obj/item/organ/test_organ as anything in inserted_organs)
|
|
test_organ.Remove(lab_rat, special = TRUE)
|
|
|
|
var/datum/status_effect/organ_set_bonus/removed_status = (locate(/datum/status_effect/organ_set_bonus) in lab_rat.status_effects)
|
|
|
|
// Search for added Status Effect.
|
|
TEST_ASSERT(!removed_status || !added_status.bonus_active, "The `[added_status.type]` bonus was not deactivated after removing [total_inserted] of the [total_organs_needed] required organs from the mob, when it was expected.")
|