Implement TODO backlog: LATE phase fix, protester, CALL_SOMEONE, door lock, flashlight, persistence, navmesh, JSON localization, and release tooling
CI / headless-tests (push) Successful in 55s
CI / headless-tests (push) Successful in 55s
- Fix LATE shift phase (start 700s) so the violent-threat event is reachable - Add PROTESTER archetype (rules, profile, colors, events in public venues) - Add CALL_SOMEONE reaction (FSM -> ARGUING, influencer/trespasser/protester weights) - Door lock: DoorState core class, L binding, red/green visual indicator, locked doors thwart FORCE_ENTRY - Flashlight: G binding, SpotLight3D, perception radius bonus at evening/late - Persistence: save shift results via Save autoload, history + best score on review screen, round-trip test - Navigation: flat NavigationRegion3D navmesh, NavigationAgent3D path following with direct-movement fallback; steps made visual-only so NPCs reach entrance - Localization: strings moved to content/strings.en.json (loader keeps lookup/fmt signatures; coverage test over all keys) - Distribution: export_presets.cfg (Linux/Windows/macOS), tools/build_releases.sh, docs/RELEASING.md, prominent README Downloads section - Remove stale signal_bus.gd (invalid static-signal experiment) - Tests: 53 passing across 9 suites
This commit is contained in:
1 parent
c808165302
commit
1e972a7490
27 files changed
+1044
-340
No files matched your search
@@ -0,0 +1,46 @@
|
||||
extends RefCounted
|
||||
## Headless tests for the door lock mechanic and flashlight perception bonus.
|
||||
|
||||
const Rules := preload("res://src/core/rules.gd")
|
||||
const DoorState := preload("res://src/core/door_state.gd")
|
||||
const NpcProfile := preload("res://src/core/npc_profile.gd")
|
||||
const NPCController := preload("res://src/core/npc_controller.gd")
|
||||
|
||||
func test_door_toggle_transitions() -> bool:
|
||||
var door := DoorState.new()
|
||||
var a := TestUtils.check_eq(door.locked, false, "starts unlocked")
|
||||
var b := TestUtils.check_eq(door.toggle(), true, "toggle locks")
|
||||
var c := TestUtils.check_eq(door.toggle(), false, "toggle unlocks")
|
||||
return a and b and c
|
||||
|
||||
func test_locked_door_thwarts_force() -> bool:
|
||||
var door := DoorState.new()
|
||||
door.set_locked(true)
|
||||
var result := door.attempt_force()
|
||||
var a := TestUtils.check_eq(result["succeeded"], false, "locked door blocks forced entry")
|
||||
var b := TestUtils.check_eq(result["outcome"], "thwarted", "thwarted outcome")
|
||||
return a and b
|
||||
|
||||
func test_unlocked_door_admits_force() -> bool:
|
||||
var door := DoorState.new()
|
||||
var result := door.attempt_force()
|
||||
var a := TestUtils.check_eq(result["succeeded"], true, "open door lets forced entry through")
|
||||
var b := TestUtils.check_eq(result["outcome"], "entered", "entered outcome")
|
||||
return a and b
|
||||
|
||||
func test_flashlight_widens_perception() -> bool:
|
||||
## Without the flashlight, an NPC at AWARE_RADIUS + 3 m is unaware.
|
||||
## With the flashlight bonus (4 m), the same distance registers as aware.
|
||||
var p := NpcProfile.new()
|
||||
p.id = "nightwalker"
|
||||
p.npc_type = Rules.NpcType.TOURIST
|
||||
var dim := NPCController.new()
|
||||
dim.setup("d1", p, "wander", 1)
|
||||
var unlit: Dictionary = dim.perceive_guard(NPCController.AWARE_RADIUS + 3.0, 0.0)
|
||||
var a := TestUtils.check_eq(unlit["band"], "unaware", "unlit: too far to notice")
|
||||
|
||||
var lit := NPCController.new()
|
||||
lit.setup("l1", p, "wander", 2)
|
||||
var lit_result: Dictionary = lit.perceive_guard(NPCController.AWARE_RADIUS + 3.0, 4.0)
|
||||
var b := TestUtils.check_eq(lit_result["band"], "aware", "flashlight bonus makes NPC aware")
|
||||
return a and b
|
||||
@@ -73,6 +73,20 @@ func test_violent_threat_scales_to_threaten() -> bool:
|
||||
saw_threat = true
|
||||
return TestUtils.check(saw_threat, "violent profile can threaten at emergency level")
|
||||
|
||||
func test_call_someone_reaction() -> bool:
|
||||
var p := NpcProfile.new()
|
||||
p.id = "callsome"
|
||||
p.npc_type = Rules.NpcType.INFLUENCER
|
||||
p.reactions_by_level = {
|
||||
Rules.Level.FORMAL_WARNING: { Rules.Reaction.CALL_SOMEONE: 100 },
|
||||
}
|
||||
var npc := NPCController.new()
|
||||
npc.setup("c1", p, "film", 5, "AT_ENTRANCE")
|
||||
var outcome := npc.apply_player_action(Rules.Level.FORMAL_WARNING, Rules.Tone.PROFESSIONAL)
|
||||
var a := TestUtils.check_eq(outcome["reaction"], Rules.Reaction.CALL_SOMEONE, "rolls CALL_SOMEONE")
|
||||
var b := TestUtils.check_eq(npc.fsm.current_state, "ARGUING", "transitions to ARGUING")
|
||||
return a and b
|
||||
|
||||
func test_fsm_transitions() -> bool:
|
||||
var p := _profile_with_defaults("guest", Rules.NpcType.TOURIST, 0.9)
|
||||
var npc := NPCController.new()
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
extends RefCounted
|
||||
## Headless tests for shift-result persistence (Save autoload, user:// JSON).
|
||||
|
||||
func _save_instance() -> Object:
|
||||
var save_script: GDScript = load("res://src/autoload/save.gd")
|
||||
return save_script.new()
|
||||
|
||||
func test_save_round_trip() -> bool:
|
||||
var save := _save_instance()
|
||||
var review := {
|
||||
"scenario_id": "hollywood_building",
|
||||
"reputation": {"rating": 82.5, "grade": "B"},
|
||||
"spawned_count": 7,
|
||||
"completed_at_ms": Time.get_ticks_msec(),
|
||||
}
|
||||
var err: int = save.save_shift_result(review)
|
||||
var a := TestUtils.check_eq(err, OK, "save succeeds")
|
||||
var results: Array = save.load_shift_results()
|
||||
var b := TestUtils.check(results.size() > 0, "history non-empty after save")
|
||||
var last: Dictionary = results[results.size() - 1]
|
||||
var c := TestUtils.check_eq(last.get("scenario_id", ""), "hollywood_building", "round-trips scenario id")
|
||||
var d := TestUtils.check_eq(float(last.get("reputation", {}).get("rating", 0.0)), 82.5, "round-trips rating")
|
||||
return a and b and c and d
|
||||
|
||||
func test_load_returns_array_when_empty_or_missing() -> bool:
|
||||
# The tester home may already contain results; this only asserts shape safety.
|
||||
var save := _save_instance()
|
||||
var results: Array = save.load_shift_results()
|
||||
return TestUtils.check(results is Array, "load_shift_results always returns Array")
|
||||
@@ -41,6 +41,42 @@ var _spawn_count := 0
|
||||
func _on_spawn(_profile: NpcProfile, _intent: String, _id: String) -> void:
|
||||
_spawn_count += 1
|
||||
|
||||
func test_late_phase_reaches_violent_event() -> bool:
|
||||
## Bug fix: the LATE phase never fired because no shift_phases entry existed.
|
||||
var scenario: VenueScenario = ScenarioFactory.hollywood_building()
|
||||
var coordinator := ShiftCoordinator.new()
|
||||
coordinator.setup(scenario, 900.0, 1)
|
||||
coordinator.start()
|
||||
for i in 760:
|
||||
coordinator.tick(1.0)
|
||||
var a := TestUtils.check_eq(coordinator.current_phase, Rules.Phase.LATE, "LATE phase reached by 760s")
|
||||
var eligible := scenario.events_in_phase(Rules.Phase.LATE)
|
||||
var found := false
|
||||
for e in eligible:
|
||||
if e.get("id", "") == "violent_emergency_event":
|
||||
found = true
|
||||
var b := TestUtils.check(found, "violent event is eligible in LATE phase")
|
||||
# All venues declare the LATE phase honestly.
|
||||
var c := true
|
||||
for venue in [ScenarioFactory.hollywood_building(), ScenarioFactory.joke_shop(), ScenarioFactory.tv_studio()]:
|
||||
if not venue.shift_phases.has(Rules.Phase.LATE):
|
||||
c = false
|
||||
return a and b and TestUtils.check(c, "all venues declare a LATE phase")
|
||||
|
||||
func test_protester_archetype_present() -> bool:
|
||||
var profiles := ScenarioFactory.shared_profiles()
|
||||
var protester_found := false
|
||||
for p in profiles:
|
||||
if p.id == "protester":
|
||||
protester_found = true
|
||||
var a := TestUtils.check(protester_found, "protester profile defined")
|
||||
var in_pool := false
|
||||
for venue in [ScenarioFactory.hollywood_building(), ScenarioFactory.tv_studio()]:
|
||||
for e in venue.event_pool:
|
||||
if e.get("npc_type", -1) == Rules.NpcType.PROTESTER:
|
||||
in_pool = true
|
||||
return a and TestUtils.check(in_pool, "protester event referenced in public venues")
|
||||
|
||||
func test_shift_coordinator_runs_a_shift() -> bool:
|
||||
var scenario: VenueScenario = ScenarioFactory.hollywood_building()
|
||||
var coordinator := ShiftCoordinator.new()
|
||||
|
||||
@@ -14,6 +14,15 @@ func test_strings_format() -> bool:
|
||||
var b := TestUtils.check_eq(Strings.fmt("react.comply", ["Tourist"]), "Tourist complies and steps back.", "reaction formats")
|
||||
return a and b
|
||||
|
||||
func test_strings_json_backed_all_resolve() -> bool:
|
||||
## Every key in the JSON-loaded table must resolve to a value other than
|
||||
## the key itself (fail-safe would otherwise mask broken entries).
|
||||
for key in Strings.TABLE.keys():
|
||||
var value: String = Strings.lookup(key)
|
||||
if value == key:
|
||||
return TestUtils.fail("key %s resolves to itself — table entry missing" % key)
|
||||
return true
|
||||
|
||||
func test_strings_cover_ui_keys() -> bool:
|
||||
## Every key referenced by the HUD and game manager must exist.
|
||||
var required := [
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
extends RefCounted
|
||||
## Headless tests for the procedural world and navigation mesh.
|
||||
|
||||
const WorldBuilder := preload("res://src/game/world_builder.gd")
|
||||
|
||||
func test_navmesh_built() -> bool:
|
||||
var root := Node3D.new()
|
||||
WorldBuilder.new(root).build()
|
||||
var region: NavigationRegion3D = root.find_child("NavRegion", true, false) as NavigationRegion3D
|
||||
if region == null:
|
||||
return TestUtils.fail("no NavRegion in world")
|
||||
var mesh: NavigationMesh = region.navigation_mesh
|
||||
if mesh == null:
|
||||
return TestUtils.fail("NavRegion has no navigation mesh")
|
||||
var a := TestUtils.check(mesh.get_polygon_count() > 0, "navmesh has polygons")
|
||||
var b := TestUtils.check(mesh.get_vertices().size() >= 4, "navmesh has vertices")
|
||||
root.free()
|
||||
return a and b
|
||||
|
||||
func test_door_indicator_built() -> bool:
|
||||
var root := Node3D.new()
|
||||
var builder := WorldBuilder.new(root)
|
||||
builder.build()
|
||||
var a := TestUtils.check(builder.door_indicator != null, "door indicator mesh exists")
|
||||
if builder.door_indicator != null:
|
||||
builder.set_door_locked(true)
|
||||
var mat: StandardMaterial3D = builder.door_indicator.material_override as StandardMaterial3D
|
||||
var b := TestUtils.check(mat != null and mat.albedo_color.r > 0.5, "indicator turns red when locked")
|
||||
builder.set_door_locked(false)
|
||||
var c := TestUtils.check(mat != null and mat.albedo_color.g > 0.5, "indicator turns green when open")
|
||||
root.free()
|
||||
return a and b and c
|
||||
root.free()
|
||||
return a
|
||||
Reference in new issue
Block a user