Source-bound Ancient Soul wallet codec, outsider definitions/levels/bonuses, TP and sacrifice math from clicker_heroes_rebuild @46cc8ad. Additive schema v7 fields with provenance; WR sky_marks/edicts left untouched. Save-first, exactly-once claim, strict import, migration and real ScreenTouch probes.
211 lines
9.2 KiB
GDScript
211 lines
9.2 KiB
GDScript
extends SceneTree
|
|
|
|
## S3 runtime/touch evidence for the CH transcendence/outsider slice.
|
|
## Every flow step is driven by Input.parse_input_event(InputEventScreenTouch)
|
|
## through the real viewport/Control routing -- no button callback is invoked
|
|
## directly. Covers 360/390/430 x zh/en x normal/reduced portrait viewports.
|
|
|
|
const OUTPUT_PATH := "res://artifacts/transcendence_touch_test.json"
|
|
const Wallet = preload("res://scripts/ancient_soul_wallet.gd")
|
|
const SIZES := [Vector2i(360, 800), Vector2i(390, 844), Vector2i(430, 932)]
|
|
const LOCALES := ["zh_CN", "en_US"]
|
|
const REDUCED := [false, true]
|
|
|
|
var _problems: Array = []
|
|
var _steps: Array = []
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _check(cond: bool, msg: String) -> void:
|
|
if not cond:
|
|
_problems.append(msg)
|
|
|
|
|
|
func _record(name: String, data: Dictionary) -> void:
|
|
var e := data.duplicate()
|
|
e["step"] = name
|
|
_steps.append(e)
|
|
|
|
|
|
func _run() -> void:
|
|
var root_window := get_root()
|
|
for size in SIZES:
|
|
for locale in LOCALES:
|
|
for reduced in REDUCED:
|
|
await _case(root_window, size as Vector2i, str(locale), bool(reduced))
|
|
_finish()
|
|
|
|
|
|
func _case(root_window: Window, size: Vector2i, locale: String, reduced: bool) -> void:
|
|
var tag := "%dx%d/%s/%s" % [size.x, size.y, locale, "reduced" if reduced else "normal"]
|
|
root_window.content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS
|
|
root_window.content_scale_size = size
|
|
root_window.size = size
|
|
await _wait_frames(3)
|
|
|
|
var shell := load("res://scenes/game_root.tscn").instantiate() as GameRoot
|
|
root_window.add_child(shell)
|
|
await _wait_frames(2)
|
|
shell.set_locale_for_test(locale)
|
|
shell.set_reduced_motion_for_test(reduced)
|
|
shell.reset_profile_for_test()
|
|
var gp := shell.get_profile()
|
|
gp["completed_nodes"] = ["R1-C01-N10"]
|
|
gp["completed_regions"] = 5
|
|
gp["hero_levels"] = {"H01": 4000}
|
|
gp["primal_souls"] = 2
|
|
gp["hero_souls"] = 0
|
|
gp["oath_souls_spent"] = 0
|
|
gp["hero_souls_sacrificed"] = 0
|
|
gp["ancient_souls"] = {}
|
|
ProfileStore.save_profile(gp)
|
|
shell.show_page_for_test("skyport")
|
|
shell.refresh_pages_for_test()
|
|
await _wait_frames(4)
|
|
|
|
# 1. Real touch opens the prestige preview; the CH-derived Ancient Soul line
|
|
# and TP must be readable in both locales.
|
|
var viewport_size := root_window.get_visible_rect().size
|
|
var prestige_rect := shell.u2_target_rect_for_test("skyport_action_prestige")
|
|
_check(prestige_rect != Rect2(), "%s: prestige button has no rect" % tag)
|
|
var scroll := shell.find_skyport_scroll_for_test()
|
|
if scroll != null:
|
|
scroll.scroll_horizontal = int(maxf(0.0, prestige_rect.position.x - (viewport_size.x - prestige_rect.size.x) * 0.5))
|
|
scroll.scroll_vertical = int(maxf(0.0, prestige_rect.position.y - viewport_size.y * 0.5))
|
|
await _wait_frames(2)
|
|
prestige_rect = shell.u2_target_rect_for_test("skyport_action_prestige")
|
|
await _tap(prestige_rect.get_center())
|
|
await _wait_frames(2)
|
|
_check(shell.get_modal_visible_for_test(), "%s: prestige touch did not open modal" % tag)
|
|
var body := shell.get_modal_body_for_test()
|
|
var ancient_word := "远古之魂" if locale == "zh_CN" else "Ancient Souls"
|
|
_check(body.contains(ancient_word), "%s: preview must show Ancient Soul reward line" % tag)
|
|
_check(not body.contains("[shell.prestige.ancient_gain]"), "%s: ancient_gain locale key missing" % tag)
|
|
var pv := shell.transcendence_preview_for_test()
|
|
_check(int(pv.get("earned_total", -1)) == 3, "%s: preview earned total must be 3" % tag)
|
|
_check(bool(pv.get("can_transcend")), "%s: preview must allow transcendence" % tag)
|
|
_record("preview", {"case": tag, "body": body, "earned": int(pv.get("earned_total", -1)),
|
|
"tp": float(pv.get("transcendent_power", -1)),
|
|
"actions": shell.get_modal_actions_for_test().get_child_count()})
|
|
|
|
# 2. Real touch on transcend settles the wallet exactly once and persists it.
|
|
var confirm_center := shell.modal_button_center_for_test("confirm_transcendence")
|
|
_check(confirm_center != Vector2.ZERO, "%s: transcendence button has no rect" % tag)
|
|
await _tap(confirm_center)
|
|
await _wait_frames(2)
|
|
var p := shell.get_profile()
|
|
_check(int(p.get("transcensions", -1)) == 1, "%s: transcensions must be 1" % tag)
|
|
_check(str((p.get("ancient_souls", {}) as Dictionary).get("balance", "")) != "",
|
|
"%s: ancient soul wallet must be written" % tag)
|
|
_check(int((p.get("last_transcendence", {}) as Dictionary).get("earned_total", -1)) == 3,
|
|
"%s: receipt earned_total must be 3" % tag)
|
|
_check(int((p.get("transcensions", -1))) == 1, "%s: repeat touch must not double-settle" % tag)
|
|
var reloaded := ProfileStore.load_profile()
|
|
_check(int(reloaded.get("transcensions", -1)) == 1, "%s: transcensions must persist" % tag)
|
|
_check((reloaded.get("ancient_souls", {}) as Dictionary).has("wallet_codec"),
|
|
"%s: wallet codec must persist" % tag)
|
|
_record("confirm", {"case": tag, "transcensions": p.get("transcensions"),
|
|
"wallet": p.get("ancient_souls"), "persisted": reloaded.get("ancient_souls")})
|
|
|
|
# 3. Close result, reopen prestige, then real-touch into the outsider shop.
|
|
var close_center := shell.modal_button_center_for_test("map")
|
|
_check(close_center != Vector2.ZERO, "%s: result close has no rect" % tag)
|
|
await _tap(close_center)
|
|
await _wait_frames(2)
|
|
shell.show_page_for_test("skyport")
|
|
shell.refresh_pages_for_test()
|
|
await _wait_frames(3)
|
|
prestige_rect = shell.u2_target_rect_for_test("skyport_action_prestige")
|
|
if scroll != null:
|
|
scroll.scroll_vertical = int(maxf(0.0, prestige_rect.position.y - viewport_size.y * 0.5))
|
|
await _wait_frames(2)
|
|
prestige_rect = shell.u2_target_rect_for_test("skyport_action_prestige")
|
|
await _tap(prestige_rect.get_center())
|
|
await _wait_frames(2)
|
|
var shop_center := shell.modal_button_center_for_test("open_outsider_shop")
|
|
_check(shop_center != Vector2.ZERO, "%s: outsider shop button has no rect" % tag)
|
|
await _tap(shop_center)
|
|
await _wait_frames(2)
|
|
_check(shell.get_modal_visible_for_test(), "%s: outsider shop did not open" % tag)
|
|
var shop_body := shell.get_modal_body_for_test()
|
|
_check(shop_body.contains("Phandoryss") or shop_body.contains("Ponyboy"),
|
|
"%s: outsider shop must list source-bound outsiders" % tag)
|
|
_check(not shop_body.contains("[shell.prestige.ancient_shop]"), "%s: shop locale key missing" % tag)
|
|
_record("shop", {"case": tag, "body": shop_body,
|
|
"actions": shell.get_modal_actions_for_test().get_child_count()})
|
|
|
|
# 4. Real touch buys Ponyboy (id 5): +100% primal reward is visible in the
|
|
# primal preview, and the wallet debit persists. TP itself depends only
|
|
# on total, which a buy must never change (CH m22908).
|
|
var tp_before_buy := shell.transcendent_power_for_test()
|
|
var buy_center := shell.modal_button_center_for_test("buy_outsider:5")
|
|
_check(buy_center != Vector2.ZERO, "%s: Ponyboy buy button has no rect" % tag)
|
|
await _tap(buy_center)
|
|
await _wait_frames(2)
|
|
var after_buy := shell.get_profile()
|
|
var wallet: Dictionary = after_buy["ancient_souls"]
|
|
_check(int((wallet["levels"] as Dictionary).get("5", 0)) == 1, "%s: Ponyboy level must be 1" % tag)
|
|
_check(str(wallet["balance"]) == Wallet.raw(2.0), "%s: wallet balance debited to 2" % tag)
|
|
_check(str(wallet["total"]) == Wallet.raw(3.0), "%s: total unchanged by buy" % tag)
|
|
_check(shell.transcendent_primal_reward_for_test(105) == 235,
|
|
"%s: Ponyboy L1 (x11) gives transcendent primal reward 105 = 235" % tag)
|
|
_check(is_equal_approx(shell.transcendent_power_for_test(), tp_before_buy),
|
|
"%s: a level buy must not change TP (total unchanged)" % tag)
|
|
var reloaded2 := ProfileStore.load_profile()
|
|
var wallet2: Dictionary = reloaded2["ancient_souls"]
|
|
_check(int((wallet2["levels"] as Dictionary).get("5", 0)) == 1, "%s: outsider level must persist" % tag)
|
|
_record("buy", {"case": tag, "wallet": wallet, "primal_105": shell.transcendent_primal_reward_for_test(105),
|
|
"persisted_level": (wallet2["levels"] as Dictionary).get("5", 0)})
|
|
|
|
root_window.remove_child(shell)
|
|
shell.free()
|
|
await process_frame
|
|
|
|
|
|
func _wait_frames(count: int) -> void:
|
|
for _i in range(count):
|
|
await process_frame
|
|
# frame_post_draw is intentionally not awaited here: in this isolated probe
|
|
# the signal can stall the headless render loop. process_frame awaits already
|
|
# give every queued Control its layout pass.
|
|
await process_frame
|
|
|
|
|
|
func _tap(position: Vector2) -> void:
|
|
var down := InputEventScreenTouch.new()
|
|
down.index = 12
|
|
down.position = position
|
|
down.pressed = true
|
|
Input.parse_input_event(down)
|
|
await process_frame
|
|
await process_frame
|
|
var up := InputEventScreenTouch.new()
|
|
up.index = 12
|
|
up.position = position
|
|
up.pressed = false
|
|
Input.parse_input_event(up)
|
|
await process_frame
|
|
await process_frame
|
|
|
|
|
|
func _finish() -> void:
|
|
var passed := _problems.is_empty()
|
|
var report := {"schema": 1, "kind": "windroost_transcendence_touch_test",
|
|
"input_method": "Input.parse_input_event(InputEventScreenTouch)",
|
|
"matrix": {"sizes": ["360x800", "390x844", "430x932"], "locales": LOCALES, "reduced": REDUCED},
|
|
"overall": "PASS" if passed else "FAIL", "problems": _problems, "steps": _steps}
|
|
var dir := ProjectSettings.globalize_path("res://artifacts")
|
|
DirAccess.make_dir_recursive_absolute(dir)
|
|
var out := FileAccess.open(dir.path_join("transcendence_touch_test.json"), FileAccess.WRITE)
|
|
if out != null:
|
|
out.store_string(JSON.stringify(report, "\t", true))
|
|
out.close()
|
|
if passed:
|
|
print("TRANSCEND_TOUCH_PASS %d real ScreenTouch cases verified" % (_steps.size() / 4))
|
|
else:
|
|
print("TRANSCEND_TOUCH_FAIL %s" % "; ".join(_problems))
|
|
quit(0 if passed else 1)
|