mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
Fish sources are more thoroughfully stressed during unit tests. (#86637)
## About The Pull Request The profound fisher component (for both mobs and gloves) as well as the proc responsible for rolling rewards are now being tested too. This is something I've meant to do in a while, #86633 just happened to kick it off now. ## Why It's Good For The Game More tests, fewer mistakes flying under the radar. ## Changelog N/A
This commit is contained in:
@@ -280,15 +280,43 @@
|
||||
growth_rate = 100
|
||||
fish_traits = list() //We don't want to end up applying traits twice on the resulting lobstrosity
|
||||
|
||||
/datum/unit_test/explosive_fishing
|
||||
/datum/unit_test/fish_sources
|
||||
|
||||
/datum/unit_test/explosive_fishing/Run()
|
||||
var/datum/fish_source/source = GLOB.preset_fish_sources[/datum/fish_source/unit_test]
|
||||
/datum/unit_test/fish_sources/Run()
|
||||
var/datum/fish_source/source = GLOB.preset_fish_sources[/datum/fish_source/unit_test_explosive]
|
||||
source.spawn_reward_from_explosion(run_loc_floor_bottom_left, 1)
|
||||
if(source.fish_counts[/obj/item/wrench])
|
||||
TEST_FAIL("The unit test item wasn't removed/spawned from fish_table during 'spawn_reward_from_explosion'.")
|
||||
|
||||
/datum/fish_source/unit_test
|
||||
///From here, we check that the profound_fisher as well as fish source procs for rolling rewards don't fail.
|
||||
source = GLOB.preset_fish_sources[/datum/fish_source/unit_test_profound_fisher]
|
||||
run_loc_floor_bottom_left.AddElement(/datum/element/lazy_fishing_spot, /datum/fish_source/unit_test_profound_fisher)
|
||||
var/mob/living/basic/fisher = allocate(/mob/living/basic)
|
||||
fisher.AddComponent(/datum/component/profound_fisher)
|
||||
fisher.set_combat_mode(FALSE)
|
||||
fisher.melee_attack(run_loc_floor_bottom_left, ignore_cooldown = TRUE)
|
||||
if(source.fish_counts[/obj/item/fish/testdummy] != 1)
|
||||
TEST_FAIL("The unit test profound fisher didn't catch the test fish on a lazy fishing spot (element)")
|
||||
|
||||
///For good measure, let's try it again, but with the component this time, and a human mob and gloves
|
||||
run_loc_floor_bottom_left.RemoveElement(/datum/element/lazy_fishing_spot, /datum/fish_source/unit_test_profound_fisher)
|
||||
var/datum/component/comp = run_loc_floor_bottom_left.AddComponent(/datum/component/fishing_spot, source)
|
||||
var/mob/living/carbon/human/consistent/angler = allocate(/mob/living/carbon/human/consistent)
|
||||
var/obj/item/clothing/gloves/noodling = allocate(/obj/item/clothing/gloves)
|
||||
noodling.AddComponent(/datum/component/profound_fisher)
|
||||
angler.equip_to_slot(noodling, ITEM_SLOT_GLOVES)
|
||||
|
||||
angler.UnarmedAttack(run_loc_floor_bottom_left, proximity_flag = TRUE)
|
||||
if(source.fish_counts[/obj/item/fish/testdummy])
|
||||
TEST_FAIL("The unit test profound fisher didn't catch the test fish on a fishing spot (component)")
|
||||
qdel(comp)
|
||||
|
||||
///As a final test, let's see how it goes with a fish source containing every single fish subtype.
|
||||
comp = run_loc_floor_bottom_left.AddComponent(/datum/component/fishing_spot, GLOB.preset_fish_sources[/datum/fish_source/unit_test_all_fish])
|
||||
fisher.melee_attack(run_loc_floor_bottom_left, ignore_cooldown = TRUE)
|
||||
qdel(comp)
|
||||
|
||||
/datum/fish_source/unit_test_explosive
|
||||
fish_table = list(
|
||||
/obj/item/wrench = 1,
|
||||
/obj/item/screwdriver = INFINITY, //infinite weight, so if fish counts doesn't work as intended, this'll be always picked.
|
||||
@@ -298,6 +326,17 @@
|
||||
/obj/item/screwdriver = 0, //this should never be picked.
|
||||
)
|
||||
|
||||
/datum/fish_source/unit_test_profound_fisher
|
||||
fish_table = list(/obj/item/fish/testdummy = 1)
|
||||
fish_counts = list(/obj/item/fish/testdummy = 2)
|
||||
|
||||
/datum/fish_source/unit_test_all_fish
|
||||
|
||||
/datum/fish_source/unit_test_all_fish/New()
|
||||
for(var/fish_type as anything in subtypesof(/obj/item/fish))
|
||||
fish_table[fish_type] = 10
|
||||
return ..()
|
||||
|
||||
/datum/unit_test/edible_fish
|
||||
|
||||
/datum/unit_test/edible_fish/Run()
|
||||
|
||||
Reference in New Issue
Block a user