Files
DungeonCrawlerWorld/tests/e2e/test_demo_map_chest_e2e.gd

44 lines
1.6 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_real_input_opens_surface_door_and_reaches_the_generated_first_floor() -> void:
var state := game.get_game_state()
var hud := game.get_node("HUD") as GameHud
var event_log := game.get_node("HUD/EventLog") as RichTextLabel
assert_eq(state.map.size, Vector2i(42, 16))
assert_eq(state.floor_state.floor_number, 0)
assert_true(state.floor_state.chests.is_empty())
state.player.cell = Vector2i(35, 7)
hud.refresh(state, [], game.get_run_state())
assert_eq(hud.get_context_prompt(), "Espace — Ouvrir la porte")
game._unhandled_input(_key_event(KEY_E))
assert_eq(game.last_turn_results[0].kind, &"door_opened")
assert_eq(state.map.get_cell(Vector2i(36, 7)), GridMapState.CellKind.FLOOR)
for step in range(4):
game._unhandled_input(_key_event(KEY_RIGHT))
assert_eq(state.player.cell, state.floor_state.exit)
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.map.size, Vector2i(210, 105))
assert_eq(state.floor_state.rooms.size(), 170)
assert_false(state.floor_state.metadata.get("hand_authored", true))
assert_string_contains(event_log.get_parsed_text(), "You descend the stairs.")
func _key_event(keycode: Key) -> InputEventKey:
var event := InputEventKey.new()
event.keycode = keycode
event.physical_keycode = keycode
event.pressed = true
return event