feat: complete playtest parity improvements

This commit is contained in:
goose
2026-10-08 19:06:19 -04:00
parent cce25a1908
commit eca098b4b9
139 changed files with 3001 additions and 982 deletions
+19 -9
View File
@@ -3,8 +3,6 @@ extends RefCounted
const MAX_MAP_SIZE := Vector2i(700, 350)
const MAX_ROOM_COUNT := 500
const SHALLOW_ROOM_MIN_SIZE := Vector2i(5, 4)
const SHALLOW_ROOM_MAX_SIZE := Vector2i(10, 8)
const DEEP_ROOM_MIN_SIZE := Vector2i(4, 3)
const DEEP_ROOM_MAX_SIZE := Vector2i(6, 5)
const ROOM_PADDING := 2
@@ -38,13 +36,6 @@ const EconomyType = preload("res://scripts/domain/items/economy.gd")
# impractical. It is also the sole sizing input to generation, making a seed
# and floor number reproduce exactly the same layout.
static func generation_profile(floor_number: int) -> Dictionary:
if floor_number <= 1:
return {
"map_size": Vector2i(80, 50),
"target_room_count": 8,
"room_min_size": SHALLOW_ROOM_MIN_SIZE,
"room_max_size": SHALLOW_ROOM_MAX_SIZE,
}
var normalized_floor := maxi(1, floor_number)
return {
"map_size": Vector2i(
@@ -75,6 +66,7 @@ static func generate(seed: String, floor_number: int, catalog: ContentCatalog) -
graph.add_local_loops(rooms, rng)
for edge in graph.loop_edges:
_carve_l_corridor_preserving_doors(map, _room_center(rooms[edge.from].bounds), _room_center(rooms[edge.to].bounds))
tree_door_cells = _remove_nonfunctional_doors(map, tree_door_cells)
for serialized_door in tree_door_cells:
map.set_cell(Vector2i(int(serialized_door[0]), int(serialized_door[1])), GridMapStateType.CellKind.CLOSED_DOOR)
@@ -176,6 +168,24 @@ static func _place_tree_boundary_doors(map: GridMapState, path: Array[Vector2i],
break
return serialized_cells
static func _remove_nonfunctional_doors(map: GridMapState, serialized_doors: Array[Array]) -> Array[Array]:
var functional: Array[Array] = []
for serialized_door: Array in serialized_doors:
var cell := Vector2i(int(serialized_door[0]), int(serialized_door[1]))
var walkable_directions: Array[Vector2i] = []
for direction: Vector2i in [Vector2i.LEFT, Vector2i.RIGHT, Vector2i.UP, Vector2i.DOWN]:
if map.is_walkable(cell + direction):
walkable_directions.append(direction)
var controls_straight_passage := walkable_directions.size() == 2 and (
(walkable_directions.has(Vector2i.LEFT) and walkable_directions.has(Vector2i.RIGHT))
or (walkable_directions.has(Vector2i.UP) and walkable_directions.has(Vector2i.DOWN))
)
if controls_straight_passage:
functional.append(serialized_door)
else:
map.set_cell(cell, GridMapStateType.CellKind.FLOOR)
return functional
static func _is_adjacent_to_serialized_door(cell: Vector2i, serialized_doors: Array[Array]) -> bool:
for serialized_door in serialized_doors:
var door_cell := Vector2i(int(serialized_door[0]), int(serialized_door[1]))
+2 -3
View File
@@ -55,11 +55,10 @@ static func _spawn_enemy(floor: FloorState, catalog: ContentCatalog, room: RoomS
return serial + 1
static func _spawn_chest(floor: FloorState, catalog: ContentCatalog, room: RoomState, rng: DeterministicRng, occupied: Dictionary[Vector2i, bool]) -> void:
var definitions := SpawnRulesType.loot_tables(catalog)
var definition := catalog.get_loot_table(&"floor_treasure")
var cell := _available_cell(floor, room, rng, occupied)
if definitions.is_empty() or cell == Vector2i(-1, -1):
if definition.is_empty() or cell == Vector2i(-1, -1):
return
var definition: Dictionary = definitions[rng.next_int() % definitions.size()]
floor.chests[cell] = {
"loot_table_id": definition["id"],
"opened": false,
+25 -33
View File
@@ -3,44 +3,36 @@ extends RefCounted
const GridMapStateType = preload("res://scripts/domain/grid_map_state.gd")
const FloorStateType = preload("res://scripts/domain/world/floor_state.gd")
const ActorStateType = preload("res://scripts/domain/actor_state.gd")
const RoomStateType = preload("res://scripts/domain/world/room_state.gd")
# Floor zero deliberately remains an authored tutorial surface. Its geometry is
# not derived from the run seed; RunState supplies persistence by caching it.
const SURFACE_SIZE := Vector2i(42, 16)
const ENTRANCE := Vector2i(4, 7)
const DOOR := Vector2i(36, 7)
const EXIT := Vector2i(39, 7)
# The surface mirrors DCWASCII's current floor-zero contract: an empty authored
# staging area, a straight corridor, one door, and the stairs to the procedural
# dungeon. It intentionally contains no enemies, chest, deadline content, or
# seed-dependent population.
static func generate(_seed: String = "") -> FloorState:
var map := GridMapStateType.new(Vector2i(30, 20), GridMapStateType.CellKind.WALL)
_carve_room(map, Rect2i(2, 12, 6, 5))
_carve_room(map, Rect2i(2, 4, 7, 7))
_carve_room(map, Rect2i(10, 2, 10, 6))
_carve_room(map, Rect2i(21, 5, 7, 8))
_carve_vertical_corridor(map, 4, 10, 12)
_carve_horizontal_corridor(map, 8, 10, 6)
_carve_horizontal_corridor(map, 18, 21, 6)
_carve_vertical_corridor(map, 18, 4, 6)
map.set_cell(Vector2i(4, 11), GridMapStateType.CellKind.CLOSED_DOOR)
map.set_cell(Vector2i(4, 7), GridMapStateType.CellKind.CHEST)
map.set_cell(Vector2i(18, 4), GridMapStateType.CellKind.STAIRS)
var map := GridMapStateType.new(SURFACE_SIZE, GridMapStateType.CellKind.WALL)
var entrance_room := RoomStateType.new(&"surface_entrance", Rect2i(2, 2, 18, 11), &"entrance")
var landing := RoomStateType.new(&"surface_landing", Rect2i(37, 6, 4, 3), &"open")
_carve_room(map, entrance_room.bounds)
for x in range(20, DOOR.x):
map.set_cell(Vector2i(x, ENTRANCE.y), GridMapStateType.CellKind.FLOOR)
map.set_cell(DOOR, GridMapStateType.CellKind.CLOSED_DOOR)
_carve_room(map, landing.bounds)
map.set_cell(EXIT, GridMapStateType.CellKind.STAIRS)
var floor := FloorStateType.new(map, 0, 0)
floor.entrance = Vector2i(4, 12)
floor.exit = Vector2i(18, 4)
floor.enemies[&"goblin"] = ActorStateType.new(&"goblin", Vector2i(24, 8), 6, 2)
floor.chests[Vector2i(4, 7)] = {
"loot_table_id": &"floor1_reward",
"opened": false,
}
floor.rooms = [entrance_room, landing]
floor.entrance = ENTRANCE
floor.exit = EXIT
floor.metadata = {"hand_authored": true, "theme": "surface"}
return floor
static func _carve_room(map: GridMapState, room: Rect2i) -> void:
for y in range(room.position.y, room.end.y):
for x in range(room.position.x, room.end.x):
static func _carve_room(map: GridMapState, bounds: Rect2i) -> void:
for y in range(bounds.position.y, bounds.end.y):
for x in range(bounds.position.x, bounds.end.x):
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
static func _carve_horizontal_corridor(map: GridMapState, from_x: int, to_x: int, y: int) -> void:
for x in range(from_x, to_x + 1):
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
static func _carve_vertical_corridor(map: GridMapState, x: int, from_y: int, to_y: int) -> void:
for y in range(from_y, to_y + 1):
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
+15 -3
View File
@@ -50,12 +50,24 @@ static func trigger(floor: FloorState, player: ActorState, cell: Vector2i, catal
trap["discovered"] = true
floor.traps[cell] = trap
var payload := {"trap_id": StringName(trap.get("trap_id", "")), "damage": actual_damage}
var events: Array[Dictionary] = [{"kind": &"trap_triggered", "payload": payload}]
var events: Array[Dictionary] = [_event(&"trap_triggered", player, cell, payload)]
# Content chance remains deterministic in this turn-based seam: a declared
# majority chance applies, while lower chances are safely represented as no
# status until a future RNG-owned rules slice supplies a roll stream.
var status := StringName(definition.get("status", ""))
# JSON `null` is a valid declaration for traps without a status effect.
# Convert only textual IDs; StringName(null) is not a valid constructor.
var status_value: Variant = definition.get("status")
var status := StringName(status_value) if status_value is String else &""
if not status.is_empty() and float(definition.get("status_chance", 0.0)) >= 0.5:
player.apply_status(StatusEffectType.new(status, int(definition.get("status_duration", -1)), 0, StringName(trap.get("trap_id", ""))))
events.append({"kind": &"trap_status_applied", "payload": {"trap_id": StringName(trap.get("trap_id", "")), "status": status}})
events.append(_event(&"trap_status_applied", player, cell, {"trap_id": StringName(trap.get("trap_id", "")), "status": status}))
return {"triggered": true, "damage": actual_damage, "trap_id": StringName(trap.get("trap_id", "")), "message": String(definition.get("message", "A trap triggers.")), "events": events}
static func _event(kind: StringName, player: ActorState, cell: Vector2i, payload: Dictionary) -> Dictionary:
return {
"kind": kind,
"actor_id": player.id,
"target_id": player.id,
"cell": cell,
"payload": payload,
}