extends GutTest const LimbWounds = preload("res://scripts/domain/combat/limb_wounds.gd") const ActorState = preload("res://scripts/domain/actor_state.gd") func test_all_supported_wounds_merge_by_worst_severity_and_duration() -> void: var wounds := LimbWounds.new() for slot in LimbWounds.SLOTS: wounds.apply(slot, 1, 3, "fixture") assert_eq(wounds.active_wounds().size(), 4) wounds.apply(&"arms", 3, 1, "second hit") assert_eq(wounds.severity_at(&"arms"), 3) assert_eq(wounds.duration_at(&"arms"), 3) wounds.apply(&"tail", 3, 8) assert_eq(wounds.severity_at(&"tail"), 0) func test_wounds_passively_recover_and_report_recovered_slot() -> void: var wounds := LimbWounds.new() wounds.apply(&"legs", 2, 2) assert_eq(wounds.tick(), []) assert_eq(wounds.duration_at(&"legs"), 1) assert_eq(wounds.tick(), [&"legs"]) assert_eq(wounds.severity_at(&"legs"), 0) func test_round_trip_preserves_wound_state() -> void: var wounds := LimbWounds.new() wounds.apply(&"head", 2, 7, "goblin") var restored := LimbWounds.from_dictionary(wounds.to_dictionary()) assert_eq(restored.severity_at(&"head"), 2) assert_eq(restored.duration_at(&"head"), 7) assert_eq(restored.source_at(&"head"), "goblin") func test_head_and_torso_wounds_reduce_perception_and_maximum_health() -> void: var actor := ActorState.new(&"player", Vector2i.ZERO, 20, 3, &"player", {"perception": 10}) actor.wounds.apply(&"head", 2, 8) actor.wounds.apply(&"torso", 2, 8) assert_eq(actor.effective_perception(), 8) assert_eq(actor.effective_max_hit_points(), 18)