feat: add responsive HUD prompts

This commit is contained in:
goose
2026-10-01 15:40:58 -04:00
parent 502492ffc0
commit 5679ed3008
9 changed files with 314 additions and 20 deletions
+35
View File
@@ -0,0 +1,35 @@
extends GutTest
const GameScene = preload("res://scenes/Game.tscn")
var game: Game
func before_each() -> void:
game = GameScene.instantiate()
add_child_autofree(game)
await get_tree().process_frame
func test_help_band_displays_the_exact_control_labels() -> void:
var help_label := game.get_node_or_null("HUD/HelpLabel") as Label
assert_not_null(help_label)
assert_string_contains(help_label.text, "Déplacer : ZQSD / Flèches")
assert_string_contains(help_label.text, "Interagir : Espace ou E")
func test_hud_uses_viewport_anchored_panels_with_distinct_stats_and_log_zones() -> void:
var hud := game.get_node("HUD") as GameHud
var layout := hud.get_node_or_null("ResponsiveLayout") as Control
var stats_panel := hud.get_node_or_null("ResponsiveLayout/StatsPanel") as PanelContainer
var log_panel := hud.get_node_or_null("ResponsiveLayout/LogPanel") as PanelContainer
var player_health := hud.get_node("PlayerHealthLabel") as Label
var enemy_health := hud.get_node("EnemyHealthLabel") as Label
var event_log := hud.get_node("EventLog") as RichTextLabel
assert_not_null(layout)
assert_eq(layout.anchor_right, 1.0)
assert_eq(layout.anchor_bottom, 1.0)
assert_not_null(stats_panel)
assert_not_null(log_panel)
assert_true(stats_panel.get_global_rect().encloses(player_health.get_global_rect()))
assert_true(stats_panel.get_global_rect().encloses(enemy_health.get_global_rect()))
assert_true(log_panel.get_global_rect().encloses(event_log.get_global_rect()))
assert_false(stats_panel.get_global_rect().intersects(log_panel.get_global_rect()))
+38
View File
@@ -0,0 +1,38 @@
extends GutTest
const GameScene = preload("res://scenes/Game.tscn")
var game: Game
func before_each() -> void:
game = GameScene.instantiate()
add_child_autofree(game)
await get_tree().process_frame
func test_context_prompt_describes_an_adjacent_closed_door_without_mutating_the_map() -> void:
var hud := game.get_node("HUD") as GameHud
var state := game.get_game_state()
var door_cell := Vector2i(2, 1)
assert_eq(hud.get_context_prompt(), "Espace — Ouvrir la porte")
assert_eq(state.map.get_cell(door_cell), GridMapState.CellKind.CLOSED_DOOR)
func test_context_prompt_describes_stairs_under_player_and_nothing_else() -> void:
var hud := game.get_node("HUD") as GameHud
var state := game.get_game_state()
state.map.set_cell(Vector2i(2, 1), GridMapState.CellKind.FLOOR)
state.player.cell = Vector2i(9, 7)
hud.refresh(state)
assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier")
state.map.set_cell(state.player.cell, GridMapState.CellKind.FLOOR)
hud.refresh(state)
assert_eq(hud.get_context_prompt(), "")
func test_context_prompt_describes_a_reached_exit() -> void:
var hud := game.get_node("HUD") as GameHud
var state := game.get_game_state()
state.exit_reached = true
hud.refresh(state)
assert_eq(hud.get_context_prompt(), "Sortie atteinte — prochain étage bientôt disponible")