Map screen version

This commit is contained in:
2026-08-23 13:16:04 +03:00
parent 45427b7070
commit d749485126
16 changed files with 650 additions and 9 deletions
+55
View File
@@ -30,6 +30,7 @@ func _run() -> void:
test_kick_spread()
test_gait_phase_crossing()
test_tail_verlet_constraint()
test_run_map()
print("=" .repeat(60))
print("Results: %d passed, %d failed" % [_passed, _failed])
@@ -171,6 +172,60 @@ func test_tail_verlet_constraint() -> void:
_assert_in_range(damping_factor, 0.85, 1.0, "tail damping factor is reasonable")
# ── Run map (Slay-the-Spire progression) ──────────────────────────────────────
func test_run_map() -> void:
print("\n-- test_run_map --")
var run: Node = root.get_node_or_null("/root/Run")
if run == null:
_assert_true(false, "Run autoload should exist")
return
run.start_new_run()
_assert_true(run.has_run(), "start_new_run builds a map")
_assert_true(run.map.size() >= 2, "map has multiple rows")
# Final row is a single boss node the map funnels toward.
var last: Array = run.map[run.map.size() - 1]
_assert_eq(last.size(), 1, "final row is a single boss node")
_assert_true(last[0].level.is_boss, "final node is a boss level")
# Connectivity: every node links forward, and every next-row node has a parent.
for r: int in run.map.size() - 1:
var nxt: Array = run.map[r + 1]
var reached := {}
for from_node in run.map[r]:
_assert_true(from_node.links.size() >= 1, "row %d node links forward" % r)
for c: int in from_node.links:
_assert_true(c >= 0 and c < nxt.size(), "link column in range")
reached[c] = true
for c: int in nxt.size():
_assert_true(reached.has(c), "row %d col %d has a parent" % [r + 1, c])
# From the start gate the whole first row is the frontier.
_assert_eq(run.reachable().size(), run.map[0].size(), "start frontier is row 0")
# Advancing follows the chosen node's links.
var first = run.map[0][0]
run.select_node(first)
run.complete_current_level()
_assert_eq(run.player_row, 0, "player advanced to row 0")
_assert_true(first.cleared, "cleared node is flagged")
_assert_eq(run.reachable().size(), first.links.size(),
"frontier follows the chosen node's links")
# Walking to a boss node latches run completion.
var guard := 0
while not run.run_complete() and guard < 64:
var opts: Array = run.reachable()
if opts.is_empty():
break
run.select_node(opts[0])
run.complete_current_level()
guard += 1
_assert_true(run.run_complete(), "reaching a boss node completes the run")
# ── Shared helpers ────────────────────────────────────────────────────────────
func _assert_in_range(val: float, lo: float, hi: float, desc: String) -> void: