Implement control pass: focus cone, action wheel, named inputs, boot fixes
- Venue-correct access artifacts (AccessLoadout) and screened-aware verify - Cone focus on NPC heads with billboarded ring + display name (ADR-0008) - Action wheel with de-escalation-first slices (ADR-0009); Esc/RMB cancel - Procedural NPC face/hair/neck/shoes (ADR-0010); named input actions - Fix GameManager parse error (radial typed as ActionRadial) - Fix first-person camera height and guard spawning inside the building - Move building volume back so the door/awning/marquee are visible - Pull the event scheduler once per simulated second; cap live NPCs - Regenerate README screenshots; update TODO/DONE/MEMORY/README; 77 tests Adds src/test/smoke_focus_radial.gd for the windowed focus/radial smoke.
This commit is contained in:
1 parent
69484866db
commit
f11b441c07
28 files changed
+1433
-249
No files matched your search
@@ -0,0 +1,134 @@
|
||||
extends RefCounted
|
||||
## Venue-correct access artifacts (override_access, no free recognition on guests).
|
||||
|
||||
const Rules := preload("res://src/core/rules.gd")
|
||||
const AccessLoadout := preload("res://src/core/access_loadout.gd")
|
||||
const AccessVerifier := preload("res://src/core/access_verifier.gd")
|
||||
const ScenarioFactory := preload("res://src/content/scenario_factory.gd")
|
||||
const NpcProfile := preload("res://src/core/npc_profile.gd")
|
||||
|
||||
var verifier := AccessVerifier.new()
|
||||
|
||||
func _guest() -> NpcProfile:
|
||||
var p := NpcProfile.new()
|
||||
p.id = "authorized_guest"
|
||||
p.display_name = "Authorized Guest"
|
||||
p.npc_type = Rules.NpcType.AUTHORIZED_GUEST
|
||||
return p
|
||||
|
||||
func _staff() -> NpcProfile:
|
||||
var p := NpcProfile.new()
|
||||
p.id = "authorized_staff"
|
||||
p.display_name = "Staff Member"
|
||||
p.npc_type = Rules.NpcType.AUTHORIZED_STAFF
|
||||
return p
|
||||
|
||||
func _kinds(artifacts: Array) -> Array:
|
||||
var out: Array = []
|
||||
for a in artifacts:
|
||||
out.append(a.kind)
|
||||
return out
|
||||
|
||||
func test_joke_guest_valid_needs_screen_then_grants() -> bool:
|
||||
var policy = ScenarioFactory.joke_shop().access_policy
|
||||
var arts: Array = AccessLoadout.build(_guest(), policy, {"has_id": true, "has_ticket": true})
|
||||
var has_rec := false
|
||||
for art in arts:
|
||||
if art.kind == Rules.AccessKind.RECOGNITION:
|
||||
has_rec = true
|
||||
var a := TestUtils.check(not has_rec, "no free recognition")
|
||||
var before := verifier.verify(arts, policy, false)
|
||||
var after := verifier.verify(arts, policy, true)
|
||||
var b := TestUtils.check_eq(before["granted"], false, "unscreened valid guest denied")
|
||||
var c := TestUtils.check_eq(after["granted"], true, "screened valid guest granted")
|
||||
return a and b and c
|
||||
|
||||
func test_joke_guest_no_id_denied_even_when_screened() -> bool:
|
||||
var policy = ScenarioFactory.joke_shop().access_policy
|
||||
var arts: Array = AccessLoadout.build(_guest(), policy, {"has_id": false, "has_ticket": true})
|
||||
var result := verifier.verify(arts, policy, true)
|
||||
return TestUtils.check_eq(result["granted"], false, "no-id guest denied")
|
||||
|
||||
func test_joke_guest_expired_id_denied() -> bool:
|
||||
var policy = ScenarioFactory.joke_shop().access_policy
|
||||
var arts: Array = AccessLoadout.build(_guest(), policy, {
|
||||
"has_id": true, "has_ticket": true, "id_status": Rules.ArtifactStatus.EXPIRED,
|
||||
})
|
||||
var result := verifier.verify(arts, policy, true)
|
||||
return TestUtils.check_eq(result["granted"], false, "expired id denied")
|
||||
|
||||
func test_joke_event_payload_matches_factory() -> bool:
|
||||
var shop = ScenarioFactory.joke_shop()
|
||||
var found_expired := false
|
||||
var found_no_id := false
|
||||
for event in shop.event_pool:
|
||||
var ov: Dictionary = event.get("override_access", {})
|
||||
if event.get("id", "") == "guest_expired_id":
|
||||
found_expired = int(ov.get("id_status", -1)) == Rules.ArtifactStatus.EXPIRED
|
||||
if event.get("id", "") == "guest_no_id":
|
||||
found_no_id = ov.get("has_id", true) == false
|
||||
var a := TestUtils.check(found_expired, "guest_expired_id carries expired status")
|
||||
var b := TestUtils.check(found_no_id, "guest_no_id has has_id false")
|
||||
return a and b
|
||||
|
||||
func test_joke_staff_recognized_without_override() -> bool:
|
||||
var policy = ScenarioFactory.joke_shop().access_policy
|
||||
var arts: Array = AccessLoadout.build(_staff(), policy, {})
|
||||
var has_rec := false
|
||||
for a in arts:
|
||||
if a.kind == Rules.AccessKind.RECOGNITION and a.status == Rules.ArtifactStatus.VALID:
|
||||
has_rec = true
|
||||
var screened := verifier.verify(arts, policy, true)
|
||||
return TestUtils.check(has_rec, "staff are recognized") and TestUtils.check_eq(screened["granted"], true, "recognized staff enter after screen")
|
||||
|
||||
func test_building_guest_uses_wristband_not_recognition() -> bool:
|
||||
var policy = ScenarioFactory.hollywood_building().access_policy
|
||||
var arts: Array = AccessLoadout.build(_guest(), policy, {})
|
||||
var has_rec := false
|
||||
var has_band := false
|
||||
for a in arts:
|
||||
if a.kind == Rules.AccessKind.RECOGNITION:
|
||||
has_rec = true
|
||||
if a.kind == Rules.AccessKind.WRISTBAND and a.status == Rules.ArtifactStatus.VALID:
|
||||
has_band = true
|
||||
var result := verifier.verify(arts, policy)
|
||||
var a := TestUtils.check(not has_rec, "building guest is not auto-recognized")
|
||||
var b := TestUtils.check(has_band, "building guest presents a wristband")
|
||||
var c := TestUtils.check_eq(result["granted"], true, "valid wristband grants")
|
||||
return a and b and c
|
||||
|
||||
func test_studio_ticket_grants_without_recognition() -> bool:
|
||||
var policy = ScenarioFactory.tv_studio().access_policy
|
||||
var arts: Array = AccessLoadout.build(_guest(), policy, {"has_ticket": true})
|
||||
var has_rec := false
|
||||
for a in arts:
|
||||
if a.kind == Rules.AccessKind.RECOGNITION:
|
||||
has_rec = true
|
||||
var result := verifier.verify(arts, policy)
|
||||
return TestUtils.check(not has_rec, "audience ticket is not recognition") and TestUtils.check_eq(result["granted"], true, "ticket grants at studio")
|
||||
|
||||
func test_studio_counterfeit_denied() -> bool:
|
||||
var policy = ScenarioFactory.tv_studio().access_policy
|
||||
var arts: Array = AccessLoadout.build(_guest(), policy, {
|
||||
"wristband_status": Rules.ArtifactStatus.COUNTERFEIT,
|
||||
"credential_status": Rules.ArtifactStatus.COUNTERFEIT,
|
||||
})
|
||||
var result := verifier.verify(arts, policy)
|
||||
return TestUtils.check_eq(result["granted"], false, "counterfeit studio artifacts deny")
|
||||
|
||||
func test_carried_items_override_and_roll() -> bool:
|
||||
var forced: Array = AccessLoadout.roll_carried_items(1, {"carried_items": ["weapon"]})
|
||||
var a := TestUtils.check_eq(forced, ["weapon"], "override items win")
|
||||
var rolled: Array = AccessLoadout.roll_carried_items(42, {})
|
||||
var b := TestUtils.check(rolled is Array, "roll returns an array")
|
||||
var again: Array = AccessLoadout.roll_carried_items(42, {})
|
||||
var c := TestUtils.check_eq(rolled, again, "same seed same pocket")
|
||||
return a and b and c
|
||||
|
||||
func test_joke_shop_sidewalk_exists() -> bool:
|
||||
var shop = ScenarioFactory.joke_shop()
|
||||
var studio = ScenarioFactory.tv_studio()
|
||||
var a := TestUtils.check(shop.locations.has("sidewalk"), "joke shop sidewalk")
|
||||
var b := TestUtils.check(studio.locations.has("sidewalk"), "studio sidewalk")
|
||||
var c := TestUtils.check_eq(shop.waypoint_for_intent("film").z, shop.locations["sidewalk"].z, "film walks to sidewalk")
|
||||
return a and b and c
|
||||
@@ -0,0 +1,100 @@
|
||||
extends RefCounted
|
||||
## Focus cone math and radial menu wrap/cancel (ADR-0008, ADR-0009).
|
||||
|
||||
const NpcFocus := preload("res://src/game/npc_focus.gd")
|
||||
const ActionRadial := preload("res://src/game/ui/action_radial.gd")
|
||||
|
||||
func test_cone_picks_centered_head() -> bool:
|
||||
var origin := Vector3(0, 1.6, 0)
|
||||
var forward := Vector3(0, 0, -1)
|
||||
var heads: Array = [
|
||||
Vector3(3, 1.6, -4),
|
||||
Vector3(0.05, 1.6, -4),
|
||||
Vector3(-2, 1.6, -4),
|
||||
]
|
||||
var idx := NpcFocus.pick_index(origin, forward, heads)
|
||||
return TestUtils.check_eq(idx, 1, "head nearest the look axis wins")
|
||||
|
||||
func test_cone_rejects_behind_and_far() -> bool:
|
||||
var origin := Vector3(0, 1.6, 0)
|
||||
var forward := Vector3(0, 0, -1)
|
||||
var behind := NpcFocus.score_head(origin, forward, Vector3(0, 1.6, 4))
|
||||
var far := NpcFocus.score_head(origin, forward, Vector3(0, 1.6, -40))
|
||||
var a := TestUtils.check_eq(behind, -1.0, "behind the camera is ignored")
|
||||
var b := TestUtils.check_eq(far, -1.0, "out of range is ignored")
|
||||
return a and b
|
||||
|
||||
func test_radial_wrap_and_skip_wand() -> bool:
|
||||
var menu: Node = ActionRadial.new()
|
||||
menu.open_menu("Guest", false)
|
||||
var start: int = menu.selected
|
||||
menu.step(-1)
|
||||
var a := TestUtils.check(menu.selected != start, "step wrap moves selection")
|
||||
var b := TestUtils.check(menu.is_slice_enabled(menu.selected), "landed on an enabled slice")
|
||||
# Walk forward until we would hit wand; it must skip.
|
||||
menu.selected = 4
|
||||
menu.step(1)
|
||||
var c := TestUtils.check_eq(menu.slice_id(menu.selected), "warning", "wand skipped when venue has none")
|
||||
menu.free()
|
||||
return a and b and c
|
||||
|
||||
func test_radial_cancel_does_not_confirm() -> bool:
|
||||
var menu: Node = ActionRadial.new()
|
||||
menu.open_menu("Guest", true)
|
||||
var got := {"id": ""}
|
||||
menu.confirmed.connect(func(id): got["id"] = id)
|
||||
menu.cancelled.connect(func(): got["id"] = "cancelled")
|
||||
menu.close_menu()
|
||||
var a := TestUtils.check_eq(got["id"], "", "closing without confirm emits nothing")
|
||||
var slice: String = menu.confirm_selected()
|
||||
var b := TestUtils.check_eq(slice, "", "confirm while closed is empty")
|
||||
menu.free()
|
||||
return a and b
|
||||
|
||||
func test_radial_confirm_returns_id() -> bool:
|
||||
var menu: Node = ActionRadial.new()
|
||||
menu.open_menu("Guest", true)
|
||||
menu.selected = 0
|
||||
var slice: String = menu.confirm_selected()
|
||||
menu.free()
|
||||
return TestUtils.check_eq(slice, "raise_hand", "space-confirm uses highlighted slice")
|
||||
|
||||
func test_angle_top_is_first_slice() -> bool:
|
||||
var menu: Node = ActionRadial.new()
|
||||
var idx: int = menu.angle_to_index(-PI / 2.0)
|
||||
menu.free()
|
||||
return TestUtils.check_eq(idx, 0, "top of the doughnut is slice 0")
|
||||
|
||||
func test_wand_not_on_w() -> bool:
|
||||
var src := FileAccess.get_file_as_string("res://src/game/game_manager.gd")
|
||||
var a := TestUtils.check(not src.contains("KEY_W:"), "W is not a game-manager action key")
|
||||
var b := TestUtils.check(src.contains("is_action_pressed(\"wand\")"), "wand goes through the named action")
|
||||
var c := TestUtils.check(not _action_has_key("wand", KEY_W), "wand action is not bound to W")
|
||||
var d := TestUtils.check(_action_has_key("wand", KEY_C), "wand action is bound to C")
|
||||
return a and b and c and d
|
||||
|
||||
func test_named_input_actions_exist() -> bool:
|
||||
var menu_ok := _action_has_key("action_menu", KEY_SPACE)
|
||||
var confirm_ok := _action_has_key("confirm", KEY_SPACE) and _action_has_key("confirm", KEY_ENTER)
|
||||
var cancel_ok := _action_has_key("cancel", KEY_ESCAPE)
|
||||
var inspect_ok := _action_has_key("inspect", KEY_E)
|
||||
return TestUtils.check(menu_ok, "action_menu has Space") \
|
||||
and TestUtils.check(confirm_ok, "confirm has Space + Enter") \
|
||||
and TestUtils.check(cancel_ok, "cancel has Esc") \
|
||||
and TestUtils.check(inspect_ok, "inspect has E")
|
||||
|
||||
func test_cancel_has_right_mouse() -> bool:
|
||||
var events: Array = InputMap.action_get_events("cancel")
|
||||
var found := false
|
||||
for event in events:
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
found = true
|
||||
return TestUtils.check(found, "cancel action includes right mouse button")
|
||||
|
||||
func _action_has_key(action: String, keycode: Key) -> bool:
|
||||
if not InputMap.has_action(action):
|
||||
return false
|
||||
for event in InputMap.action_get_events(action):
|
||||
if event is InputEventKey and event.physical_keycode == keycode:
|
||||
return true
|
||||
return false
|
||||
@@ -38,7 +38,7 @@ func test_tv_studio_has_all_npc_types() -> bool:
|
||||
|
||||
var _spawn_count := 0
|
||||
|
||||
func _on_spawn(_profile: NpcProfile, _intent: String, _id: String) -> void:
|
||||
func _on_spawn(_profile: NpcProfile, _intent: String, _id: String, _event: Dictionary = {}) -> void:
|
||||
_spawn_count += 1
|
||||
|
||||
func test_late_phase_reaches_violent_event() -> bool:
|
||||
@@ -137,3 +137,17 @@ func test_waypoints_map_intent_to_location() -> bool:
|
||||
var d := TestUtils.check_eq(scenario.waypoint_for_intent("sit"), steps_end, "sit -> steps_end")
|
||||
var e := TestUtils.check_eq(scenario.waypoint_for_intent("unknown_intent"), sidewalk, "unknown -> sidewalk fallback")
|
||||
return a and b and c and d and e
|
||||
|
||||
func test_spawn_rate_is_time_based() -> bool:
|
||||
# Regression: tick() runs at physics rate. Rolling the event scheduler every
|
||||
# frame spawned >1000 NPCs in seconds. Ten simulated seconds at 60 Hz must
|
||||
# stay in the normal single-digit-per-second range.
|
||||
var scenario: VenueScenario = ScenarioFactory.hollywood_building()
|
||||
var coordinator := ShiftCoordinator.new()
|
||||
coordinator.setup(scenario, 60.0, 99)
|
||||
_spawn_count = 0
|
||||
coordinator.npc_spawn_requested.connect(_on_spawn)
|
||||
coordinator.start()
|
||||
for i in 600:
|
||||
coordinator.tick(1.0 / 60.0)
|
||||
return TestUtils.check(_spawn_count <= 60, "spawns stay time-based at physics rate (was %d)" % _spawn_count)
|
||||
Reference in new issue
Block a user