Files
DungeonCrawlerWorld/tests/e2e/test_stair_deadline_e2e.gd
T

41 lines
1.5 KiB
GDScript
Raw 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_real_game_early_down_stairs_are_blocked_then_rest_makes_descent_eligible() -> void:
var state := game.get_game_state()
var hud := game.get_node("HUD") as GameHud
var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label
var log := game.get_node("HUD/EventLog") as RichTextLabel
state.enemies.clear()
state.player.cell = state.floor_state.exit
assert_string_contains(hud.get_context_prompt(), "encore 13 jour")
game._unhandled_input(_key_event(KEY_E))
assert_eq(game.get_run_state().current_floor, 0)
assert_eq(prompt_label.text, hud.get_context_prompt())
assert_string_contains(log.get_parsed_text(), "Les escaliers refusent")
assert_string_contains(log.get_parsed_text(), "13 jour")
game.advance_floor_deadline(13 * FloorDeadline.REAL_SECONDS_PER_DAY)
assert_eq(game.get_run_state().deadline_for(0).remaining_days(), 2)
assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier")
game._unhandled_input(_key_event(KEY_E))
assert_eq(game.get_run_state().current_floor, 1)
assert_eq(state.player.cell, state.floor_state.entrance)
assert_eq(hud.get_context_prompt(), "Espace — Monter l’escalier")
func _key_event(keycode: Key) -> InputEventKey:
var event := InputEventKey.new()
event.keycode = keycode
event.physical_keycode = keycode
event.pressed = true
return event