fix(client): address PR review warnings — field guard + public API rename
- main.gd: add has("entity_id") guard to _play_recognition_chimes()
(matches defensive pattern in _play_close_sound_events and update_sound_events)
- sound_indicator_renderer.gd: rename _color_for_type → color_for_type
(public testable API, not an internal-only method)
- test_rendering.gd: update test calls to match rename
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -220,6 +220,8 @@ func _play_close_sound_events() -> void:
|
||||
func _play_recognition_chimes() -> void:
|
||||
var active_ids: Dictionary = {}
|
||||
for rec in GameState.pending_recognitions:
|
||||
if not rec is Dictionary or not rec.has("entity_id"):
|
||||
continue
|
||||
var eid: int = rec.entity_id
|
||||
active_ids[eid] = true
|
||||
if not _known_recognition_ids.has(eid):
|
||||
|
||||
@@ -111,7 +111,7 @@ func _draw() -> void:
|
||||
else:
|
||||
alpha = lerpf(1.0, 0.0, (t - fade_start) / (FADE_DURATION / INDICATOR_LIFETIME))
|
||||
|
||||
var color: Color = _color_for_type(ind.event_type)
|
||||
var color: Color = color_for_type(ind.event_type)
|
||||
color.a = alpha * 0.9
|
||||
_draw_arrow(edge_pt, dir, color)
|
||||
|
||||
@@ -142,7 +142,7 @@ func _draw_arrow(pos: Vector2, dir: Vector2, color: Color) -> void:
|
||||
|
||||
|
||||
## Map event type string → D-018 color category.
|
||||
func _color_for_type(event_type: String) -> Color:
|
||||
func color_for_type(event_type: String) -> Color:
|
||||
var et := event_type.to_lower()
|
||||
if et.contains("voice") or et.contains("speech") or et.contains("convers") or et.contains("talk"):
|
||||
return COLOR_VOICE
|
||||
|
||||
@@ -461,23 +461,23 @@ func test_sound_indicator_empty_update_preserves_existing() -> void:
|
||||
|
||||
func test_sound_indicator_color_voice() -> void:
|
||||
var renderer := _make_sound_indicator_renderer()
|
||||
assert_that(renderer._color_for_type("voice")).is_equal(SoundIndicatorRenderer.COLOR_VOICE)
|
||||
assert_that(renderer._color_for_type("Voice")).is_equal(SoundIndicatorRenderer.COLOR_VOICE)
|
||||
assert_that(renderer._color_for_type("speech")).is_equal(SoundIndicatorRenderer.COLOR_VOICE)
|
||||
assert_that(renderer.color_for_type("voice")).is_equal(SoundIndicatorRenderer.COLOR_VOICE)
|
||||
assert_that(renderer.color_for_type("Voice")).is_equal(SoundIndicatorRenderer.COLOR_VOICE)
|
||||
assert_that(renderer.color_for_type("speech")).is_equal(SoundIndicatorRenderer.COLOR_VOICE)
|
||||
renderer.queue_free()
|
||||
|
||||
func test_sound_indicator_color_danger() -> void:
|
||||
var renderer := _make_sound_indicator_renderer()
|
||||
assert_that(renderer._color_for_type("Gunshot")).is_equal(SoundIndicatorRenderer.COLOR_DANGER)
|
||||
assert_that(renderer._color_for_type("alert")).is_equal(SoundIndicatorRenderer.COLOR_DANGER)
|
||||
assert_that(renderer._color_for_type("danger")).is_equal(SoundIndicatorRenderer.COLOR_DANGER)
|
||||
assert_that(renderer.color_for_type("Gunshot")).is_equal(SoundIndicatorRenderer.COLOR_DANGER)
|
||||
assert_that(renderer.color_for_type("alert")).is_equal(SoundIndicatorRenderer.COLOR_DANGER)
|
||||
assert_that(renderer.color_for_type("danger")).is_equal(SoundIndicatorRenderer.COLOR_DANGER)
|
||||
renderer.queue_free()
|
||||
|
||||
func test_sound_indicator_color_neutral_for_unknown() -> void:
|
||||
var renderer := _make_sound_indicator_renderer()
|
||||
assert_that(renderer._color_for_type("Footstep")).is_equal(SoundIndicatorRenderer.COLOR_NEUTRAL)
|
||||
assert_that(renderer._color_for_type("")).is_equal(SoundIndicatorRenderer.COLOR_NEUTRAL)
|
||||
assert_that(renderer._color_for_type("Unknown")).is_equal(SoundIndicatorRenderer.COLOR_NEUTRAL)
|
||||
assert_that(renderer.color_for_type("Footstep")).is_equal(SoundIndicatorRenderer.COLOR_NEUTRAL)
|
||||
assert_that(renderer.color_for_type("")).is_equal(SoundIndicatorRenderer.COLOR_NEUTRAL)
|
||||
assert_that(renderer.color_for_type("Unknown")).is_equal(SoundIndicatorRenderer.COLOR_NEUTRAL)
|
||||
renderer.queue_free()
|
||||
|
||||
func test_sound_indicator_deduplicates_same_position() -> void:
|
||||
|
||||
Reference in New Issue
Block a user