Merge pull request #52433 from Jared-Fogle/metabolization-tests

Add unit tests for metabolizing of all reagents and fix the ones that failed
This commit is contained in:
ShizCalev
2020-07-24 22:30:03 -04:00
committed by GitHub
7 changed files with 34 additions and 14 deletions
+1 -1
View File
@@ -497,7 +497,7 @@
if(T)
T.add_vomit_floor(src, VOMIT_TOXIC, purge)//toxic barf looks different || call purge when doing detoxicfication to pump more chems out of the stomach.
T = get_step(T, dir)
if (is_blocked_turf(T))
if (T != null && is_blocked_turf(T))
break
return TRUE
@@ -103,7 +103,7 @@ All effects don't start immediately, but rather get worse over time; the rate is
taste_description = "dish water"
glass_name = "glass of light beer"
glass_desc = "A freezing pint of watery light beer."
/datum/reagent/consumable/ethanol/beer/maltliquor
name = "Malt Liquor"
description = "An alcoholic beverage brewed since ancient times on Old Earth. This variety is stronger than usual, super cheap, and super terrible."
@@ -683,14 +683,14 @@ All effects don't start immediately, but rather get worse over time; the rate is
/datum/reagent/consumable/ethanol/beepsky_smash/on_mob_metabolize(mob/living/carbon/M)
if(HAS_TRAIT(M, TRAIT_ALCOHOL_TOLERANCE))
metabolization_rate = 0.8
if(!HAS_TRAIT(M.mind, TRAIT_LAW_ENFORCEMENT_METABOLISM))
if(M.mind != null && !HAS_TRAIT(M.mind, TRAIT_LAW_ENFORCEMENT_METABOLISM))
B = new()
M.gain_trauma(B, TRAUMA_RESILIENCE_ABSOLUTE)
..()
/datum/reagent/consumable/ethanol/beepsky_smash/on_mob_life(mob/living/carbon/M)
M.Jitter(2)
if(HAS_TRAIT(M.mind, TRAIT_LAW_ENFORCEMENT_METABOLISM))
if(M.mind != null && HAS_TRAIT(M.mind, TRAIT_LAW_ENFORCEMENT_METABOLISM))
M.adjustStaminaLoss(-10, 0)
if(prob(20))
new /datum/hallucination/items_other(M)
@@ -705,7 +705,7 @@ All effects don't start immediately, but rather get worse over time; the rate is
return ..()
/datum/reagent/consumable/ethanol/beepsky_smash/overdose_start(mob/living/carbon/M)
if(!HAS_TRAIT(M.mind, TRAIT_LAW_ENFORCEMENT_METABOLISM))
if(M.mind != null && !HAS_TRAIT(M.mind, TRAIT_LAW_ENFORCEMENT_METABOLISM))
M.gain_trauma(/datum/brain_trauma/mild/phobia/security, TRAUMA_RESILIENCE_BASIC)
/datum/reagent/consumable/ethanol/irish_cream
@@ -1521,7 +1521,7 @@ All effects don't start immediately, but rather get worse over time; the rate is
/datum/reagent/consumable/ethanol/quadruple_sec/on_mob_life(mob/living/carbon/M)
//Securidrink in line with the Screwdriver for engineers or Nothing for mimes
if(HAS_TRAIT(M.mind, TRAIT_LAW_ENFORCEMENT_METABOLISM))
if(M.mind != null && HAS_TRAIT(M.mind, TRAIT_LAW_ENFORCEMENT_METABOLISM))
M.heal_bodypart_damage(1, 1)
M.adjustBruteLoss(-2,0)
. = 1
@@ -1540,7 +1540,7 @@ All effects don't start immediately, but rather get worse over time; the rate is
/datum/reagent/consumable/ethanol/quintuple_sec/on_mob_life(mob/living/carbon/M)
//Securidrink in line with the Screwdriver for engineers or Nothing for mimes but STRONG..
if(HAS_TRAIT(M.mind, TRAIT_LAW_ENFORCEMENT_METABOLISM))
if(M.mind != null && HAS_TRAIT(M.mind, TRAIT_LAW_ENFORCEMENT_METABOLISM))
M.heal_bodypart_damage(2,2,2)
M.adjustBruteLoss(-5,0)
M.adjustOxyLoss(-5,0)
@@ -2154,7 +2154,7 @@ All effects don't start immediately, but rather get worse over time; the rate is
glass_desc = "boozy Catholicism in a glass."
/datum/reagent/consumable/ethanol/trappist/on_mob_life(mob/living/carbon/M)
if(M.mind.holy_role)
if(M.mind?.holy_role)
M.adjustFireLoss(-2.5, 0)
M.jitteriness = max(0, M.jitteriness-1)
M.stuttering = max(0, M.stuttering-1)
@@ -544,7 +544,7 @@
/datum/reagent/consumable/pwr_game/on_mob_life(mob/living/carbon/M)
M.adjust_bodytemperature(-8 * TEMPERATURE_DAMAGE_COEFFICIENT, M.get_body_temp_normal())
if(prob(10))
M?.mind.adjust_experience(/datum/skill/gaming, 5)
M.mind?.adjust_experience(/datum/skill/gaming, 5)
..()
/datum/reagent/consumable/shamblers
@@ -418,7 +418,7 @@
/datum/reagent/drug/happiness/addiction_act_stage1(mob/living/M)// all work and no play makes jack a dull boy
var/datum/component/mood/mood = M.GetComponent(/datum/component/mood)
mood.setSanity(min(mood.sanity, SANITY_DISTURBED))
mood?.setSanity(min(mood.sanity, SANITY_DISTURBED))
M.Jitter(5)
if(prob(20))
M.emote(pick("twitch","laugh","frown"))
@@ -426,7 +426,7 @@
/datum/reagent/drug/happiness/addiction_act_stage2(mob/living/M)
var/datum/component/mood/mood = M.GetComponent(/datum/component/mood)
mood.setSanity(min(mood.sanity, SANITY_UNSTABLE))
mood?.setSanity(min(mood.sanity, SANITY_UNSTABLE))
M.Jitter(10)
if(prob(30))
M.emote(pick("twitch","laugh","frown"))
@@ -434,7 +434,7 @@
/datum/reagent/drug/happiness/addiction_act_stage3(mob/living/M)
var/datum/component/mood/mood = M.GetComponent(/datum/component/mood)
mood.setSanity(min(mood.sanity, SANITY_CRAZY))
mood?.setSanity(min(mood.sanity, SANITY_CRAZY))
M.Jitter(15)
if(prob(40))
M.emote(pick("twitch","laugh","frown"))
@@ -442,7 +442,7 @@
/datum/reagent/drug/happiness/addiction_act_stage4(mob/living/carbon/human/M)
var/datum/component/mood/mood = M.GetComponent(/datum/component/mood)
mood.setSanity(SANITY_INSANE)
mood?.setSanity(SANITY_INSANE)
M.Jitter(20)
if(prob(50))
M.emote(pick("twitch","laugh","frown"))
@@ -1218,7 +1218,7 @@
M.confused = max(0, M.confused-6)
M.disgust = max(0, M.disgust-6)
var/datum/component/mood/mood = M.GetComponent(/datum/component/mood)
if(mood.sanity <= SANITY_NEUTRAL) // only take effect if in negative sanity and then...
if(mood != null && mood.sanity <= SANITY_NEUTRAL) // only take effect if in negative sanity and then...
mood.setSanity(min(mood.sanity+5, SANITY_NEUTRAL)) // set minimum to prevent unwanted spiking over neutral
..()
. = 1
+1
View File
@@ -16,6 +16,7 @@
#include "chain_pull_through_space.dm"
#include "component_tests.dm"
#include "keybinding_init.dm"
#include "metabolizing.dm"
#include "outfit_sanity.dm"
#include "plantgrowth_tests.dm"
#include "reagent_id_typos.dm"
+19
View File
@@ -0,0 +1,19 @@
/datum/unit_test/metabolization/Run()
// Pause natural mob life so it can be handled entirely by the test
SSmobs.pause()
var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human)
var/mob/living/carbon/monkey/monkey = allocate(/mob/living/carbon/monkey)
for (var/reagent_type in subtypesof(/datum/reagent))
test_reagent(human, reagent_type)
test_reagent(monkey, reagent_type)
/datum/unit_test/metabolization/proc/test_reagent(mob/living/carbon/C, reagent_type)
C.reagents.add_reagent(reagent_type, 10)
C.reagents.metabolize(C, can_overdose = TRUE)
C.reagents.clear_reagents()
/datum/unit_test/metabolization/Destroy()
SSmobs.ignite()
return ..()