Files

40 lines
1.4 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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(36, 7)
state.player.cell = Vector2i(35, 7)
hud.refresh(state, [], game.get_run_state())
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.player.cell = state.floor_state.exit
hud.refresh(state, [], game.get_run_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")