mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 20:20:33 +01:00
Merge branch 'master' of https://github.com/tgstation/tgstation into upstream-sync
This commit is contained in:
@@ -228,6 +228,7 @@
|
||||
#include "movement_order_sanity.dm"
|
||||
#include "mutant_hands_consistency.dm"
|
||||
#include "mutant_organs.dm"
|
||||
#include "neurine_trauma_cleanup.dm"
|
||||
#include "novaflower_burn.dm"
|
||||
#include "nuke_cinematic.dm"
|
||||
#include "omnitools.dm"
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
* they aren't the same type so everything that works with one isn't guaranteed to work with the other.
|
||||
*/
|
||||
/datum/unit_test/hydroponics_harvest/Run()
|
||||
var/obj/machinery/hydroponics/hydroponics_tray = allocate(/obj/machinery/hydroponics)
|
||||
var/obj/machinery/hydroponics/soil/testing_soil = allocate(/obj/machinery/hydroponics/soil)
|
||||
var/obj/item/seeds/planted_food_seed = allocate(/obj/item/seeds/apple) //grown food
|
||||
var/obj/item/seeds/planted_not_food_seed = allocate(/obj/item/seeds/sunflower) //grown inedible
|
||||
var/obj/item/seeds/planted_densified_seed = allocate(/obj/item/seeds/redbeet) //grown + densified chemicals
|
||||
|
||||
var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human/consistent)
|
||||
|
||||
hydroponics_tray.forceMove(run_loc_floor_bottom_left)
|
||||
testing_soil.forceMove(run_loc_floor_bottom_left)
|
||||
|
||||
var/nearby_loc = locate((run_loc_floor_bottom_left.x + 1), run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)
|
||||
human.forceMove(nearby_loc)
|
||||
@@ -38,11 +38,11 @@
|
||||
planted_densified_seed.forceMove(seeds_loc)
|
||||
|
||||
// Apples should harvest 10 apples with 10u nutrients and 4u vitamins.
|
||||
test_seed(hydroponics_tray, planted_food_seed, human)
|
||||
test_seed(testing_soil, planted_food_seed, human)
|
||||
// Sunflowers should harvest 10 sunflowers with 4u nutriment and 0u vitamins. It should also have 8u oil.
|
||||
test_seed(hydroponics_tray, planted_not_food_seed, human)
|
||||
test_seed(testing_soil, planted_not_food_seed, human)
|
||||
// Redbeets should harvest 5 beets (10 / 2) with 10u nutriments (5 x 2) and 10u vitamins (5 x 2) thanks to densified chemicals.
|
||||
test_seed(hydroponics_tray, planted_densified_seed, human)
|
||||
test_seed(testing_soil, planted_densified_seed, human)
|
||||
|
||||
/datum/unit_test/hydroponics_harvest/proc/plant_and_update_seed(obj/machinery/hydroponics/tray, obj/item/seeds/seed)
|
||||
seed.set_yield(10) // Sets the seed yield to 10. This gets clamped to 5 if the plant has traits to half the yield.
|
||||
@@ -92,10 +92,11 @@
|
||||
|
||||
var/found_nutriments = all_harvested_items[1].reagents.get_reagent_amount(/datum/reagent/consumable/nutriment)
|
||||
var/found_vitamins = all_harvested_items[1].reagents.get_reagent_amount(/datum/reagent/consumable/nutriment/vitamin)
|
||||
|
||||
QDEL_LIST(all_harvested_items) //We got everything we needed from our harvest, we can clean it up.
|
||||
|
||||
TEST_ASSERT_EQUAL(found_nutriments, expected_nutriments * max_volume, "Hydroponics harvest from [saved_name] has a [expected_nutriments] nutriment gene (expecting [expected_nutriments * max_volume]) but only had [found_nutriments] units of nutriment inside.")
|
||||
TEST_ASSERT_EQUAL(found_vitamins, expected_vitamins * max_volume, "Hydroponics harvest from [saved_name] has a [expected_vitamins] vitamin gene (expecting [expected_nutriments * max_volume]) but only had [found_vitamins] units of vitamins inside.")
|
||||
TEST_ASSERT_EQUAL(found_vitamins, expected_vitamins * max_volume, "Hydroponics harvest from [saved_name] has a [expected_vitamins] vitamin gene (expecting [expected_vitamins * max_volume]) but only had [found_vitamins] units of vitamins inside.")
|
||||
|
||||
if(tray.myseed)
|
||||
tray.age = 0
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/// Tests that neurine reagent properly creates and cleans up temporary traumas
|
||||
/datum/unit_test/neurine_trauma_cleanup
|
||||
|
||||
/datum/unit_test/neurine_trauma_cleanup/Run()
|
||||
var/mob/living/carbon/human/dummy = allocate(/mob/living/carbon/human/consistent)
|
||||
dummy.mind_initialize()
|
||||
|
||||
// Create neurine reagent
|
||||
var/datum/reagent/inverse/neurine/neurine_reagent = new()
|
||||
|
||||
// Ensure the dummy has a brain
|
||||
var/obj/item/organ/brain/brain = dummy.get_organ_slot(ORGAN_SLOT_BRAIN)
|
||||
TEST_ASSERT(brain, "Test dummy should have a brain")
|
||||
|
||||
// Get initial trauma count
|
||||
var/initial_trauma_count = length(brain.traumas)
|
||||
|
||||
// Trigger neurine to add a trauma (simulate on_mob_life)
|
||||
// We need to ensure it creates a trauma by setting high purity
|
||||
neurine_reagent.creation_purity = 10 // This ensures SPT_PROB(creation_purity*10) will be 100%
|
||||
neurine_reagent.on_mob_life(dummy, 1, 1)
|
||||
|
||||
// Check that a trauma was added
|
||||
var/post_add_trauma_count = length(brain.traumas)
|
||||
TEST_ASSERT(post_add_trauma_count == initial_trauma_count + 1, "Neurine should have added exactly one trauma")
|
||||
TEST_ASSERT(neurine_reagent.temp_trauma, "Neurine should have stored a reference to the trauma it created")
|
||||
|
||||
// Verify the trauma is actually there and has the right resilience
|
||||
var/datum/brain_trauma/added_trauma = neurine_reagent.temp_trauma
|
||||
TEST_ASSERT(added_trauma in brain.traumas, "The trauma stored in temp_trauma should be in the brain's trauma list")
|
||||
TEST_ASSERT(added_trauma.resilience == TRAUMA_RESILIENCE_MAGIC, "Neurine-created trauma should have TRAUMA_RESILIENCE_MAGIC")
|
||||
|
||||
// Now simulate the reagent being deleted (on_mob_delete)
|
||||
neurine_reagent.on_mob_delete(dummy)
|
||||
|
||||
// Check that the trauma was properly removed
|
||||
var/post_delete_trauma_count = length(brain.traumas)
|
||||
TEST_ASSERT(post_delete_trauma_count == initial_trauma_count, "Neurine trauma should have been removed when reagent was deleted")
|
||||
TEST_ASSERT(!neurine_reagent.temp_trauma, "Neurine should have cleared its temp_trauma reference")
|
||||
TEST_ASSERT(!(added_trauma in brain.traumas), "The specific trauma should no longer be in the brain's trauma list")
|
||||
|
||||
// Test special case: imaginary friend should NOT be removed
|
||||
var/datum/brain_trauma/special/imaginary_friend/friend_trauma = new()
|
||||
brain.add_trauma_to_traumas(friend_trauma)
|
||||
friend_trauma.owner = dummy
|
||||
friend_trauma.resilience = TRAUMA_RESILIENCE_MAGIC
|
||||
neurine_reagent.temp_trauma = friend_trauma
|
||||
|
||||
var/pre_friend_test_count = length(brain.traumas)
|
||||
neurine_reagent.on_mob_delete(dummy)
|
||||
|
||||
// Imaginary friend should still be there
|
||||
TEST_ASSERT(length(brain.traumas) == pre_friend_test_count, "Imaginary friend trauma should not be removed by neurine cleanup")
|
||||
TEST_ASSERT(friend_trauma in brain.traumas, "Imaginary friend should still be in trauma list")
|
||||
|
||||
// Clean up for next test
|
||||
qdel(friend_trauma)
|
||||
qdel(neurine_reagent)
|
||||
Reference in New Issue
Block a user