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)