Continued PRODUCTION/51. Oaths were flat "+4% storm/+2% roster each": - oath_rules.py / .gd: 26 oaths -> 18 distinct combat rules (crit/elemental DoT/execute/armor-break/combo/energy/cooldown/ultimate/summon/cleanse/click...) + 8 honest out-of-combat meta rules. O14 scoped to ultimate only. - hero_skill_loader gained active_oaths param (identity preserved); game_root injects profile.oaths on the live P3a path. - test_oath_rules.py PASS 7 checks; check_oath_rules_parity.py PASS 9 cases python==gd; run_oath_rules_ui_test.sh PASS in real game_root (O03 adds 4 poison effects/22 events, O13 cooldown x0.8, meta O09 no change). - 3 new gates; full P2_CHECKS_PASS (88 gates), identity preserved. ALL 7 STAGES COMPLETE (A-G). Every previously-flattened system now has real differentiated mechanisms, dual-engine parity, focused/distinctness gates, and live-runtime proof: skills, talents, edicts, enemy/boss mechanics, relics, oaths. Achievements verified to already be genuinely differentiated. prototype/ untracked.
107 lines
4.0 KiB
Python
107 lines
4.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Stage G: oaths must be distinct real rules, not flat +4% storm."""
|
|
import json
|
|
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 oath_rules as OR
|
|
import hero_skill_loader as HSL
|
|
import mvp_validation_sim as sim
|
|
|
|
SKILLS = json.loads((ROOT / "data" / "hero_skills.json").read_text(encoding="utf-8"))
|
|
CONTENT = json.loads((ROOT / "data" / "full_game_content.json").read_text(encoding="utf-8"))
|
|
HERO_STATS = {h["id"]: h for h in CONTENT["heroes"]}
|
|
RULES = sim.Rules(sim.read_json(ROOT / "data" / "mvp_battle_rules.json"))
|
|
|
|
|
|
def check(cond, msg):
|
|
if not cond:
|
|
raise AssertionError(msg)
|
|
|
|
|
|
def with_oath(oid, hero="H01"):
|
|
base = HSL.build_skills([hero], SKILLS, HERO_STATS)
|
|
out = HSL.build_skills([hero], SKILLS, HERO_STATS, active_oaths={oid: True})
|
|
return base, out
|
|
|
|
|
|
def signature(skills):
|
|
return [(s.get("interval"), tuple((e["type"], e.get("value"), e.get("stat", ""))
|
|
for e in s["effects"])) for s in skills]
|
|
|
|
|
|
def test_integrity():
|
|
check(not OR.validate(), "26 oaths, >=15 combat")
|
|
check({o["id"] for o in CONTENT["oaths"]} == set(OR.OATH_RULES), "all pack oaths defined")
|
|
c = OR.classify({f"O{i:02d}": True for i in range(1, 27)})
|
|
check(len(c["combat"]) == 18 and len(c["meta"]) == 8, "18 combat + 8 meta")
|
|
|
|
|
|
def test_meta_not_faked():
|
|
for oid in ("O09", "O17", "O26"):
|
|
base, out = with_oath(oid)
|
|
check(signature(base) == signature(out), f"{oid} meta oath does not alter combat")
|
|
|
|
|
|
def test_combat_oaths_change_skills():
|
|
for oid in ("O01", "O03", "O04", "O12", "O13", "O16", "O22"):
|
|
base, out = with_oath(oid)
|
|
check(signature(base) != signature(out), f"{oid} combat oath changes skills")
|
|
|
|
|
|
def test_distinct_rules():
|
|
sigs = {}
|
|
for oid in ("O01", "O02", "O03", "O04", "O05", "O12", "O13"):
|
|
_, out = with_oath(oid)
|
|
sigs[oid] = repr(signature(out))
|
|
check(len(set(sigs.values())) >= 6, f"oath rules mostly distinct: {[(k, v[:40]) for k, v in sigs.items()]}")
|
|
|
|
|
|
def test_slot_scoped_ultimate():
|
|
# O14 is ultimate-only: only the ultimate skill gets the extra damage.
|
|
base, out = with_oath("O14")
|
|
for a, b in zip(base, out):
|
|
if a["hero_id"].endswith(":ultimate"):
|
|
check(len(b["effects"]) > len(a["effects"]), "O14 boosts ultimate")
|
|
else:
|
|
check(len(b["effects"]) == len(a["effects"]), "O14 does not touch non-ultimate")
|
|
|
|
|
|
def test_oath_changes_battle():
|
|
def run(skills):
|
|
sc = {"id": "OATH-TEST", "mode": "auto", "enemy_ids": ["E1"],
|
|
"enemy_specs": {"E1": {"hp": 900.0, "armor": 1.0, "shield": 0.0,
|
|
"weak_tag": "click", "rebuild_at": [], "rebuild_amount": 0.0}},
|
|
"visible_hero_ids": ["H05"], "roster_hero_ids": ["H05"],
|
|
"input_events": [], "timeout_seconds": 40.0, "hp_scale": 1.0,
|
|
"skills": skills}
|
|
r = sim.run_scenario(RULES, sc, 10001, 40.0)
|
|
return (r["result"], round(r["duration_seconds"], 2),
|
|
sum(1 for e in r["event_log"] if e.get("type") == "skill_effect"))
|
|
base = run(HSL.build_skills(["H05"], SKILLS, HERO_STATS))
|
|
cd = run(HSL.build_skills(["H05"], SKILLS, HERO_STATS, active_oaths={"O13": True}))
|
|
dot = run(HSL.build_skills(["H05"], SKILLS, HERO_STATS, active_oaths={"O03": True}))
|
|
check(base != cd, f"冷却 oath changes battle: base={base} O13={cd}")
|
|
check(base != dot, f"元素 oath changes battle: base={base} O03={dot}")
|
|
|
|
|
|
def test_identity():
|
|
base = HSL.build_skills(["H01"], SKILLS, HERO_STATS)
|
|
check(base == HSL.build_skills(["H01"], SKILLS, HERO_STATS, active_oaths={}),
|
|
"empty oaths -> identity")
|
|
|
|
|
|
def main():
|
|
fns = [v for k, v in sorted(globals().items()) if k.startswith("test_")]
|
|
for fn in fns:
|
|
fn()
|
|
print(f"OATH_RULES_PASS {len(fns)} checks")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|