Files
windroost/tools/fullgame/check_side_depth_parity.py
T
wushenghua 65cb4d331d feat: commissions and partners get real differentiated rules (stage H)
User asked how the quest/mercenary/relic systems are implemented in the new
game. Relics were already done (stage F). Commissions and partners were thin
flat counters, so per FINAL_GAME_DESIGN 11.1 ("no second combat system") they
are now genuinely differentiated SIDE systems:

- commission_board.py/.gd: 4 task types driven by distinct real counters
  (battle_wins/completed_nodes/talent_count/prestige_count), each paying a
  different currency (gold/crystal/fragments/sky marks). No daily pressure,
  progress-gated repeats, no miss penalty.
- partner_perks.py/.gd: 5 partner specialties -> 5 distinct side rules
  (offline gold / gear drops / record rewards / revive charges / rift rewards),
  scaling with partner level. P03 hooked into side_systems.claim_record and P01
  into profile_store.build_offline_report as REAL payout mutators.
- test_side_depth.py PASS 6 checks; check_side_depth_parity.py PASS 3 cases
  python==gd (existing side-systems parity still passes); run_side_depth_ui_test
  PASS in real game_root (4 types pay 4 currencies, 5 perks active).
- 3 new gates; full P2_CHECKS_PASS (92 gates), identity preserved.

Combat systems A-G plus side systems H now all have real differentiated
mechanisms. Owner gates (human play feel/device/release) remain open.
prototype/ untracked.
2026-11-19 14:52:58 +08:00

77 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""Gate: GDScript commission/partner side-depth mirrors Python byte-for-byte."""
import json
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT / "tools"))
sys.path.insert(0, str(Path(__file__).parent))
import commission_board as CB
import partner_perks as PP
GD_JSON = ROOT / "p2_godot_sample" / "artifacts" / "side_depth_parity_gd.json"
GODOT = "/Applications/Godot.app/Contents/MacOS/Godot"
PROJECT = ROOT / "p2_godot_sample"
PROFILES = [
{"battle_wins": 13, "completed_nodes": ["a", "b", "c"], "talents": {"t1": 1},
"rebuild_count": 2, "new_sky_count": 1, "gold": 0, "crystal": 0,
"star_fragments": 0, "sky_marks": 0},
{"battle_wins": 3, "completed_nodes": ["a"], "talents": {},
"highest_node": 45, "relics": {"L1": 1},
"claimed_rewards": [f"A{i}" for i in range(1, 10)],
"rebuild_count": 0, "new_sky_count": 2},
{},
]
def deep_equal(a, b, path=""):
if isinstance(a, dict) and isinstance(b, dict):
if set(a) != set(b):
return [f"{path} keys {set(a)} != {set(b)}"]
out = []
for k in a:
out += deep_equal(a[k], b[k], f"{path}.{k}")
return out
if isinstance(a, list) and isinstance(b, list):
if len(a) != len(b):
return [f"{path} len {len(a)} != {len(b)}"]
out = []
for i, (x, y) in enumerate(zip(a, b)):
out += deep_equal(x, y, f"{path}[{i}]")
return out
if isinstance(a, (int, float)) and isinstance(b, (int, float)):
return [] if abs(float(a) - float(b)) <= 1e-4 else [f"{path} {a} != {b}"]
return [] if a == b else [f"{path} {a} != {b}"]
def main() -> int:
r = subprocess.run([GODOT, "--headless", "--path", str(PROJECT),
"--script", "res://scripts/side_depth_parity_test.gd"],
capture_output=True, text=True, timeout=180)
if r.returncode != 0 or "SIDE_DEPTH_PARITY_GD" not in r.stdout:
print("SIDE_DEPTH_PARITY_FAIL emitter failed")
print(r.stdout[-400:], r.stderr[-400:])
return 1
gd = json.loads(GD_JSON.read_text())["results"]
problems = []
for case in gd:
p = PROFILES[case["i"]]
py = {"commission_status": CB.status(p), "perks": PP.compute(p),
"record_paid": PP.apply_record_reward(p, 20, 5),
"offline_paid": PP.apply_offline(p, 1000)}
for key in py:
problems += deep_equal(py[key], case[key], f"case{case['i']}.{key}")
if problems:
print(f"SIDE_DEPTH_PARITY_FAIL {len(problems)} mismatch(es)")
for p in problems[:20]:
print(" " + p)
return 1
print(f"SIDE_DEPTH_PARITY_PASS {len(gd)} cases, python==gd")
return 0
if __name__ == "__main__":
raise SystemExit(main())