Implement NPC perception, returning trespassers, responder dispatch, wand screening, and accessibility polish
CI / headless-tests (push) Successful in 2m11s

This commit is contained in:
zwitschi committed 2026-10-31 12:31:13 +01:00
1 parent 439e0a4281
commit 81b5d5ce5a
22 files changed
+879 -73

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
extends RefCounted
## Headless tests for the handheld wand screening logic (PLAN.md: The Joke Shop).
const WandScreener := preload("res://src/core/wand_screener.gd")
func test_wand_detects_prohibited_item() -> bool:
var screener := WandScreener.new()
var result: Dictionary = screener.screen(["keys", "weapon"])
var a := TestUtils.check(result["alert"], "alert raised")
var b := TestUtils.check(result["prohibited"], "prohibited flagged")
var c := TestUtils.check_eq(result["item"], "weapon", "weapon identified")
return a and b and c
func test_wand_false_alarm() -> bool:
var screener := WandScreener.new()
var result: Dictionary = screener.screen(["keys", "phone"])
var a := TestUtils.check(result["alert"], "alert raised")
var b := TestUtils.check(result["false_alarm"], "false alarm flagged")
var c := TestUtils.check(not result["prohibited"], "not prohibited")
return a and b and c
func test_wand_clear() -> bool:
var screener := WandScreener.new()
var result: Dictionary = screener.screen([])
var a := TestUtils.check(not result["alert"], "no alert")
var b := TestUtils.check(not result["prohibited"], "not prohibited")
var c := TestUtils.check(not result["false_alarm"], "not false alarm")
return a and b and c
func test_wand_prohibited_takes_priority() -> bool:
var screener := WandScreener.new()
# A weapon plus a harmless item: prohibited wins.
var result: Dictionary = screener.screen(["keys", "knife"])
return TestUtils.check(result["prohibited"], "prohibited wins over false alarm")
func test_wand_decision_correctness() -> bool:
var screener := WandScreener.new()
var prohibited := screener.screen(["weapon"])
var a := TestUtils.check(not screener.decide(prohibited, true)["correct"], "admitting prohibited item is wrong")
var b := TestUtils.check(screener.decide(prohibited, false)["correct"], "refusing prohibited item is correct")
var clean := screener.screen([])
var c := TestUtils.check(screener.decide(clean, true)["correct"], "admitting clean guest is correct")
var d := TestUtils.check(not screener.decide(clean, false)["correct"], "refusing clean guest is wrong")
return a and b and c and d
func test_classify_item() -> bool:
var a := TestUtils.check_eq(WandScreener.classify_item("gun"), "prohibited", "gun prohibited")
var b := TestUtils.check_eq(WandScreener.classify_item("belt"), "false_alarm", "belt false alarm")
var c := TestUtils.check_eq(WandScreener.classify_item("wallet"), "clear", "wallet clear")
return a and b and c