feat: add final floor victory and deep generation scale

This commit is contained in:
goose
2026-10-04 10:32:11 -04:00
parent 6ded0f76ce
commit f65e9026c1
21 changed files with 330 additions and 57 deletions
@@ -0,0 +1,39 @@
extends GutTest
const ContentCatalogType = preload("res://scripts/domain/content/content_catalog.gd")
const FloorGeneratorType = preload("res://scripts/domain/world/floor_generator.gd")
const CARDINAL_DIRECTIONS := [Vector2i.LEFT, Vector2i.RIGHT, Vector2i.UP, Vector2i.DOWN]
func test_deep_profiles_generate_bounded_non_overlapping_reachable_room_layouts() -> void:
var catalog := ContentCatalogType.new()
for floor_number in [2, 12, 15]:
var profile := FloorGeneratorType.generation_profile(floor_number)
var floor := FloorGeneratorType.generate("deep-profile", floor_number, catalog)
assert_eq(floor.rooms.size(), int(profile["target_room_count"]), "floor %d creates its profiled room count" % floor_number)
assert_eq(floor.map.size, profile["map_size"])
_assert_non_overlapping(floor.rooms, floor_number)
var reachable := _reachable_cells_treating_doors_as_openable(floor.map, floor.entrance)
assert_true(reachable.has(floor.exit), "floor %d reaches its exit" % floor_number)
func _assert_non_overlapping(rooms: Array[RoomState], floor_number: int) -> void:
var occupied: Dictionary[Vector2i, bool] = {}
for room in rooms:
for y in range(room.bounds.position.y, room.bounds.end.y):
for x in range(room.bounds.position.x, room.bounds.end.x):
var cell := Vector2i(x, y)
assert_false(occupied.has(cell), "floor %d keeps rooms non-overlapping" % floor_number)
occupied[cell] = true
func _reachable_cells_treating_doors_as_openable(map: GridMapState, start: Vector2i) -> Dictionary[Vector2i, bool]:
var reachable: Dictionary[Vector2i, bool] = {start: true}
var frontier: Array[Vector2i] = [start]
while not frontier.is_empty():
var current := frontier.pop_front()
for direction in CARDINAL_DIRECTIONS:
var next_cell: Vector2i = current + direction
if (map.is_walkable(next_cell) or map.get_cell(next_cell) == GridMapState.CellKind.CLOSED_DOOR) and not reachable.has(next_cell):
reachable[next_cell] = true
frontier.append(next_cell)
return reachable