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:
Ghom
2024-09-15 13:49:48 +00:00
committed by GitHub
parent 5409570e01
commit 00e2f6cd7b
4 changed files with 62 additions and 19 deletions
+1
View File
@@ -24,6 +24,7 @@
/datum/component/fishing_spot/Destroy()
fish_source.on_fishing_spot_del(src)
fish_source = null
REMOVE_TRAIT(parent, TRAIT_FISHING_SPOT, REF(src))
return ..()
/datum/component/fishing_spot/proc/handle_cast(datum/source, obj/item/fishing_rod/rod, mob/user)
+16 -13
View File
@@ -64,9 +64,12 @@
/datum/component/profound_fisher/proc/on_unarmed_attack(mob/living/source, atom/attack_target, proximity_flag, list/modifiers)
SIGNAL_HANDLER
if(!source.client || !should_fish_on(source, attack_target))
if(!should_fish_on(source, attack_target))
return
INVOKE_ASYNC(src, PROC_REF(begin_fishing), source, attack_target)
if(source.client)
INVOKE_ASYNC(src, PROC_REF(begin_fishing), source, attack_target)
else
INVOKE_ASYNC(src, PROC_REF(pretend_fish), source, attack_target)
return COMPONENT_CANCEL_ATTACK_CHAIN
/datum/component/profound_fisher/proc/pre_attack(mob/living/source, atom/target)
@@ -77,7 +80,7 @@
if(source.client)
INVOKE_ASYNC(src, PROC_REF(begin_fishing), source, target)
else
INVOKE_ASYNC(src, PROC_REF(pretend_fish), target)
INVOKE_ASYNC(src, PROC_REF(pretend_fish), source, target)
return COMPONENT_HOSTILE_NO_ATTACK
/datum/component/profound_fisher/proc/should_fish_on(mob/living/user, atom/target)
@@ -102,9 +105,8 @@
REMOVE_TRAIT(source, TRAIT_PROFOUND_FISHER, TRAIT_GENERIC)
UnregisterSignal(source, SIGNAL_REMOVETRAIT(TRAIT_GONE_FISHING))
/datum/component/profound_fisher/proc/pretend_fish(atom/target)
var/mob/living/living_parent = parent
if(DOING_INTERACTION_WITH_TARGET(living_parent, target))
/datum/component/profound_fisher/proc/pretend_fish(mob/living/source, atom/target)
if(DOING_INTERACTION_WITH_TARGET(source, target))
return
var/list/fish_spot_container[NPC_FISHING_SPOT]
SEND_SIGNAL(target, COMSIG_NPC_FISHING, fish_spot_container)
@@ -113,13 +115,14 @@
return null
var/obj/effect/fishing_float/float = new(get_turf(target), target)
playsound(float, 'sound/effects/splash.ogg', 100)
var/happiness_percentage = living_parent.ai_controller?.blackboard[BB_BASIC_HAPPINESS] / 100
var/fishing_speed = 10 SECONDS - round(4 SECONDS * happiness_percentage)
if(!do_after(living_parent, fishing_speed, target = target) && !QDELETED(fish_spot))
qdel(float)
return
var/reward_loot = fish_spot.roll_reward(our_rod, parent)
fish_spot.dispense_reward(reward_loot, parent, target)
if(!PERFORM_ALL_TESTS(fish_sources))
var/happiness_percentage = source.ai_controller?.blackboard[BB_BASIC_HAPPINESS] * 0.01
var/fishing_speed = 10 SECONDS - round(4 SECONDS * happiness_percentage)
if(!do_after(source, fishing_speed, target = target) && !QDELETED(fish_spot))
qdel(float)
return
var/reward_loot = fish_spot.roll_reward(our_rod, source)
fish_spot.dispense_reward(reward_loot, source, target)
playsound(float, 'sound/effects/bigsplash.ogg', 100)
qdel(float)