39 lines
1.3 KiB
GDScript
39 lines
1.3 KiB
GDScript
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(4, 11)
|
||
|
||
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(4, 11), GridMapState.CellKind.FLOOR)
|
||
state.player.cell = Vector2i(18, 4)
|
||
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")
|