Add ventcrawl unit-test (#24830)

* Add ventcrawl unit-test

* Fix linting

* Solve chair-flipping without HANDS_BLOCKED

* Remove unit_test_dummy variable

* Use `isturf` helper in ventcrawl unit-test

Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>

* Update code/modules/unit_tests/atmos/test_ventcrawl.dm

---------

Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
This commit is contained in:
Zantox
2024-04-30 00:57:36 +00:00
committed by GitHub
co-authored by Ryan DGamerL
parent 3e9c29258e
commit ec2c5638fc
9 changed files with 67 additions and 11 deletions
@@ -49,6 +49,7 @@ SUBSYSTEM_DEF(mapping)
log_startup_progress("We feel like [cave_theme] today...") log_startup_progress("We feel like [cave_theme] today...")
// Load all Z level templates // Load all Z level templates
preloadTemplates() preloadTemplates()
preloadTemplates(path = "code/modules/unit_tests/atmos/")
// Load the station // Load the station
loadStation() loadStation()
@@ -129,7 +129,7 @@
handle_rotation(newdir) handle_rotation(newdir)
/obj/structure/chair/AltClick(mob/user) /obj/structure/chair/AltClick(mob/user)
if(user.stat || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || !Adjacent(user)) if(user.stat || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || !Adjacent(user) || is_ventcrawling(user))
return return
rotate() rotate()
+1 -1
View File
@@ -326,7 +326,7 @@
return T.straight_table_check(direction) return T.straight_table_check(direction)
/obj/structure/table/AltShiftClick(mob/living/carbon/human/user) /obj/structure/table/AltShiftClick(mob/living/carbon/human/user)
if(user.stat || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || !Adjacent(user) || !can_be_flipped) if(user.stat || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || !Adjacent(user) || !can_be_flipped || is_ventcrawling(user))
return return
if(!flipped) if(!flipped)
@@ -500,11 +500,15 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven
visible_message("<span class='notice'>[src] begins climbing into the ventilation system...</span>", \ visible_message("<span class='notice'>[src] begins climbing into the ventilation system...</span>", \
"<span class='notice'>You begin climbing into the ventilation system...</span>") "<span class='notice'>You begin climbing into the ventilation system...</span>")
if(!do_after(src, 4.5 SECONDS, target = src)) #ifdef UNIT_TESTS
return var/ventcrawl_delay = 0 SECONDS
#else
var/ventcrawl_delay = 4.5 SECONDS
if(!client) if(!client)
return return
#endif
if(!do_after(src, ventcrawl_delay, target = src))
return
if(!vent_found.can_crawl_through()) if(!vent_found.can_crawl_through())
to_chat(src, "<span class='warning'>You can't vent crawl through that!</span>") to_chat(src, "<span class='warning'>You can't vent crawl through that!</span>")
@@ -545,7 +549,8 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven
if(!A.pipe_image) if(!A.pipe_image)
A.update_pipe_image() A.update_pipe_image()
pipes_shown += A.pipe_image pipes_shown += A.pipe_image
client.images += A.pipe_image if(client)
client.images += A.pipe_image
/mob/living/proc/remove_ventcrawl() /mob/living/proc/remove_ventcrawl()
if(client) if(client)
@@ -209,7 +209,6 @@
adjustBruteLoss(-3) adjustBruteLoss(-3)
/mob/living/simple_animal/slime/proc/handle_nutrition() /mob/living/simple_animal/slime/proc/handle_nutrition()
if(docile) //God as my witness, I will never go hungry again if(docile) //God as my witness, I will never go hungry again
set_nutrition(700) //fuck you for using the base nutrition var set_nutrition(700) //fuck you for using the base nutrition var
return return
@@ -244,9 +243,6 @@
if(prob(25-powerlevel*5)) if(prob(25-powerlevel*5))
powerlevel++ powerlevel++
/mob/living/simple_animal/slime/proc/handle_targets() /mob/living/simple_animal/slime/proc/handle_targets()
if(Tempstun) if(Tempstun)
if(!buckled) // not while they're eating! if(!buckled) // not while they're eating!
@@ -269,7 +265,7 @@
if(prob(10)) if(prob(10))
Discipline-- Discipline--
if(!client) if(!client && !stop_automated_movement)
if(!(mobility_flags & MOBILITY_MOVE)) if(!(mobility_flags & MOBILITY_MOVE))
return return
@@ -467,3 +467,7 @@
to_chat(src, "<i>I can't vent crawl while feeding...</i>") to_chat(src, "<i>I can't vent crawl while feeding...</i>")
return return
..() ..()
/mob/living/simple_animal/slime/unit_test_dummy
wander = FALSE
stop_automated_movement = TRUE
+1
View File
@@ -2,6 +2,7 @@
//Keep this sorted alphabetically //Keep this sorted alphabetically
#ifdef UNIT_TESTS #ifdef UNIT_TESTS
#include "atmos\test_ventcrawl.dm"
#include "games\test_cards.dm" #include "games\test_cards.dm"
#include "jobs\test_job_globals.dm" #include "jobs\test_job_globals.dm"
#include "aicard_icons.dm" #include "aicard_icons.dm"
@@ -0,0 +1,42 @@
/datum/unit_test/ventcrawl
var/mob/living/simple_animal/slime = null
var/obj/machinery/vent = null
var/obj/structure/table/table = null
/datum/unit_test/ventcrawl/proc/setup_test_area()
var/datum/map_template/template = GLOB.map_templates["test_ventcrawl.dmm"]
if(!template.load(run_loc_bottom_left))
Fail("Failed to load 'test_ventcrawl.dmm'")
slime = new /mob/living/simple_animal/slime/unit_test_dummy(run_loc_bottom_left)
vent = find_spawned_test_object(run_loc_bottom_left, /obj/machinery/atmospherics/unary/vent_pump)
table = find_spawned_test_object(get_step(run_loc_bottom_left, EAST), /obj/structure/table)
/datum/unit_test/ventcrawl/proc/find_spawned_test_object(turf/location as turf, test_object_type)
for(var/content in location.contents)
if(istype(content, test_object_type))
return content
Fail("Couldn't find spawned test object of type: [test_object_type].")
/datum/unit_test/ventcrawl/Run()
setup_test_area()
// Enter vent
vent.AltClick(slime)
if(slime.loc != vent)
Fail("Failed to crawl into vent.")
// Movement
slime.loc.relaymove(slime, EAST)
if(slime.loc == vent)
Fail("Failed to step EAST while wentcrawling.")
// Try to flip table on top of pipe, while inside pipe (shouldn't work)
table.AltShiftClick(slime)
if(table.flipped)
Fail("Shouldn't be possible to flip structures while inside vent.")
// Exit vent
slime.loc.relaymove(slime, EAST)
if(!isturf(slime.loc))
Fail("Wasn't able to ventcrawl out of vent.")
@@ -0,0 +1,7 @@
"a" = (/obj/machinery/atmospherics/unary/vent_pump/on{dir = 4},/turf/simulated/floor,/area/space)
"d" = (/obj/machinery/atmospherics/unary/vent_pump/on{dir = 8},/turf/simulated/floor,/area/space)
"X" = (/obj/machinery/atmospherics/pipe/simple/visible{dir = 4},/obj/structure/table,/turf/simulated/floor,/area/space)
(1,1,1) = {"
aXd
"}