feat: add multi-floor dungeon transitions
This commit is contained in:
@@ -48,7 +48,7 @@ func test_stairs_usage_triggers_exactly_one_enemy_response_without_transitioning
|
||||
assert_eq(state.player.cell, stairs)
|
||||
assert_same(state.map, map)
|
||||
|
||||
func test_stairs_usage_refreshes_exact_exit_prompt_and_writes_the_journal() -> void:
|
||||
func test_stairs_usage_transitions_to_floor_one_and_writes_the_journal() -> void:
|
||||
var game := GameScene.instantiate() as Game
|
||||
add_child_autofree(game)
|
||||
await get_tree().process_frame
|
||||
@@ -62,7 +62,8 @@ func test_stairs_usage_refreshes_exact_exit_prompt_and_writes_the_journal() -> v
|
||||
var results := game.submit_test_interact()
|
||||
|
||||
assert_eq(results[0].kind, &"stairs_used")
|
||||
assert_true(state.exit_reached)
|
||||
assert_eq(hud.get_context_prompt(), "Sortie atteinte — prochain étage bientôt disponible")
|
||||
assert_eq(prompt_label.text, "Sortie atteinte — prochain étage bientôt disponible")
|
||||
assert_eq(game.get_run_state().current_floor, 1)
|
||||
assert_eq(game.get_game_state().player.cell, game.get_game_state().floor_state.entrance)
|
||||
assert_eq(hud.get_context_prompt(), "Espace — Monter l’escalier")
|
||||
assert_eq(prompt_label.text, "Espace — Monter l’escalier")
|
||||
assert_string_contains(event_log.get_parsed_text(), "You descend the stairs.")
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
extends GutTest
|
||||
|
||||
const ContentCatalogType = preload("res://scripts/domain/content/content_catalog.gd")
|
||||
const SurfaceGeneratorType = preload("res://scripts/domain/world/surface_generator.gd")
|
||||
const FloorTransitionType = preload("res://scripts/domain/run/floor_transition.gd")
|
||||
const RunStateType = preload("res://scripts/domain/run/run_state.gd")
|
||||
const GridMapStateType = preload("res://scripts/domain/grid_map_state.gd")
|
||||
|
||||
const ASCII_CATALOG_PATH := "res://data/ascii"
|
||||
|
||||
func test_floor_zero_is_hand_authored_and_floor_one_is_seed_floor_one_procedural() -> void:
|
||||
var catalog := ContentCatalogType.load_from_directory(ASCII_CATALOG_PATH)
|
||||
var run := RunStateType.new("B5-surface-contract")
|
||||
var transitions := FloorTransitionType.new(catalog)
|
||||
|
||||
var surface := transitions.initial_floor(run)
|
||||
var descend := transitions.transition(run, surface, surface.exit)
|
||||
var first_floor: FloorState = descend["floor"]
|
||||
|
||||
assert_eq(surface.floor_number, 0)
|
||||
assert_true(surface.metadata.get("hand_authored", false))
|
||||
assert_eq(surface.map.size, Vector2i(30, 20))
|
||||
assert_eq(surface.entrance, Vector2i(4, 12))
|
||||
assert_eq(surface.exit, Vector2i(18, 4))
|
||||
assert_eq(surface.map.get_cell(surface.exit), GridMapStateType.CellKind.STAIRS)
|
||||
assert_eq(first_floor.floor_number, 1)
|
||||
assert_false(first_floor.metadata.get("hand_authored", false))
|
||||
assert_eq(first_floor.seed, _seed_value("B5-surface-contract", 1))
|
||||
assert_eq(first_floor.map.get_cell(first_floor.entrance), GridMapStateType.CellKind.STAIRS)
|
||||
assert_eq(first_floor.map.get_cell(first_floor.exit), GridMapStateType.CellKind.STAIRS)
|
||||
assert_eq(descend["arrival"], first_floor.entrance)
|
||||
|
||||
var independently_authored := SurfaceGeneratorType.generate("another-seed")
|
||||
assert_eq(independently_authored.to_dict(), surface.to_dict(), "floor zero is authored rather than seed-generated")
|
||||
|
||||
func test_transition_cache_keeps_mutated_floor_state_and_arrival_cells_across_return_trip() -> void:
|
||||
var catalog := ContentCatalogType.load_from_directory(ASCII_CATALOG_PATH)
|
||||
var run := RunStateType.new("B5-cache-contract")
|
||||
var transitions := FloorTransitionType.new(catalog)
|
||||
var surface := transitions.initial_floor(run)
|
||||
var first_descent := transitions.transition(run, surface, surface.exit)
|
||||
var first_floor: FloorState = first_descent["floor"]
|
||||
first_floor.chests[Vector2i(3, 3)] = {"opened": true}
|
||||
first_floor.enemies.clear()
|
||||
first_floor.events.append({"id": "first-floor-event", "resolved": true})
|
||||
|
||||
var ascent := transitions.transition(run, first_floor, first_floor.entrance)
|
||||
var returned_surface: FloorState = ascent["floor"]
|
||||
returned_surface.map.set_cell(Vector2i(4, 7), GridMapStateType.CellKind.FLOOR)
|
||||
var second_descent := transitions.transition(run, returned_surface, returned_surface.exit)
|
||||
var cached_first_floor: FloorState = second_descent["floor"]
|
||||
|
||||
assert_same(returned_surface, surface)
|
||||
assert_eq(ascent["arrival"], surface.exit)
|
||||
assert_same(cached_first_floor, first_floor)
|
||||
assert_eq(second_descent["arrival"], first_floor.entrance)
|
||||
assert_eq(cached_first_floor.chests[Vector2i(3, 3)], {"opened": true})
|
||||
assert_eq(cached_first_floor.enemies.size(), 0)
|
||||
assert_true(cached_first_floor.events.has({"id": "first-floor-event", "resolved": true}))
|
||||
assert_eq(surface.map.get_cell(Vector2i(4, 7)), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
func _seed_value(seed: String, floor_number: int) -> int:
|
||||
var value := 0
|
||||
for index in range(seed.length()):
|
||||
value = (value * 31 + seed.unicode_at(index)) % 2147483647
|
||||
return value + floor_number
|
||||
@@ -0,0 +1 @@
|
||||
uid://20vpsc7klakm
|
||||
Reference in New Issue
Block a user