From ffeec3087365a44a36582e72c97d7e154fb0939d Mon Sep 17 00:00:00 2001 From: Forrest Date: Mon, 5 Oct 2026 15:20:58 -0400 Subject: [PATCH] Task #12 follow-up: theft alert for a claimed loose animal AlertManager.collect() only raised the THEFT alert for a claimed Status.HOME item; a thief that claimed a loose (Status.LOOSE) animal raised no alert at all. The acceptance criteria call for loose animals to behave per the existing theft rules, and the alert is part of that UX, so treat LOOSE like HOME there too. Added a check to test_targets.gd 's _loose_start confirming a claimed loose animal raises the same THEFT alert as a penned one (same AlertManager pattern test_roster.gd's _alerts uses). Co-Authored-By: Claude Sonnet 5 --- game/scripts/alert_manager.gd | 2 +- game/tests/test_targets.gd | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/game/scripts/alert_manager.gd b/game/scripts/alert_manager.gd index f9daccb..e1a9db2 100644 --- a/game/scripts/alert_manager.gd +++ b/game/scripts/alert_manager.gd @@ -85,7 +85,7 @@ func collect() -> Array[Dictionary]: continue var p := Vector2(enemies.pos_x[d], enemies.pos_z[d]) raw.append(_alert(Kind.ESCAPE, enemies.type[d], loot.category[id], p, _escalation(d, p))) - LootSystem.Status.HOME: + LootSystem.Status.HOME, LootSystem.Status.LOOSE: var d := enemies.resolve_handle(loot.holder[id]) if loot.holder[id] >= 0 else -1 if d >= 0: raw.append(_alert(Kind.THEFT, enemies.type[d], loot.category[id], loot.position_of(id), 0.0)) diff --git a/game/tests/test_targets.gd b/game/tests/test_targets.gd index bd07f51..ab564af 100644 --- a/game/tests/test_targets.gd +++ b/game/tests/test_targets.gd @@ -56,9 +56,10 @@ func run(r: GameTestRunner) -> void: ## Task #12: animals start loose, scattered outside the pen, grazing in place; a thief can still -## claim and steal one (same rule as any theft once it's dropped); the player leads one in with the -## follow-trail mechanic, entering the pen makes it home, and FarmState records it as penned so a -## morning resync keeps it home (and the rest loose) instead of resetting the herd into the pen. +## claim and steal one (raising the same theft alert as for a penned one, and same rule as any +## theft once it's dropped); the player leads one in with the follow-trail mechanic, entering the +## pen makes it home, and FarmState records it as penned so a morning resync keeps it home (and the +## rest loose) instead of resetting the herd into the pen. func _loose_start(r: GameTestRunner) -> void: var farm := (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D r.root.add_child(farm) @@ -99,6 +100,9 @@ func _loose_start(r: GameTestRunner) -> void: var item1 := sim.enemies.target[sim.enemies.resolve_handle(h)] r.check(item1 > 0 and loot.category[item1] == C.ANIMAL and loot.status[item1] == S.LOOSE, "a thief claims a loose animal, not just a penned one") + var am := farm.get_node("Hud/Alerts") as AlertManager + var theft_alerts := am.collect().filter(func(a: Dictionary) -> bool: return a["kind"] == AlertManager.Kind.THEFT and int(a["category"]) == C.ANIMAL) + r.check(not theft_alerts.is_empty(), "claiming a loose animal raises the same theft alert as a penned one") var caught := _until(sim, func() -> bool: return loot.status[item1] == S.CARRIED, 60.0) r.check(caught < 60.0, "and catches it (%.1f s)" % caught) var dh := sim.enemies.resolve_handle(h)