Three parallel read-only reviews (save/boundary, perf/lifecycle, battle/economy) produced verified findings; each was confirmed with a probe before fixing. Battle logic: - storm_cooldown was set to 10s on use but never decremented, disabling the button for the rest of every battle. Now ticks with speed-scaled delta. touch_input_test verifies 9.8s -> 0 after 12s. - set_p3a_scenario ignored the per-wave seed passed to setup(), so every wave of a multi-wave node reused seed 10001. Now accepts an explicit seed from GameRoot. Performance: - set_roster rebuilt all hero cards every frame (~35 nodes + styleboxes/frame, ~2100 nodes/sec at 60fps). Now diffs by hero id and updates labels/energy in place; visible_node_test asserts card instance ids are unchanged across an identical set_roster call. - VfxView.configure() called _ready() before add_child() triggered Godot's _ready() again, creating two Sprite2Ds per effect (double overdraw). Added an _ensure_sprite validity guard like UnitView. - VFX manifest was reopened + JSON-parsed per effect spawn (~16/sec under held taps); now cached in a static. - SfxPlayer._played (test-only telemetry) grew unbounded; capped at 64. Save/profile: - muted and low_power were written by settings but absent from DEFAULT_PROFILE, so _normalize() dropped them on every save -> settings never persisted. Added to defaults + migration; save_corruption_test verifies. - An unclaimed offline report was overwritten by the next launch after any intervening save, silently losing earned gold. build_offline_report now preserves a pending report; p3b test models claim/clear between scenarios. - hero_levels values are clamped to 1..10000 (negative/huge values gave free or overflowing upgrade costs) and unlocked_heroes is deduped (repeat ids triple-counted roster DPS). Robustness: - hit-stop restore coroutine now uses a generation token so a stale coroutine cannot end a newer hit-stop after clear_all. Full gate P2_CHECKS_PASS. All logs still 0 script/parse errors and 0 lambda- capture errors. prototype/ untracked.
110 lines
4.1 KiB
GDScript
110 lines
4.1 KiB
GDScript
extends SceneTree
|
|
|
|
## Visible-node cap evidence for P2-BAT-03.
|
|
##
|
|
## The contract allows at most five full enemy nodes and five visible hero
|
|
## nodes in the battle stage. Background heroes must not get a Sprite or a
|
|
## collision body. This test supplies more content than the cap and checks
|
|
## the actual node counts, including after the content shrinks again.
|
|
|
|
const OUTPUT_PATH := "res://artifacts/visible_node_test.json"
|
|
|
|
var _problems: Array = []
|
|
var _steps: Array = []
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _run() -> void:
|
|
var scene = load("res://scripts/battle_scene.gd").new()
|
|
root.add_child(scene)
|
|
var battle := scene as BattleScene
|
|
battle.set_process(false)
|
|
battle.setup("zh_CN", "P3A-N03-SEMI", 10001)
|
|
|
|
var heroes: Array = []
|
|
for hero_id in ["H01", "H02", "H04", "H05", "H06", "H03"]:
|
|
heroes.append({"id": hero_id, "signature": "auto", "energy": 0.0, "energy_max": 100.0})
|
|
battle.hud.set_roster(heroes)
|
|
|
|
var enemies: Array = []
|
|
for index in range(7):
|
|
enemies.append({
|
|
"id": "E-R1-F1-V1#%d" % (index + 1),
|
|
"content_id": "E-R1-F1-V1",
|
|
"kind": "normal", "hp": 100.0, "max_hp": 100.0,
|
|
"armor": 1.0, "shield": 0.0, "weak_tag": "aoe",
|
|
"shield_broken": false, "dead": false,
|
|
})
|
|
battle.hud.set_enemies(enemies, "")
|
|
await process_frame
|
|
await process_frame
|
|
|
|
var counts := battle.hud.visible_node_counts()
|
|
_check(int(counts["enemy_units"]) <= 5, "enemy unit count %s exceeds 5" % str(counts["enemy_units"]))
|
|
_check(int(counts["enemy_plates"]) <= 5, "enemy plate count %s exceeds 5" % str(counts["enemy_plates"]))
|
|
_check(int(counts["enemy_hit_areas"]) <= 5, "enemy hit area count %s exceeds 5" % str(counts["enemy_hit_areas"]))
|
|
_check(int(counts["hero_units"]) <= 5, "visible hero unit count %s exceeds 5" % str(counts["hero_units"]))
|
|
_record("over_cap_content", counts)
|
|
|
|
# Non-visible heroes must not have spawned any art: only H01 has an atlas,
|
|
# so a leaked unit for H02/H04 would fail to configure and stay absent.
|
|
_check(int(counts["hero_units"]) == 5, "the hero cap should render exactly 5 units, got %s" % str(counts["hero_units"]))
|
|
|
|
# set_roster runs every frame; calling it again with identical data must
|
|
# reuse the same card nodes, not rebuild them (perf regression: ~2100
|
|
# nodes/sec were allocated before the diff-by-id fix).
|
|
var ids_before: Array = battle.hud.roster_card_ids_for_test()
|
|
battle.hud.set_roster(heroes)
|
|
await process_frame
|
|
var ids_after: Array = battle.hud.roster_card_ids_for_test()
|
|
if ids_before != ids_after:
|
|
_problems.append("set_roster rebuilt cards with identical roster: %s -> %s" % [str(ids_before), str(ids_after)])
|
|
_record("roster_reuse", {"before": ids_before.size(), "after": ids_after.size(), "same": ids_before == ids_after})
|
|
|
|
# Shrinking the content must release the stale nodes.
|
|
battle.hud.set_enemies(enemies.slice(0, 1), "")
|
|
battle.hud.set_roster(heroes.slice(0, 1))
|
|
await process_frame
|
|
await process_frame
|
|
var shrunk := battle.hud.visible_node_counts()
|
|
_check(int(shrunk["enemy_units"]) == 1, "stale enemy units were not released")
|
|
_check(int(shrunk["hero_units"]) == 1, "stale hero units were not released")
|
|
_record("after_shrink", shrunk)
|
|
|
|
var passed := _problems.is_empty()
|
|
var report := {
|
|
"schema": 1,
|
|
"kind": "windroost_visible_node_test",
|
|
"overall": "PASS" if passed else "FAIL",
|
|
"problems": _problems,
|
|
"steps": _steps,
|
|
}
|
|
var artifact_dir := ProjectSettings.globalize_path("res://artifacts")
|
|
DirAccess.make_dir_recursive_absolute(artifact_dir)
|
|
var file := FileAccess.open(artifact_dir.path_join("visible_node_test.json"), FileAccess.WRITE)
|
|
if file != null:
|
|
file.store_string(JSON.stringify(report, "\t", true))
|
|
file.close()
|
|
|
|
for entry in _steps:
|
|
print("VISIBLE_NODE_STEP %s" % JSON.stringify(entry))
|
|
if passed:
|
|
print("VISIBLE_NODE_PASS caps and stale-node cleanup verified")
|
|
else:
|
|
print("VISIBLE_NODE_FAIL %s" % "; ".join(_problems))
|
|
quit(0 if passed else 1)
|
|
|
|
|
|
func _check(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
_problems.append(message)
|
|
|
|
|
|
func _record(name: String, data: Dictionary) -> void:
|
|
var entry := data.duplicate()
|
|
entry["step"] = name
|
|
_steps.append(entry)
|