909 lines
42 KiB
GDScript
909 lines
42 KiB
GDScript
extends SceneTree
|
|
|
|
## GUI-only visual ownership probe for M52 Market. It writes static-only,
|
|
## dynamic-only-on-neutral and final composite PNGs for each shipped fixture.
|
|
|
|
const MarketPageView = preload("res://entry/views/market_page_view.gd")
|
|
const InkCheck = preload("res://tools/ui_ink_check.gd")
|
|
const MarketController = preload("res://entry/market_page_controller.gd")
|
|
const MarketChrome = preload("res://ui/shared/market_chrome.gd")
|
|
# Single authoritative size (owner policy): every page is authored at 1280x720.
|
|
const FIXTURES := [
|
|
{"width": 1280, "height": 720},
|
|
]
|
|
# M82 acceptance matrix: the reference size gates, the smoke size only records.
|
|
const SMOKE_FIXTURES := [
|
|
{"width": 1280, "height": 600},
|
|
]
|
|
# Wide capture: the centered 1280x720 canvas and the aspect-cover background are
|
|
# recorded here but do not gate; minimum and reference still gate.
|
|
const WIDE_FIXTURES := [
|
|
{"width": 1600, "height": 720},
|
|
]
|
|
const STATE_KINDS := ["empty", "recruit", "hired"]
|
|
# Bounded settle: headless runs never emit frame_post_draw, so every wait is a
|
|
# fixed number of process frames (the m53/m54/m67/m68 probes settle the same way).
|
|
const SETTLE_FRAMES := 3
|
|
const LOCALES := ["zh_CN", "en"]
|
|
# Accessibility pass: 1.0 plus the shipped 130% text scale (M73).
|
|
const TEXT_SCALES := [1.0, 1.3]
|
|
var output_root := ""
|
|
var trace := false
|
|
var ink_scanned := 0
|
|
var ink_violations: Array = []
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("_run")
|
|
|
|
func _run() -> void:
|
|
if OS.get_environment("ABG_EVIDENCE_DIR").is_empty():
|
|
push_error("Market visual probe requires the owned test-attempt runner")
|
|
quit(1)
|
|
return
|
|
output_root = OS.get_environment("ABG_EVIDENCE_DIR").path_join("market-visual-probe")
|
|
trace = OS.get_environment("ABG_M82_TRACE") == "1"
|
|
DirAccess.make_dir_recursive_absolute(output_root)
|
|
var self_test := InkCheck.self_test(root)
|
|
if self_test.size() < 3:
|
|
push_error("M59 ink self-test expected at least 3 violations, got %d" % self_test.size())
|
|
quit(1)
|
|
return
|
|
print("ABG_M59_INK_SELF_TEST_OK violations=%d" % self_test.size())
|
|
ink_scanned = 0
|
|
ink_violations = []
|
|
var only_state := ""
|
|
var args := OS.get_cmdline_user_args()
|
|
if args.size() > 0:
|
|
only_state = String(args[0])
|
|
for fixture in FIXTURES:
|
|
for locale in LOCALES:
|
|
for scale in TEXT_SCALES:
|
|
for state_kind in STATE_KINDS:
|
|
if not only_state.is_empty() and String(state_kind) != only_state:
|
|
continue
|
|
await _capture_fixture(int(fixture.width), int(fixture.height), String(locale), false, String(state_kind), float(scale), true)
|
|
if float(scale) == 1.0:
|
|
await _capture_fixture(int(fixture.width), int(fixture.height), String(locale), true, "recruit", float(scale))
|
|
await _capture_fixture(int(fixture.width), int(fixture.height), String(locale), false, "equipment", float(scale))
|
|
for fixture in SMOKE_FIXTURES:
|
|
for locale in LOCALES:
|
|
for scale in TEXT_SCALES:
|
|
for state_kind in STATE_KINDS:
|
|
await _capture_fixture(int(fixture.width), int(fixture.height), String(locale), false, String(state_kind), float(scale), true)
|
|
for fixture in WIDE_FIXTURES:
|
|
for locale in LOCALES:
|
|
for scale in TEXT_SCALES:
|
|
for state_kind in STATE_KINDS:
|
|
await _capture_fixture(int(fixture.width), int(fixture.height), String(locale), false, String(state_kind), float(scale), false)
|
|
if not ink_violations.is_empty():
|
|
for violation in ink_violations:
|
|
push_error("M59 ink violation %s %s %s %s [%s] %s: %s" % [
|
|
violation.variant, violation.locale, violation.size, violation.kind,
|
|
violation.path, violation.node, violation.detail,
|
|
])
|
|
print("ABG_M59_INK_CHECK_FAIL scanned=%d violations=%d" % [ink_scanned, ink_violations.size()])
|
|
quit(1)
|
|
return
|
|
print("ABG_M59_INK_CHECK_OK scanned=%d violations=0" % ink_scanned)
|
|
var copy_failures := _copy_purity_failures()
|
|
if not copy_failures.is_empty():
|
|
for failure in copy_failures:
|
|
push_error("M85 market copy: %s" % failure)
|
|
print("ABG_M85_MARKET_COPY_FAIL failures=%d" % copy_failures.size())
|
|
quit(1)
|
|
return
|
|
print("ABG_M85_MARKET_COPY_OK zh=no_latin en=unchanged scope=short_context_detail")
|
|
print("ABG_M82_MARKET_STATE_MATRIX_OK empty=clean available=ok hired=ok title_ink=inside targets=48 viewports=reference:1280x720,minimum:1280x600,wide:1600x720 gates=reference+minimum")
|
|
print("ABG_M52_MARKET_VISUAL_PROBE_OK viewports=3 gated=2 locale_count=2 states=empty,available,hired scales=1.0,1.3 scans=%d views=static,dynamic,final" % ink_scanned)
|
|
quit(0)
|
|
|
|
func _dock_bounds(view: Control, ui_factor := 1.0) -> Dictionary:
|
|
# The row lives inside the centred canvas; its authored x/y tokens are checked
|
|
# in canvas-authored space (inverse of the canvas transform), while the physical
|
|
# hit floor stays on real screen pixels.
|
|
var back := view.find_child("MarketBackGuild", true, false) as Button
|
|
var ret := view.find_child("MarketReturnContract", true, false) as Button
|
|
if back == null or ret == null:
|
|
return {"ok": false, "detail": "missing dock command"}
|
|
var canvas := view.find_child("MarketMasterCanvas", true, false) as Control
|
|
var to_authored := Transform2D.IDENTITY
|
|
if canvas != null:
|
|
to_authored = canvas.get_global_transform_with_canvas().affine_inverse()
|
|
var b_global: Rect2 = back.get_global_rect()
|
|
var r_global: Rect2 = ret.get_global_rect()
|
|
var b := _transform_rect(to_authored, b_global)
|
|
var r := _transform_rect(to_authored, r_global)
|
|
var problems: Array = []
|
|
if int(b.position.x) < 40 or int(b.position.x) > 80:
|
|
problems.append("back_left=%d (authored)" % int(b.position.x))
|
|
if int(r.end.x) < 1200 or int(r.end.x) > 1272:
|
|
problems.append("return_right=%d (authored)" % int(r.end.x))
|
|
if absf(b.size.y - r.size.y) > 2.0:
|
|
problems.append("height %d vs %d" % [int(b.size.y), int(r.size.y)])
|
|
if absf(b.position.y - r.position.y) > 2.0:
|
|
problems.append("baseline %d vs %d" % [int(b.position.y), int(r.position.y)])
|
|
# Physical floor on real screen pixels; the authored ceiling stays on the
|
|
# canvas-authored rect (no scale factor, no tolerance multiplier).
|
|
if b_global.size.y < 48.0:
|
|
problems.append("back_height=%.0fpx play (floor 48)" % b_global.size.y)
|
|
if b.size.y > 60.0:
|
|
problems.append("back_height=%d authored exceeds the 60px token" % int(b.size.y))
|
|
var detail := "authored back x %d..%d y %d..%d | return x %d..%d y %d..%d | play h=%.0f" % [
|
|
int(b.position.x), int(b.end.x), int(b.position.y), int(b.end.y),
|
|
int(r.position.x), int(r.end.x), int(r.position.y), int(r.end.y), b_global.size.y,
|
|
]
|
|
if not problems.is_empty():
|
|
return {"ok": false, "detail": "%s | %s" % [",".join(problems), detail]}
|
|
return {"ok": true, "detail": detail}
|
|
|
|
|
|
func _transform_rect(xform: Transform2D, rect: Rect2) -> Rect2:
|
|
var a := xform * rect.position
|
|
var b_pt := xform * Vector2(rect.end.x, rect.position.y)
|
|
var c := xform * Vector2(rect.position.x, rect.end.y)
|
|
var d := xform * rect.end
|
|
var xs := [a.x, b_pt.x, c.x, d.x]
|
|
var ys := [a.y, b_pt.y, c.y, d.y]
|
|
xs.sort()
|
|
ys.sort()
|
|
return Rect2(xs[0], ys[0], xs[xs.size() - 1] - xs[0], ys[ys.size() - 1] - ys[0])
|
|
|
|
|
|
func _variant_label(longest: bool, kind: String, text_scale: float = 1.0) -> String:
|
|
var base := kind if kind != "recruit" else ("longest" if longest else "normal")
|
|
return base if is_equal_approx(text_scale, 1.0) else "%s@%.1f" % [base, text_scale]
|
|
|
|
|
|
func _capture_fixture(width: int, height: int, locale: String, longest: bool, kind: String = "recruit", text_scale: float = 1.0, strict := true) -> void:
|
|
# M82: the project pins the OS window at 1280x720 (resizable off), so a capture
|
|
# must come from a viewport authored at the requested size. A SubViewport gives
|
|
# exact pixels for every viewport class and keeps the page's canvas/aspect rules
|
|
# honest. Requested and actual sizes are both recorded.
|
|
var sub := SubViewport.new()
|
|
sub.name = "M82CaptureViewport"
|
|
sub.size = Vector2i(width, height)
|
|
sub.render_target_update_mode = SubViewport.UPDATE_ALWAYS
|
|
sub.transparent_bg = false
|
|
root.add_child(sub)
|
|
var capture_size := sub.size
|
|
var capture_w := capture_size.x
|
|
var capture_h := capture_size.y
|
|
print("ABG_M82_TRACE capture requested=%dx%d actual=%dx%d strict=%s" % [
|
|
width, height, capture_size.x, capture_size.y, str(strict)])
|
|
if capture_size.x != width or capture_size.y != height:
|
|
ink_violations.append({"node": "Capture", "kind": "viewport", "path": kind,
|
|
"variant": _variant_label(longest, kind, text_scale), "locale": locale,
|
|
"size": "%dx%d" % [capture_size.x, capture_size.y],
|
|
"detail": "requested %dx%d but captured %dx%d" % [width, height, capture_size.x, capture_size.y]})
|
|
# M82: one geometry source only. The view enters the requested-size SubViewport
|
|
# first, then a full-rect preset with zeroed offsets owns its size; setting
|
|
# `view.size` as well doubled the layout (full anchors + size offsets).
|
|
var view := MarketPageView.new()
|
|
view.name = "MarketVisualProbeView"
|
|
view.configure_presentation({"safe_area": 24, "text_scale": text_scale, "locale": locale})
|
|
sub.add_child(view)
|
|
view.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
view.offset_left = 0.0
|
|
view.offset_top = 0.0
|
|
view.offset_right = 0.0
|
|
view.offset_bottom = 0.0
|
|
await _settle()
|
|
_note("%s before_render" % kind)
|
|
view.render(_fixture_data(locale, longest, kind))
|
|
_note("%s after_render" % kind)
|
|
await _settle()
|
|
_note("%s after_first_settle" % kind)
|
|
var label := _variant_label(longest, kind, text_scale)
|
|
var final_path := "%s/%s-%dx%d-%s-final.png" % [output_root, locale, capture_size.x, capture_size.y, label]
|
|
await _save_image(sub, final_path)
|
|
for problem in _edge_bar_problems(final_path):
|
|
if strict:
|
|
ink_violations.append({"node": "MarketCoverage", "kind": "bars", "path": kind,
|
|
"variant": label, "locale": locale, "size": "%dx%d" % [capture_size.x, capture_size.y],
|
|
"detail": problem})
|
|
else:
|
|
print("ABG_M82_SMOKE_NOTE %dx%d %s %s bars: %s" % [capture_size.x, capture_size.y, locale, label, problem])
|
|
|
|
_trace_coverage(view, Vector2(capture_size))
|
|
var violations := InkCheck.scan(view)
|
|
for problem in _coverage_problems(view, Vector2(capture_size)):
|
|
violations.append({"node": "MarketCoverage", "kind": "coverage", "path": kind, "detail": problem})
|
|
_note("%s after_scan" % kind)
|
|
if strict:
|
|
for problem in _state_problems(view, kind, locale, text_scale):
|
|
violations.append({"node": "MarketLedgerState", "kind": "state", "path": kind, "detail": problem})
|
|
ink_scanned += 1
|
|
if label == "normal":
|
|
var dock := _dock_bounds(view, minf(float(capture_w) / 1280.0, float(capture_h) / 720.0))
|
|
if not bool(dock.get("ok", false)):
|
|
violations.append({"node": "MarketDockRow", "kind": "bounds", "path": "footer", "detail": String(dock.get("detail", ""))})
|
|
elif locale == "zh_CN" and is_equal_approx(text_scale, 1.0):
|
|
print("ABG_M52_MARKET_DOCK_BOUNDS_OK %s" % String(dock.get("detail", "")))
|
|
for violation in violations:
|
|
violation["variant"] = label
|
|
violation["locale"] = locale
|
|
violation["size"] = "%dx%d" % [capture_size.x, capture_size.y]
|
|
if strict:
|
|
ink_violations.append(violation)
|
|
else:
|
|
print("ABG_M82_SMOKE_NOTE %dx%d %s %s %s %s" % [capture_size.x, capture_size.y, locale, label,
|
|
String(violation.get("kind", "?")), String(violation.get("node", "?"))])
|
|
|
|
var page := view.find_child("M52MarketDesignPage", true, false) as Control
|
|
if page != null:
|
|
page.visible = false
|
|
await _settle()
|
|
await _save_image(sub, "%s/%s-%dx%d-%s-static.png" % [output_root, locale, capture_size.x, capture_size.y, label])
|
|
if page != null:
|
|
page.visible = true
|
|
var background := view.find_child("M52MarketWorldBackground", true, false) as Control
|
|
var matte := view.find_child("MarketMasterMatte", true, false) as Control
|
|
if background != null:
|
|
background.visible = false
|
|
if matte != null:
|
|
matte.visible = false
|
|
var neutral := ColorRect.new()
|
|
neutral.name = "NeutralProbeBackground"
|
|
neutral.color = Color("#26353c")
|
|
neutral.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
neutral.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
view.add_child(neutral)
|
|
view.move_child(neutral, 0)
|
|
await _settle()
|
|
await _save_image(sub, "%s/%s-%dx%d-%s-dynamic.png" % [output_root, locale, capture_size.x, capture_size.y, label])
|
|
sub.queue_free()
|
|
await _settle()
|
|
_note("%s done" % kind)
|
|
|
|
|
|
func _settle() -> void:
|
|
for _frame in range(SETTLE_FRAMES):
|
|
await process_frame
|
|
|
|
|
|
func _note(label: String) -> void:
|
|
if trace:
|
|
print("ABG_M82_TRACE %s" % label)
|
|
|
|
|
|
func _state_problems(view: Control, kind: String, locale: String, text_scale: float) -> Array:
|
|
var problems: Array = []
|
|
var ledger := view.find_child("MarketContextSurface", true, false) as Control
|
|
if ledger == null:
|
|
problems.append("no ledger surface")
|
|
return problems
|
|
var selected_only := ["PortraitModule", "IdentityModule", "ProfessionModule", "TraitModule", "CostModule"]
|
|
var action_names := ["ActionButton", "MarketReviewRecruit", "MarketReviewEquipment", "MarketReviewRoute"]
|
|
var state_shell := ledger.find_child("LedgerShell", true, false)
|
|
var skip_now := PackedStringArray()
|
|
var skip_text := String(state_shell.get("ledger_row_skip")) if state_shell != null else ""
|
|
if not skip_text.is_empty():
|
|
skip_now = PackedStringArray(skip_text.split(","))
|
|
var portrait_module := ledger.find_child("PortraitModule", true, false)
|
|
if kind != "empty":
|
|
if portrait_module == null:
|
|
problems.append("portrait module missing")
|
|
else:
|
|
var portrait_control := portrait_module as Control
|
|
if not portrait_control.visible:
|
|
problems.append("portrait module is hidden")
|
|
# The authored slot is asserted in the stack scope; here the play-size
|
|
# and the inner viewport must prove the subject is really readable.
|
|
var play_h := _play_size(portrait_control).y
|
|
if play_h < 130.0:
|
|
problems.append("portrait play height %.0fpx is below the 130px subject floor" % play_h)
|
|
var viewport_node := portrait_module.find_child("PortraitViewport", true, false) as Control
|
|
if viewport_node == null or _play_size(viewport_node).y < 90.0:
|
|
problems.append("portrait viewport is shorter than the 90px floor for this viewport")
|
|
var subject: Texture2D = portrait_module.get("portrait_texture") as Texture2D
|
|
var image_node := portrait_module.find_child("PortraitImage", true, false) as TextureRect
|
|
if subject == null:
|
|
problems.append("portrait has no subject texture")
|
|
elif image_node == null or image_node.texture == null:
|
|
problems.append("portrait image layer is empty")
|
|
if kind == "empty":
|
|
# M82: the empty state owns a different information architecture *and* a
|
|
# different painted surface: no portrait frame, no dock band, one hint.
|
|
var empty_shell := ledger.find_child("LedgerShell", true, false)
|
|
if empty_shell == null or String(empty_shell.get_meta("chrome_variant", "")) != "ledger_empty":
|
|
problems.append("empty state is not painted by the ledger_empty variant")
|
|
for module_name in selected_only:
|
|
if ledger.find_child(module_name, true, false) != null:
|
|
problems.append("empty state exposes %s" % module_name)
|
|
for action_name in action_names:
|
|
if ledger.find_child(action_name, true, false) != null:
|
|
problems.append("empty state exposes action dock %s" % action_name)
|
|
var hint := ledger.find_child("MarketEmptyHint", true, false)
|
|
if hint == null:
|
|
problems.append("empty state has no hint")
|
|
var banned := RegEx.new()
|
|
banned.compile("已招募|HIRED|\\d+\\s*(金币|COIN)")
|
|
for label in _labels(ledger):
|
|
var found := banned.search(String(label.text))
|
|
if found != null:
|
|
problems.append("empty state prints selected copy: %s" % String(label.text))
|
|
else:
|
|
for module_name in selected_only:
|
|
if ledger.find_child(module_name, true, false) == null:
|
|
problems.append("%s state lacks %s" % [kind, module_name])
|
|
var dock := _action_dock(ledger, action_names)
|
|
if skip_now.has("dock"):
|
|
# A state without an action says so everywhere: no painted band, no
|
|
# reserved height, no visible dock.
|
|
if dock != null and (dock as Control).visible:
|
|
problems.append("%s state has no action but shows a dock" % kind)
|
|
elif dock == null:
|
|
problems.append("%s state lacks its action dock" % kind)
|
|
elif not (dock as Control).visible:
|
|
problems.append("%s action dock is hidden" % kind)
|
|
elif _play_size(dock as Control).y < 48.0 or _play_size(dock as Control).x < 48.0:
|
|
var play := _play_size(dock as Control)
|
|
problems.append("%s action dock play rect is %.0fx%.0f (floor 48)" % [kind, play.x, play.y])
|
|
else:
|
|
var dock_button := dock as Button
|
|
if dock_button == null:
|
|
problems.append("%s action dock is not a button" % kind)
|
|
elif dock_button.disabled:
|
|
problems.append("%s action dock is disabled" % kind)
|
|
var availability := _label_text(ledger, "CostModule")
|
|
if kind == "hired":
|
|
if not (availability.contains("已招募") or availability.contains("HIRED")):
|
|
problems.append("hired state lost its HIRED semantics: %s" % availability)
|
|
elif availability.contains("已招募") or availability.contains("HIRED"):
|
|
problems.append("available state prints HIRED: %s" % availability)
|
|
var header := ledger.find_child("LedgerHeader", true, false) as Label
|
|
if header == null:
|
|
problems.append("ledger header missing")
|
|
else:
|
|
problems.append_array(_title_slot_problems(ledger, header))
|
|
if kind != "empty":
|
|
problems.append_array(_detail_problems(ledger))
|
|
problems.append_array(_cost_geometry_problems(ledger))
|
|
var hint_node := ledger.find_child("MarketEmptyHint", true, false)
|
|
if hint_node == null and kind == "empty":
|
|
problems.append("empty state hint disappeared")
|
|
if kind != "empty":
|
|
problems.append_array(_stack_order_problems(ledger))
|
|
_trace_stack(ledger, kind, locale, text_scale)
|
|
return problems
|
|
|
|
func _stack_order_problems(ledger: Control) -> Array:
|
|
# M82: one measurement contract means the painted stack and the placed modules
|
|
# share an order. Every rect must be contained in the ledger and the rows must
|
|
# not overlap in the order band -> portrait -> identity -> profession -> detail
|
|
# -> trait -> cost -> dock.
|
|
var problems: Array = []
|
|
var shell := ledger.find_child("LedgerShell", true, false)
|
|
var title_h := 36.0
|
|
var detail_h := 46.0
|
|
var ui_scale := 1.0
|
|
var skip_rows := ""
|
|
if shell != null and "ledger_title_height" in shell:
|
|
title_h = float(shell.ledger_title_height)
|
|
detail_h = float(shell.ledger_detail_height)
|
|
ui_scale = float(shell.ledger_text_scale)
|
|
skip_rows = String(shell.ledger_row_skip)
|
|
skip_rows = String(shell.ledger_row_skip)
|
|
var skip := PackedStringArray()
|
|
if not skip_rows.is_empty():
|
|
skip = PackedStringArray(skip_rows.split(","))
|
|
var stack: Dictionary = MarketChrome.ledger_stack(ledger.size, title_h, detail_h, ui_scale, skip)
|
|
var ledger_rect := ledger.get_global_rect()
|
|
# M82: the selected ledger is 2D. The top block (subject left, identity and
|
|
# profession right) sits under the band; detail/trait/cost/dock follow below.
|
|
var order: Array = []
|
|
if stack.has("top_block"):
|
|
order.append(["band", "top_block"])
|
|
var side_ok := float(stack.portrait.end.x) <= float(stack.identity.position.x) + 0.5
|
|
if not side_ok:
|
|
problems.append("portrait and identity overlap horizontally")
|
|
order.append(["top_block", "detail"])
|
|
else:
|
|
order.append(["band", "portrait"])
|
|
for pair in [["detail", "trait"], ["trait", "cost"], ["cost", "dock"]]:
|
|
if float(stack[pair[0]].size.y) > 4.0 and float(stack[pair[1]].size.y) > 4.0:
|
|
order.append(pair)
|
|
for pair in order:
|
|
var upper: Rect2 = _authored_global(ledger, stack[pair[0]])
|
|
var lower: Rect2 = _authored_global(ledger, stack[pair[1]])
|
|
if upper.end.y > lower.position.y + 0.5:
|
|
problems.append("stack order %s.end.y %.1f > %s.y %.1f" % [pair[0], upper.end.y, pair[1], lower.position.y])
|
|
# The floor is checked on the authoring stack: a slot squeezed to zero must
|
|
# fail even if the ledger then hides the module (that hid a real regression).
|
|
if float(stack.portrait.size.y) < 130.0:
|
|
problems.append("portrait slot is %.0fpx tall (subject floor 130)" % float(stack.portrait.size.y))
|
|
for key in ["band", "portrait", "identity", "profession", "detail", "trait", "cost", "dock"]:
|
|
var rect: Rect2 = _authored_global(ledger, stack[key])
|
|
if not ledger_rect.encloses(rect):
|
|
problems.append("stack %s escapes the ledger (%s vs %s)" % [key, rect, ledger_rect])
|
|
# the placed nodes must match their authored rect (a module that grows past its
|
|
# slot is the root of the overlap the owner saw)
|
|
var placed := [["PortraitModule", "portrait"], ["IdentityModule", "identity"],
|
|
["ProfessionModule", "profession"], ["DetailCopy", "detail"],
|
|
["TraitModule", "trait"], ["CostModule", "cost"],
|
|
["ActionButton", "dock"], ["MarketReviewRecruit", "dock"], ["MarketReviewEquipment", "dock"]]
|
|
for pair in placed:
|
|
var node := ledger.find_child(String(pair[0]), true, false) as Control
|
|
if node == null or not node.visible:
|
|
continue
|
|
var node_rect := node.get_global_rect()
|
|
var authored: Rect2 = _authored_global(ledger, stack[pair[1]])
|
|
if node_rect.position.y < authored.position.y - 0.5 or node_rect.end.y > authored.end.y + 0.5:
|
|
problems.append("%s grows past its slot (node y %.1f..%.1f slot y %.1f..%.1f)" % [pair[0],
|
|
node_rect.position.y, node_rect.end.y, authored.position.y, authored.end.y])
|
|
return problems
|
|
|
|
func _detail_problems(ledger: Control) -> Array:
|
|
# The detail must show every line it wrapped: no overrun trimming, and the
|
|
# visible line count equals the wrapped count (M82 defect: "Company 8 -...").
|
|
var problems: Array = []
|
|
var detail := ledger.find_child("DetailCopy", true, false)
|
|
if detail == null:
|
|
return problems
|
|
var label := detail.find_child("DetailLabel", true, false) as Label
|
|
if label == null:
|
|
return problems
|
|
if label.text_overrun_behavior != TextServer.OVERRUN_NO_TRIMMING:
|
|
problems.append("detail trims its text (overrun behavior)")
|
|
if label.get_line_count() > label.get_visible_line_count():
|
|
problems.append("detail hides %d of %d wrapped lines" % [
|
|
label.get_line_count() - label.get_visible_line_count(), label.get_line_count()])
|
|
return problems
|
|
|
|
func _cost_geometry_problems(ledger: Control) -> Array:
|
|
# The coin socket and the two strings share one row: none of them may overlap.
|
|
var problems: Array = []
|
|
var cost_module := ledger.find_child("CostModule", true, false) as Control
|
|
if cost_module == null:
|
|
return problems
|
|
var icon := cost_module.find_child("CoinIcon", true, false) as Control
|
|
var status_label := cost_module.find_child("AvailabilityLabel", true, false) as Label
|
|
var cost_label := cost_module.find_child("CostLabel", true, false) as Label
|
|
if icon != null and status_label != null:
|
|
if icon.get_global_rect().intersects(InkCheck.ink_rect(status_label)):
|
|
problems.append("coin icon overlaps the availability text")
|
|
if status_label != null and cost_label != null:
|
|
if InkCheck.ink_rect(status_label).intersects(InkCheck.ink_rect(cost_label)):
|
|
problems.append("availability and amount ink overlap")
|
|
return problems
|
|
|
|
func _play_size(node: Control) -> Vector2:
|
|
# The canvas transform scales rendering only, so a node's own rect stays in
|
|
# design space. Measuring through `get_global_transform_with_canvas()` gives the
|
|
# actual play pixels the player sees, and the gates below compare them against
|
|
# fixed physical thresholds (never a scaled threshold).
|
|
var xform := node.get_global_transform_with_canvas()
|
|
var node_scale := xform.get_scale()
|
|
return Vector2(node.size.x * node_scale.x, node.size.y * node_scale.y)
|
|
|
|
|
|
func _authored_global(ledger: Control, local: Rect2) -> Rect2:
|
|
# Authored rects live in the ledger's own space; convert through the node
|
|
# transform instead of assuming an unscaled canvas.
|
|
var origin: Vector2 = ledger.get_global_transform() * local.position
|
|
var corner: Vector2 = ledger.get_global_transform() * local.end
|
|
return Rect2(origin, corner - origin)
|
|
|
|
func _trace_stack(ledger: Control, kind: String, locale: String, scale: float) -> void:
|
|
if not trace:
|
|
return
|
|
var shell := ledger.find_child("LedgerShell", true, false)
|
|
var title_h := 36.0
|
|
var detail_h := 46.0
|
|
var ui_scale := 1.0
|
|
var skip_rows := ""
|
|
if shell != null and "ledger_title_height" in shell:
|
|
title_h = float(shell.ledger_title_height)
|
|
detail_h = float(shell.ledger_detail_height)
|
|
ui_scale = float(shell.ledger_text_scale)
|
|
skip_rows = String(shell.ledger_row_skip)
|
|
_trace_inventory(ledger, kind)
|
|
_trace_floors(ledger, kind)
|
|
print("ABG_M82_TRACE transform %s %s@%.1f global_rect=%s scale=%s" % [kind, locale, scale,
|
|
str(ledger.get_global_rect()),
|
|
str(ledger.get_global_rect().size / ledger.size) if ledger.size.x > 0.0 else "n/a"])
|
|
print("ABG_M82_TRACE rects %s %s@%.1f ledger_size=%s title_h=%.1f detail_h=%.1f ui=%.2f skip=%s" % [
|
|
kind, locale, scale, str(ledger.size), title_h, detail_h, ui_scale, skip_rows])
|
|
var trace_skip := PackedStringArray()
|
|
if not skip_rows.is_empty():
|
|
trace_skip = PackedStringArray(skip_rows.split(","))
|
|
var stack: Dictionary = MarketChrome.ledger_stack(ledger.size, title_h, detail_h, ui_scale, trace_skip)
|
|
for key in ["band", "portrait", "identity", "profession", "detail", "trait", "cost", "dock"]:
|
|
var slot: Rect2 = stack[key]
|
|
print("ABG_M82_TRACE local %-10s %s" % [key, str(slot)])
|
|
for node_name in ["LedgerHeader", "PortraitModule", "IdentityModule", "ProfessionModule", "DetailCopy", "TraitModule", "CostModule"]:
|
|
var node := ledger.find_child(node_name, true, false) as Control
|
|
if node != null:
|
|
print("ABG_M82_TRACE global %-16s pos=%s size=%s" % [node_name, str(node.global_position), str(node.size)])
|
|
|
|
func _coverage_problems(view: Control, viewport_size: Vector2) -> Array:
|
|
# AGENTS: centred design canvas for geometry, aspect-cover for the world
|
|
# background. Everything is compared in the capture viewport's own space.
|
|
var problems: Array = []
|
|
var view_rect := view.get_global_rect()
|
|
if absf(view_rect.position.x) > 1.0 or absf(view_rect.position.y) > 1.0 \
|
|
or absf(view_rect.size.x - viewport_size.x) > 1.0 or absf(view_rect.size.y - viewport_size.y) > 1.0:
|
|
problems.append("view %s != viewport %s" % [str(view_rect), str(viewport_size)])
|
|
var background := view.find_child("M52MarketWorldBackground", true, false) as Control
|
|
if background == null:
|
|
problems.append("world background node missing")
|
|
else:
|
|
var bg := background.get_global_rect()
|
|
if absf(bg.position.x) > 1.0 or absf(bg.position.y) > 1.0 \
|
|
or absf(bg.size.x - viewport_size.x) > 1.0 or absf(bg.size.y - viewport_size.y) > 1.0:
|
|
problems.append("world background %s != viewport %s" % [str(bg), str(viewport_size)])
|
|
var canvas := view.find_child("MarketMasterCanvas", true, false) as Control
|
|
if canvas == null:
|
|
problems.append("master canvas node missing")
|
|
else:
|
|
var art := canvas.get_global_rect()
|
|
var expect_h := minf(viewport_size.y, viewport_size.x * 9.0 / 16.0)
|
|
var expect_w := expect_h * 16.0 / 9.0
|
|
var expect_x := (viewport_size.x - expect_w) * 0.5
|
|
if absf(art.position.x - expect_x) > 1.5 or absf(art.size.x - expect_w) > 1.5 or absf(art.size.y - expect_h) > 1.5:
|
|
problems.append("master canvas %s != centred 16:9 %s" % [str(art),
|
|
str(Rect2(expect_x, 0.0, expect_w, expect_h))])
|
|
return problems
|
|
|
|
|
|
func _trace_coverage(view: Control, viewport_size: Vector2) -> void:
|
|
if not trace:
|
|
return
|
|
var background := view.find_child("M52MarketWorldBackground", true, false) as Control
|
|
var canvas := view.find_child("MarketMasterCanvas", true, false) as Control
|
|
print("ABG_M82_TRACE coverage viewport=%s view=%s background=%s canvas=%s" % [
|
|
str(viewport_size), str(view.get_global_rect()),
|
|
str(background.get_global_rect()) if background != null else "missing",
|
|
str(canvas.get_global_rect()) if canvas != null else "missing"])
|
|
|
|
|
|
func _edge_bar_problems(image_path: String) -> Array:
|
|
# A clear-colour bar on any edge fails the capture (aspect-cover background).
|
|
var problems: Array = []
|
|
var image := Image.new()
|
|
if image.load(image_path) != OK:
|
|
problems.append("saved frame could not be read back")
|
|
return problems
|
|
var clear: Color = ProjectSettings.get_setting("rendering/environment/defaults/default_clear_color", Color(0.3, 0.3, 0.3))
|
|
var w := image.get_width()
|
|
var h := image.get_height()
|
|
var edges := {
|
|
"left": [[1, h / 4], [1, h / 2], [1, (h * 3) / 4]],
|
|
"right": [[w - 2, h / 4], [w - 2, h / 2], [w - 2, (h * 3) / 4]],
|
|
"top": [[w / 4, 1], [w / 2, 1], [(w * 3) / 4, 1]],
|
|
"bottom": [[w / 4, h - 2], [w / 2, h - 2], [(w * 3) / 4, h - 2]],
|
|
}
|
|
for edge in edges:
|
|
var matches := 0
|
|
for point in edges[edge]:
|
|
var px := image.get_pixel(int(point[0]), int(point[1]))
|
|
if absf(px.r - clear.r) < 0.02 and absf(px.g - clear.g) < 0.02 and absf(px.b - clear.b) < 0.02:
|
|
matches += 1
|
|
if matches >= 2:
|
|
problems.append("%s edge shows the clear colour" % edge)
|
|
return problems
|
|
|
|
|
|
func _trace_floors(ledger: Control, kind: String) -> void:
|
|
if not trace or kind == "empty":
|
|
return
|
|
var portrait := ledger.find_child("PortraitModule", true, false) as Control
|
|
var viewport_node := ledger.find_child("PortraitViewport", true, false) if portrait != null else null
|
|
var dock := ledger.find_child("ActionButton", true, false) as Control
|
|
if dock == null:
|
|
dock = ledger.find_child("MarketReviewRecruit", true, false) as Control
|
|
print("ABG_M82_TRACE floors %s portrait_play=%.1f inner_play=%.1f dock_play=%s" % [
|
|
kind,
|
|
_play_size(portrait).y if portrait != null else -1.0,
|
|
_play_size(viewport_node as Control).y if viewport_node != null else -1.0,
|
|
"%.1fx%.1f" % [_play_size(dock).x, _play_size(dock).y] if dock != null else "none"])
|
|
|
|
|
|
func _trace_inventory(ledger: Control, kind: String) -> void:
|
|
if not trace:
|
|
return
|
|
var shell := ledger.find_child("LedgerShell", true, false)
|
|
var variant := String(shell.get_meta("chrome_variant", "ledger")) if shell != null else "missing"
|
|
var selected_only := ["PortraitModule", "IdentityModule", "ProfessionModule", "TraitModule", "CostModule"]
|
|
var present: Array[String] = []
|
|
for module_name in selected_only:
|
|
if ledger.find_child(module_name, true, false) != null:
|
|
present.append(module_name)
|
|
var hint := ledger.find_child("MarketEmptyHint", true, false) != null
|
|
var dock := ledger.find_child("ActionButton", true, false)
|
|
if dock == null:
|
|
dock = ledger.find_child("MarketReviewRecruit", true, false)
|
|
var dock_state := "none"
|
|
if dock is Control:
|
|
var button := dock as Button
|
|
dock_state = "h=%.0f enabled=%s" % [dock.size.y, str(button != null and not button.disabled)]
|
|
print("ABG_M82_TRACE inventory %s variant=%s selected_only=%s hint=%s dock=%s" % [
|
|
kind, variant, str(present), str(hint), dock_state])
|
|
|
|
func _action_dock(ledger: Control, names: Array) -> Control:
|
|
for action_name in names:
|
|
var dock := ledger.find_child(String(action_name), true, false) as Control
|
|
if dock != null:
|
|
return dock
|
|
return null
|
|
|
|
func _label_text(ledger: Control, module_name: String) -> String:
|
|
var module := ledger.find_child(module_name, true, false)
|
|
if module == null:
|
|
return ""
|
|
var copy := ""
|
|
for label in _labels(module):
|
|
copy += String(label.text) + " "
|
|
return copy.strip_edges()
|
|
|
|
func _labels(node: Node) -> Array:
|
|
var found: Array = []
|
|
for child in node.get_children():
|
|
if child is Label:
|
|
found.append(child)
|
|
found.append_array(_labels(child))
|
|
return found
|
|
|
|
func _title_slot_problems(ledger: Control, header: Label) -> Array:
|
|
# The assertion reads the same contract the ledger and the chrome use, so the
|
|
# probe can never disagree with the painted band.
|
|
var shell := ledger.find_child("LedgerShell", true, false)
|
|
var title_h := 36.0
|
|
var detail_h := 46.0
|
|
var ui_scale := 1.0
|
|
if shell != null and "ledger_title_height" in shell:
|
|
title_h = float(shell.ledger_title_height)
|
|
detail_h = float(shell.ledger_detail_height)
|
|
ui_scale = float(shell.ledger_text_scale)
|
|
var mode := String(shell.get_meta("chrome_variant", "ledger")) if shell != null else "ledger"
|
|
var stack: Dictionary = MarketChrome.ledger_empty_stack(ledger.size, title_h) \
|
|
if mode == "ledger_empty" else MarketChrome.ledger_stack(ledger.size, title_h, detail_h, ui_scale)
|
|
var band: Rect2 = stack.band
|
|
var divider_y: float = stack.divider_y
|
|
var slot := Rect2(ledger.global_position + Vector2(0.06 * ledger.size.x, band.position.y + 2.0),
|
|
Vector2(0.88 * ledger.size.x, maxf(12.0, divider_y - 4.0) - (band.position.y + 2.0)))
|
|
var ink: Rect2 = InkCheck.ink_rect(header)
|
|
var problems: Array = []
|
|
if ink.position.y < slot.position.y - 1.0 or ink.end.y > slot.end.y + 1.0:
|
|
problems.append("title ink escapes the band slot (ink y %.1f..%.1f slot y %.1f..%.1f)"
|
|
% [ink.position.y, ink.end.y, slot.position.y, slot.end.y])
|
|
if ink.end.y > ledger.global_position.y + divider_y:
|
|
problems.append("title ink crosses the band divider")
|
|
return problems
|
|
|
|
|
|
func _save_image(source: Node, path: String) -> void:
|
|
# The image comes from the capture viewport that owns the page, so its pixels
|
|
# match the requested viewport class instead of the pinned OS window.
|
|
if source == null or not is_instance_valid(source):
|
|
return
|
|
var viewport := source as Viewport
|
|
if viewport == null or not is_instance_valid(viewport):
|
|
return
|
|
var texture := viewport.get_texture()
|
|
if texture != null:
|
|
texture.get_image().save_png(path)
|
|
|
|
func _fixture_data(locale: String, longest := false, kind: String = "recruit") -> Dictionary:
|
|
if kind == "empty":
|
|
return _empty_fixture(locale)
|
|
if kind == "equipment":
|
|
return _equipment_fixture(locale, longest)
|
|
if kind == "hired":
|
|
return _hired_fixture(locale)
|
|
var is_zh := locale == "zh_CN"
|
|
var names := (
|
|
["卡珊德拉", "奥莉薇娅", "风语者"]
|
|
if longest and is_zh
|
|
else ["Gannet Faircurrent", "Cassa Stonebloom", "Hessa Quillwater"]
|
|
if longest
|
|
else ["阿里", "布兰", "塞拉"] if is_zh else ["Ari", "Bram", "Cera"]
|
|
)
|
|
return {
|
|
"ok": true,
|
|
"page_id": "market",
|
|
"locale": locale,
|
|
"category": "recruit",
|
|
"selected_kind": "recruit",
|
|
"selected_offer_id": "R-001",
|
|
"selected_offer": _recruit("R-001", names[0], locale, longest),
|
|
"offers": {
|
|
"recruit": [
|
|
_recruit("R-001", names[0], locale, longest),
|
|
_recruit("R-002", names[1], locale, longest),
|
|
_recruit("R-003", names[2], locale, longest),
|
|
],
|
|
},
|
|
"available": {"recruit": ["R-001", "R-002", "R-003"]},
|
|
"company": (
|
|
{"owned_count": 8, "line_capacity": 8, "coin": 999}
|
|
if longest
|
|
else {"owned_count": 2, "line_capacity": 4, "coin": 38}
|
|
),
|
|
"commands": {"return_contract": {"enabled": true, "reason": "ready"}},
|
|
# A selected offer is inspectable in the real page, so the available state
|
|
# carries its review facts (the empty fixture erases them again).
|
|
"review": {"available": true, "action": "recruit_review", "reason": "inspectable"},
|
|
}
|
|
|
|
|
|
func _empty_fixture(locale: String) -> Dictionary:
|
|
# M82 no_selection: offers exist, nothing is picked, so the ledger must show
|
|
# only its header and one hint.
|
|
var data := _fixture_data(locale, false, "recruit")
|
|
data["selected_offer_id"] = ""
|
|
data["selected_offer"] = {}
|
|
data.erase("review")
|
|
return data
|
|
|
|
|
|
func _hired_fixture(locale: String) -> Dictionary:
|
|
# M60-I03: one offer is already hired; the card must say so clearly while
|
|
# staying inspectable, and the ledger must read HIRED.
|
|
var is_zh := locale == "zh_CN"
|
|
# The shipped fixture must speak the locale it claims: EN carries the shipped
|
|
# English names, not the Chinese ones.
|
|
var hired_offer := _recruit("R-001", "甘尼特" if is_zh else "Gannet", locale, true)
|
|
var available_offer := _recruit("R-002", "卡珊德拉" if is_zh else "Cassandra", locale, true)
|
|
var data := _fixture_data(locale, true, "recruit")
|
|
data["offers"] = {"recruit": [hired_offer, available_offer]}
|
|
data["selected_offer_id"] = "R-001"
|
|
data["selected_offer"] = hired_offer
|
|
data["available"] = {"recruit": ["R-002"]}
|
|
data["review"] = {"available": true, "action": "recruit_review", "reason": "inspectable"}
|
|
return data
|
|
|
|
|
|
func _equipment_fixture(locale: String, longest: bool) -> Dictionary:
|
|
# Real catalog identity: EQ-002 定步护胫 / Frontpin Greaves and EQ-012
|
|
# 开线绳结 / Open-Line Cord with their shipped effect/fit/tradeoff copy.
|
|
var is_zh := locale == "zh_CN"
|
|
var items := [
|
|
{
|
|
"catalog_id": "EQ-002",
|
|
"name": "定步护胫" if is_zh else "Frontpin Greaves",
|
|
"effect": "在完成一次基础行动前,抵抗敌方第一次推动。" if is_zh else "Resists the enemy's first push until a basic action completes.",
|
|
"fit": "服装;前排" if is_zh else "Clothing; front line",
|
|
"tradeoff": "完成该基础行动后自身迟滞 1 tick。" if is_zh else "The wearer lags 1 tick after that action.",
|
|
"price": 12,
|
|
},
|
|
{
|
|
"catalog_id": "EQ-012",
|
|
"name": "开线绳结" if is_zh else "Open-Line Cord",
|
|
"effect": "前方没有相邻队友时,基础行动射程 +1。" if is_zh else "Basic action range +1 while no ally stands ahead.",
|
|
"fit": "饰品;任意位置" if is_zh else "Trinket; any slot",
|
|
"tradeoff": "前方出现队友时,立即取消已保留的远距目标。" if is_zh else "An ally moving ahead cancels the held far target.",
|
|
"price": 999 if longest else 18,
|
|
},
|
|
]
|
|
var offers: Array = []
|
|
var available: Array = []
|
|
for index in range(4):
|
|
var item: Dictionary = items[index % items.size()]
|
|
var offer_id := "E-%03d" % (index + 1)
|
|
offers.append({
|
|
"offer_id": offer_id,
|
|
"catalog_id": String(item.catalog_id),
|
|
"list_price": int(item.price),
|
|
"presentation": {
|
|
"title": String(item.name),
|
|
"detail": "%s\n%s\n%s" % [String(item.effect), String(item.fit), String(item.tradeoff)],
|
|
"short_detail": "%s\n%s" % [String(item.name), String(item.effect)],
|
|
"price": "%d %s" % [int(item.price), "金币" if is_zh else "COIN"],
|
|
"state": "inspectable",
|
|
"state_text": "可检查" if is_zh else "INSPECTABLE",
|
|
"recruit_name": "",
|
|
"profession_name": "",
|
|
"trait_name": "",
|
|
},
|
|
})
|
|
available.append(offer_id)
|
|
return {
|
|
"ok": true,
|
|
"page_id": "market",
|
|
"locale": locale,
|
|
"category": "equipment",
|
|
"selected_kind": "equipment",
|
|
"selected_offer_id": "E-001",
|
|
"selected_offer": offers[0],
|
|
"offers": {"equipment": offers},
|
|
"available": {"equipment": available},
|
|
"company": {"owned_count": 2, "line_capacity": 4, "coin": 38},
|
|
"commands": {"return_contract": {"enabled": true, "reason": "ready"}},
|
|
"review": {"available": true, "action": "equipment_review", "reason": "inspectable"},
|
|
}
|
|
|
|
|
|
func _recruit(offer_id: String, recruit_name: String, locale: String, longest := false) -> Dictionary:
|
|
var is_zh := locale == "zh_CN"
|
|
# Real per-offer identity: three different base professions so the board
|
|
# renders three different portraits. A single hardcoded profession_id made
|
|
# the capture show three copies of one recruit.
|
|
var index := int(offer_id.trim_prefix("R-"))
|
|
var slot := clampi(index - 1, 0, 2)
|
|
var profession_ids := ["PF-B01", "PF-B05", "PF-B07"]
|
|
var zh_professions := ["盾卫", "弓手", "治疗"]
|
|
var en_professions := ["Hearthguard", "Farstring", "Kindhand"]
|
|
var zh_traits := ["最后见证", "稳固阵线", "夜航直觉"]
|
|
var en_traits := ["Last Witness", "Steady Line", "Night Sense"]
|
|
var list_prices := [14, 18, 22]
|
|
var company_from := 2
|
|
if longest:
|
|
# Longest shipped strings measured from the runtime catalog: base
|
|
# professions 护心卫士/逐风行者/远弦射手 and Hearthguard/Wayrunner/
|
|
# Farstring, traits 反转带扣/Turncoat Buckle (15 glyphs), recruit names
|
|
# from the display-name pool, three-digit coin and a full 8/8 line.
|
|
profession_ids = ["PF-B01", "PF-B04", "PF-B05"]
|
|
zh_professions = ["护心卫士", "逐风行者", "远弦射手"]
|
|
en_professions = ["Hearthguard", "Wayrunner", "Farstring"]
|
|
zh_traits = ["反转带扣", "松散阵形", "最后见证"]
|
|
en_traits = ["Turncoat Buckle", "Loose Formation", "Last Witness"]
|
|
list_prices = [999, 998, 997]
|
|
company_from = 8
|
|
# The production context line is two short rows built by the Market
|
|
# controller ("profession · trait" then price and Company growth). Keep the
|
|
# fixture in that authored shape so the ledger slot is exercised honestly.
|
|
var zh_details := [
|
|
"%s · %s\n%d 金币 · 队伍 %d → %d" % [zh_professions[slot], zh_traits[slot], list_prices[slot], company_from, company_from + 1],
|
|
"%s · %s\n%d 金币 · 队伍 %d → %d" % [zh_professions[1], zh_traits[1], list_prices[1], company_from, company_from + 1],
|
|
"%s · %s\n%d 金币 · 队伍 %d → %d" % [zh_professions[2], zh_traits[2], list_prices[2], company_from, company_from + 1],
|
|
]
|
|
var en_details := [
|
|
"%s · %s\n%d COIN · Company %d -> %d" % [en_professions[slot], en_traits[slot], list_prices[slot], company_from, company_from + 1],
|
|
"%s · %s\n%d COIN · Company %d -> %d" % [en_professions[1], en_traits[1], list_prices[1], company_from, company_from + 1],
|
|
"%s · %s\n%d COIN · Company %d -> %d" % [en_professions[2], en_traits[2], list_prices[2], company_from, company_from + 1],
|
|
]
|
|
return {
|
|
"source_offer_id": offer_id,
|
|
"display_name_tokens": [recruit_name],
|
|
"recruit_name": recruit_name,
|
|
"profession_id": profession_ids[slot],
|
|
"trait_id": "TR-%03d" % (slot + 1),
|
|
"list_price": list_prices[slot],
|
|
"presentation": {
|
|
"recruit_name": recruit_name,
|
|
"profession_name": zh_professions[slot] if is_zh else en_professions[slot],
|
|
"trait_name": zh_traits[slot] if is_zh else en_traits[slot],
|
|
"short_detail": zh_details[slot] if is_zh else en_details[slot],
|
|
},
|
|
}
|
|
|
|
|
|
func _copy_purity_failures() -> Array:
|
|
# The assertion runs on the production helper, not on a hand-written fixture.
|
|
var failures: Array = []
|
|
var controller = MarketController.new()
|
|
var offer := {"profession_id": "PF-B01", "trait_id": "TR-001", "list_price": 999}
|
|
var company := {"owned_recruits": [1, 2, 3, 4, 5, 6, 7, 8]}
|
|
var zh := String(controller.short_context_detail("recruit", offer, company, "zh_CN", {}))
|
|
var en := String(controller.short_context_detail("recruit", offer, company, "en", {}))
|
|
var latin := RegEx.new()
|
|
latin.compile("[A-Za-z]")
|
|
if latin.search(zh) != null:
|
|
failures.append("zh line still carries latin letters: %s" % zh)
|
|
if not zh.contains("金币") or not zh.contains("队伍"):
|
|
failures.append("zh line lost its localized nouns: %s" % zh)
|
|
if not (en.contains("COIN") or en.contains("Coin")) or not en.contains("Company"):
|
|
failures.append("en line shape changed: %s" % en)
|
|
# The rendered fixture must obey the same purity: the frame is the artefact the
|
|
# player sees, so a drift between production and fixture has to fail here.
|
|
for spec in [["zh_CN", 1, 1], ["en", 0, 0]]:
|
|
var locale := String(spec[0])
|
|
var data := _fixture_data(locale, true, "recruit")
|
|
var fixture_offer := Dictionary(data.get("selected_offer", {}))
|
|
# The fixture declares the rendered detail under presentation.short_detail.
|
|
var line := String(Dictionary(fixture_offer.get("presentation", {})).get("short_detail", ""))
|
|
if line.is_empty():
|
|
failures.append("%s fixture renders no detail line" % locale)
|
|
continue
|
|
if locale == "zh_CN":
|
|
if latin.search(line) != null:
|
|
failures.append("zh fixture line carries latin letters: %s" % line)
|
|
if line.count("金币") != int(spec[1]) or line.count("队伍") != int(spec[2]):
|
|
failures.append("zh fixture line repeats or misses its nouns (%d/%d): %s" % [
|
|
line.count("金币"), line.count("队伍"), line])
|
|
else:
|
|
if not line.contains("COIN") or not line.contains("Company"):
|
|
failures.append("en fixture line lost its shape: %s" % line)
|
|
return failures
|