diff --git a/module/tests/scripted_spell_effect.rs b/module/tests/scripted_spell_effect.rs index dfd29e1fa..c8ea3da8a 100644 --- a/module/tests/scripted_spell_effect.rs +++ b/module/tests/scripted_spell_effect.rs @@ -41,7 +41,7 @@ fn an_enabled_scripted_effect_heals_the_resolved_target_and_credits_xp_to_the_ca let mut standalone = Standalone::start("scripted-effect-heal"); standalone.publish_module(); standalone.assert_call("debug_spawn_player_entity", &[&PLAYER.to_string()]); - prevent_scheduled_rage_decay(&standalone); + prevent_scheduled_regeneration(&standalone, PLAYER); standalone.assert_call("debug_set_power", &[&PLAYER.to_string(), "1000"]); insert_spell( @@ -68,11 +68,9 @@ fn an_enabled_scripted_effect_heals_the_resolved_target_and_credits_xp_to_the_ca ); let wolf = spawn_wolf(&standalone); - // `max_health` is the healed total, not a round number. A creature below its maximum regenerates - // on its own schedule, so an exact reading only survives when the heal fills the bar. A heal that - // never lands still fails here, because regeneration needs many passes to cover 15. + prevent_scheduled_regeneration(&standalone, wolf); standalone.assert_sql(&format!( - "UPDATE game_world_entity SET health = 50, max_health = 65 WHERE guid = {wolf}" + "UPDATE game_world_entity SET health = 50, max_health = 1000 WHERE guid = {wolf}" )); let xp_before = xp(&standalone, PLAYER); @@ -128,6 +126,7 @@ fn a_scripted_effect_with_script_id_zero_stays_the_vanilla_no_op() { ); let wolf = spawn_wolf(&standalone); + prevent_scheduled_regeneration(&standalone, wolf); standalone.assert_sql(&format!( "UPDATE game_world_entity SET health = 50, max_health = 1000 WHERE guid = {wolf}" )); @@ -159,7 +158,7 @@ fn a_missing_or_disabled_script_refuses_the_cast_before_any_cost_is_spent() { let mut standalone = Standalone::start("scripted-effect-gate"); standalone.publish_module(); standalone.assert_call("debug_spawn_player_entity", &[&PLAYER.to_string()]); - prevent_scheduled_rage_decay(&standalone); + prevent_scheduled_regeneration(&standalone, PLAYER); standalone.assert_call("debug_set_power", &[&PLAYER.to_string(), "1000"]); insert_spell( @@ -288,18 +287,14 @@ fn a_failing_scripted_effect_discards_only_its_own_staged_effects() { // Two calls, not one: the first buys headroom (`debug_set_power` raises `max_power` to meet // whatever it is told), the second sets the floor comfortably under that ceiling so the // effect's +50 below can never clamp against it. - prevent_scheduled_rage_decay(&standalone); + prevent_scheduled_regeneration(&standalone, PLAYER); standalone.assert_call("debug_set_power", &[&PLAYER.to_string(), "1000"]); standalone.assert_call("debug_set_power", &[&PLAYER.to_string(), "800"]); const FLOOR: u32 = 800; let wolf = spawn_wolf(&standalone); - // Keep this fixture in combat past the test deadline. Ordinary in-combat creatures do not - // regenerate health, so any change from 100 came from the failed Invocation. + prevent_scheduled_regeneration(&standalone, wolf); standalone.assert_sql(&format!( - "UPDATE game_world_entity SET health = 100, max_health = 100000, \ - unit_flags = {}, combat_until_ms = {} WHERE guid = {wolf}", - unit_flags::IN_COMBAT, - u64::MAX, + "UPDATE game_world_entity SET health = 100, max_health = 100000 WHERE guid = {wolf}", )); standalone.assert_call( @@ -399,15 +394,14 @@ fn power(standalone: &Standalone, guid: u64) -> u32 { .expect("power is a number") } -/// These tests assign a Warrior's Rage so they can observe only the spell's power change. Keep the -/// Character in combat beyond the fixture deadline so the unrelated regeneration pass cannot decay -/// that Rage while the test publishes scripts and spells. -fn prevent_scheduled_rage_decay(standalone: &Standalone) { - let flags = entity(standalone, PLAYER)["unit_flags"] +/// Keep an entity in combat beyond the fixture deadline so scheduled regeneration cannot change an +/// exact health or power observation. +fn prevent_scheduled_regeneration(standalone: &Standalone, guid: u64) { + let flags = entity(standalone, guid)["unit_flags"] .parse::() .expect("unit flags are a number"); standalone.assert_sql(&format!( - "UPDATE game_world_entity SET unit_flags = {}, combat_until_ms = {} WHERE guid = {PLAYER}", + "UPDATE game_world_entity SET unit_flags = {}, combat_until_ms = {} WHERE guid = {guid}", flags | unit_flags::IN_COMBAT, u64::MAX, ));