Files
Bubberstation/code/modules/unit_tests/quirks.dm
MrMelbert e634d66121 Cleans up blood deficiency hardcoding (#82185)
## About The Pull Request

- Dehardcode blood deficiency 
   - Deletes "update mail goodies" 
   - Deletes "updates quirk mail goodies"
- Both of these were only used to update blood deficiency mail goods, we
can just do that with a signal.
   - Deletes hardcoded "get_quirk / lose_blood" calls
- While you can `get_quirk`, much like you can `GetComponent` generally
speaking it's much cleaner to do it via signals.
      - In this case I added a signal to `handle_blood`. 
- And by adding this signal we can do similar dehardcoding for
jellypeople, removing their `spec_life` and running it off the signal.

## Why It's Good For The Game

Ye olde "consistency and cleaner code". And probably a tiny but of
optimization to be yeeked out of it since we don't need to iterate over
a mob's quirk list every life tick, nor every time we change specieses.
But that's probably not even a drop in the bucket so not even worth
mentioning.

Blood defi still happens in sync with Life (as noted by the comment).

## Changelog

🆑 Melbert
refactor: Blood deficiency and slimepeople now handle blood a tiny bit
differently, report any oddities.
refactor: Blood deficiency now handles its mail goods a tiny bit
different, report any oddities.
/🆑
2024-03-24 13:24:23 -06:00

78 lines
3.2 KiB
Plaintext

/// Ensure every quirk has a unique icon
/datum/unit_test/quirk_icons
/datum/unit_test/quirk_icons/Run()
var/list/used_icons = list()
for (var/datum/quirk/quirk_type as anything in subtypesof(/datum/quirk))
if (initial(quirk_type.abstract_parent_type) == quirk_type)
continue
var/icon = initial(quirk_type.icon)
if (isnull(icon))
TEST_FAIL("[quirk_type] has no icon!")
continue
if (icon in used_icons)
TEST_FAIL("[icon] used in both [quirk_type] and [used_icons[icon]]!")
continue
used_icons[icon] = quirk_type
// Make sure all quirks start with a description in medical records
/datum/unit_test/quirk_initial_medical_records
/datum/unit_test/quirk_initial_medical_records/Run()
var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human/consistent)
for(var/datum/quirk/quirk_type as anything in subtypesof(/datum/quirk))
if (initial(quirk_type.abstract_parent_type) == quirk_type)
continue
if(!isnull(quirk_type.medical_record_text))
continue
//Add quirk to a patient - so we can pass quirks that add a medical record after being assigned someone
patient.add_quirk(quirk_type)
var/datum/quirk/quirk = patient.get_quirk(quirk_type)
TEST_ASSERT_NOTNULL(quirk.medical_record_text,"[quirk_type] has no medical record description!")
patient.remove_quirk(quirk_type)
/// Ensures the blood deficiency quirk updates its mail goodies correctly
/datum/unit_test/blood_deficiency_mail
var/list/species_to_test = list(
/datum/species/lizard = /obj/item/reagent_containers/blood/lizard,
/datum/species/ethereal = /obj/item/reagent_containers/blood/ethereal,
/datum/species/skeleton = null, // Anyone with noblood should not get a blood bag
/datum/species/jelly = /obj/item/reagent_containers/blood/toxin,
/datum/species/human = /obj/item/reagent_containers/blood/o_minus,
)
/datum/unit_test/blood_deficiency_mail/Run()
var/mob/living/carbon/human/dummy = allocate(/mob/living/carbon/human/consistent)
dummy.add_quirk(/datum/quirk/blooddeficiency)
var/datum/quirk/blooddeficiency/quirk = dummy.get_quirk(/datum/quirk/blooddeficiency)
TEST_ASSERT((species_to_test[dummy.dna.species.type] in quirk.mail_goodies), "Blood deficiency quirk spawned with no mail goodies!")
for(var/species_type in species_to_test)
var/last_species = dummy.dna.species.type
dummy.set_species(species_type)
// Test that the new species has the correct blood bag
if(!isnull(species_to_test[species_type]))
TEST_ASSERT((species_to_test[species_type] in quirk.mail_goodies), \
"Blood deficiency quirk did not update correctly! ([species_type] did not get its blood bag added)")
TEST_ASSERT_EQUAL(length(quirk.mail_goodies), 1, \
"Blood deficiency quirk got multiple blood bags for [species_type]!")
else
TEST_ASSERT_EQUAL(length(quirk.mail_goodies), 0, \
"Blood deficiency quirk did not have an empty mail goody list for a noblood species!")
// Test that we don't have the old species' blood bag
if(!isnull(species_to_test[last_species]))
TEST_ASSERT(!(species_to_test[last_species] in quirk.mail_goodies), \
"Blood deficiency quirk did not update correctly for [species_type]! ([last_species] did not get its blood bag removed)")