Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more tests
Browse files Browse the repository at this point in the history
warriorstar-orion committed Jan 18, 2025
1 parent 67b5fe8 commit 5ce8c3f
Showing 4 changed files with 75 additions and 10 deletions.
2 changes: 1 addition & 1 deletion code/_compile_options.dm
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
//#define TESTING

// Uncomment the following line to compile unit tests on a local server. The output will be in a test_run-[DATE].log file in the ./data folder.
#define LOCAL_GAME_TESTS
// #define LOCAL_GAME_TESTS

// Uncomment the following line to enable Tracy profiling.
// DO NOT DO THIS UNLESS YOU UNDERSTAND THE IMPLICATIONS
10 changes: 10 additions & 0 deletions code/game/objects/items/weapons/stock_parts.dm
Original file line number Diff line number Diff line change
@@ -60,6 +60,16 @@
playsound(src, 'sound/machines/synth_no.ogg', 15, TRUE)
to_chat(user, "<span class='notice'>ERROR: [M] is out of [src]'s range!</span>")

/obj/item/storage/part_replacer/tier4/populate_contents()
for(var/amount in 1 to 30)
new /obj/item/stock_parts/capacitor/quadratic(src)
new /obj/item/stock_parts/manipulator/femto(src)
new /obj/item/stock_parts/matter_bin/bluespace(src)
new /obj/item/stock_parts/micro_laser/quadultra(src)
new /obj/item/stock_parts/scanning_module/triphasic(src)
new /obj/item/stock_parts/cell/bluespace(src)
new /obj/item/reagent_containers/glass/beaker/bluespace(src)

////////////////////////////////////////
// Bluespace Part Replacer
////////////////////////////////////////
25 changes: 24 additions & 1 deletion code/tests/_game_test_puppeteer.dm
Original file line number Diff line number Diff line change
@@ -50,12 +50,13 @@

/datum/test_puppeteer/proc/click_on(target, params)
var/datum/test_puppeteer/puppet_target = target
sleep(max(puppet.next_click, puppet.next_move) - world.time + 1)
if(istype(puppet_target))
puppet.ClickOn(puppet_target.puppet, params)
return

puppet.ClickOn(target, params)
puppet.next_click = world.time
puppet.next_move = world.time

/datum/test_puppeteer/proc/spawn_mob_nearby(mob_type)
for(var/turf/T in RANGE_TURFS(1, puppet))
@@ -105,3 +106,25 @@
for(var/atom/A in T.contents)
if(istype(A, atom_type))
return A

// No we don't technically need to put these things into an actual backpack and
// so forth, we could just leave them lying around and teleport them to the
// player but this keeps things realistic and may surface issues we wouldn't
// think to test for.
/datum/test_puppeteer/proc/put_away(obj/object)
if(!puppet.back)
puppet.equip_to_appropriate_slot(new/obj/item/storage/backpack)

var/obj/item/storage/backpack = puppet.back
backpack.handle_item_insertion(object, puppet)

/datum/test_puppeteer/proc/retrieve(obj/object)
if(!puppet.back)
return

var/obj/item/storage/backpack = puppet.back
if(!(object in backpack.contents))
return

backpack.remove_item_from_storage(object)
puppet.put_in_active_hand(object)
48 changes: 40 additions & 8 deletions code/tests/attack_chain/test_attack_chain_machinery.dm
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
var/obj/screwdriver = player.spawn_obj_in_hand(/obj/item/screwdriver)
player.click_on(scanner)
TEST_ASSERT_LAST_CHATLOG(player, "You open the maintenance hatch")
qdel(screwdriver)
player.put_away(screwdriver)

// Abductor console
var/obj/abductor_console = teleport_to_first(player, /obj/machinery/abductor/console)
@@ -43,34 +43,66 @@
player.set_intent("harm")
player.click_on(abductor_console)
TEST_ASSERT_LAST_CHATLOG(player, "You hit Abductor console with the welding tool!")
qdel(welder)
player.set_intent("help")
player.put_away(welder)

