fix(client): address PR #86 review — archetype validation, teleport clear, ticker layout

- protocol.gd: replace capitalize() with explicit match for archetype
  string mapping, push_error on unknown input with Detective fallback
- main.gd: clear _known_triangle_ids in _teleport_transition() alongside
  _known_recognition_ids so chime re-fires after room change
- news_ticker.gd: defer get_minimum_size() via call_deferred to run
  after layout pass, fixing first-frame scroll distance
- 3 new tests: unknown archetype fallback, triangle dedup per-id,
  independent triangle ID firing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 16:28:12 +01:00
co-authored by Claude Opus 4.6
parent 349f02fbcb
commit e0eb3cd35e
4 changed files with 69 additions and 3 deletions
+1
View File
@@ -575,6 +575,7 @@ func _teleport_transition() -> void:
GameState.current_dialogue = null
GameState.dialogue_active = false
_known_recognition_ids.clear() # D-067: reset chimes for new room
_known_triangle_ids.clear() # #590: reset activation chimes for new room
if dialogue_box and dialogue_box.is_dialogue_active():
dialogue_box.hide_dialogue()
+14 -1
View File
@@ -258,6 +258,9 @@ static func decode_snapshot(bytes: PackedByteArray) -> Variant:
# v19: triangle_crisis_events (#590, D-072/D-089) — one-shot activation events.
# Each entry: {triangle_id: int}. Client deduplicates by triangle_id across ticks.
# v0.1 intentional omissions: role_assignments, trigger_npc_id, tick are not decoded
# here — the client has no use for them in v0.1 (no overlay, no entity targeting).
# Add when #593+ requires richer client-side event handling.
var triangle_crisis_events: Array = []
var raw_tce: Variant = raw.get("triangle_crisis_events")
if raw_tce is Array:
@@ -470,7 +473,17 @@ static func _decode_enum_variant(raw) -> Dictionary:
## character_archetype: "detective" → "Detective", "smuggler" → "Smuggler" (server enum variant).
static func encode_startup_message(world_seed: int, character_archetype: String = "detective") -> PackedByteArray:
# Map client lowercase archetype string to server PascalCase enum variant.
var archetype_variant: String = character_archetype.capitalize()
# Explicit match prevents unknown strings silently reaching the server as
# garbage enum values — fail loudly and fall back to "Detective".
var archetype_variant: String
match character_archetype:
"detective":
archetype_variant = "Detective"
"smuggler":
archetype_variant = "Smuggler"
_:
push_error("Protocol: unknown character_archetype '%s' — defaulting to 'Detective'" % character_archetype)
archetype_variant = "Detective"
var msg := {
"world_seed": world_seed,
"character_archetype": archetype_variant,