// Abductor replacement organ storage
var/obj/machinery/abductor/gland_dispenser/dispenser = teleport_to_first(player, /obj/machinery/abductor/gland_dispenser)
var/obj/gland = player.spawn_obj_in_hand(/obj/item/organ/internal/heart/gland)
player.click_on(dispenser)
TEST_ASSERT(gland in dispenser.contents, "did not place gland in dispenser")

// Autolathe
var/obj/autolathe = teleport_to_first(player, /obj/machinery/autolathe)
var/obj/design_disk = player.spawn_obj_in_hand(/obj/item/disk/design_disk/golem_shell)
player.click_on(autolathe)
TEST_ASSERT_LAST_CHATLOG(player, "You begin to load a design")
qdel(design_disk)
player.retrieve(screwdriver)
player.click_on(autolathe)
TEST_ASSERT_LAST_CHATLOG(player, "You open the maintenance hatch")
player.put_away(screwdriver)
player.spawn_obj_in_hand(/obj/item/storage/part_replacer/tier4)
player.click_on(autolathe)
TEST_ASSERT_LAST_CHATLOG(player, "micro-manipulator replaced with femto-manipulator")

var/obj/nuke = teleport_to_first(player, /obj/machinery/nuclearbomb/undeployed)
var/obj/disk = player.spawn_obj_in_hand(/obj/item/disk/nuclear)
var/obj/machinery/nuclearbomb/nuke = teleport_to_first(player, /obj/machinery/nuclearbomb/undeployed)
var/obj/disk = player.spawn_obj_in_hand(/obj/item/disk/nuclear/unrestricted)
player.click_on(nuke)
TEST_ASSERT_LAST_CHATLOG(player, "You need to deploy")
nuke.ui_act("deploy")
nuke.extended = TRUE
player.click_on(nuke)
TEST_ASSERT(disk in nuke.contents, "Disk not inserted into nuke")
screwdriver = player.spawn_obj_in_hand(/obj/item/screwdriver)
player.retrieve(screwdriver)
player.click_on(nuke)
TEST_ASSERT_LAST_CHATLOG(player, "You unscrew the control panel")
player.put_away(screwdriver)

var/obj/camera = teleport_to_first(player, /obj/machinery/camera)
player.retrieve(screwdriver)
player.click_on(camera) // with screwdriver
TEST_ASSERT_LAST_CHATLOG(player, "panel open")
qdel(screwdriver)
player.put_away(screwdriver)
player.spawn_obj_in_hand(/obj/item/stack/sheet/mineral/plasma)
player.click_on(camera)
TEST_ASSERT_LAST_CHATLOG(player, "You attach the stack of plasma")
TEST_ASSERT_LAST_CHATLOG(player, "You attach the solid plasma")
var/obj/knife = player.spawn_obj_in_hand(/obj/item/kitchen/knife)
player.set_intent("harm")
player.click_on(camera)
TEST_ASSERT_LAST_CHATLOG(player, "You hit the security camera with the kitchen knife")
player.set_intent("help")
qdel(knife)

var/obj/chem_dispenser = teleport_to_first(player, /obj/machinery/chem_dispenser)
player.retrieve(screwdriver)
player.click_on(chem_dispenser)
TEST_ASSERT_LAST_CHATLOG(player, "You open the maintenance hatch")
player.puppet.swap_hand()
player.spawn_obj_in_hand(/obj/item/reagent_containers/glass/beaker)
player.click_on(chem_dispenser)
TEST_ASSERT_LAST_CHATLOG(player, "Close the maintenance panel first")
player.puppet.swap_hand()
player.click_on(chem_dispenser)
player.puppet.swap_hand()
player.click_on(chem_dispenser)
TEST_ASSERT_LAST_CHATLOG(player, "You set the beaker on the machine")

0 comments on commit 5ce8c3f

Please sign in to comment.