Continued PRODUCTION/51. Effect primitives now reach the real battle sims: - skill_runtime.py / skill_runtime.gd bridge folds skills into per-tick state (poison/execute/chain/buff/summon/stun/damage), parity 7 cases python==gd. - Both mvp_validation_sim.py and battle_sim.gd call skill_runtime each tick; skill_rt stored in state; buffs/summons adjust effective roster/signature DPS without compounding; identity when no skills (null -> neutral multipliers). - check_skill_battle.py: SAME encounter with 6 different skills yields 6 distinct durations [20.3/6.0/11.0/19.6/5.9/4.7], py==gd. This is the concrete proof that skills are no longer just "+DPS numbers". - 5 new gates registered; full P2_CHECKS_PASS (69 gates), identity preserved (300 results byte-identical, mvp_parity_gate PASS). This closes the core of the user's "not perfunctory" requirement: skills now produce genuinely different combat behaviour. Stages B-E (per-hero archetype assignment, talent behaviour, edict rules, enemy mechanics) remain. prototype/ untracked.
90 lines
3.9 KiB
Python
90 lines
3.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Gate: GDScript skill_runtime.gd matches Python skill_runtime.py tick-for-tick."""
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(Path(__file__).parent))
|
|
import skill_runtime as SR
|
|
|
|
GD_JSON = ROOT / "p2_godot_sample" / "artifacts" / "skill_runtime_parity_gd.json"
|
|
GODOT = "/Applications/Godot.app/Contents/MacOS/Godot"
|
|
PROJECT = ROOT / "p2_godot_sample"
|
|
|
|
|
|
def mk_enemies():
|
|
return [
|
|
{"id": "E1#1", "content_id": "E1", "hp": 500.0, "max_hp": 500.0, "armor": 1.0, "shield": 0.0, "dead": False},
|
|
{"id": "E2#2", "content_id": "E2", "hp": 500.0, "max_hp": 500.0, "armor": 1.0, "shield": 0.0, "dead": False},
|
|
]
|
|
|
|
|
|
SCENARIOS = [
|
|
{"name": "identity", "skills": []},
|
|
{"name": "damage", "skills": [{"hero_id": "H1", "interval": 1.0, "effects": [{"type": "damage", "value": 100}]}]},
|
|
{"name": "execute", "skills": [{"hero_id": "H2", "interval": 1.0, "effects": [{"type": "execute", "threshold": 0.5}]}]},
|
|
{"name": "chain", "skills": [{"hero_id": "H3", "interval": 1.0, "effects": [{"type": "chain", "value": 50, "jumps": 1}]}]},
|
|
{"name": "buff", "skills": [{"hero_id": "H4", "interval": 1.0, "effects": [{"type": "buff", "stat": "atk", "value": 0.5}]}]},
|
|
{"name": "poison", "skills": [{"hero_id": "H5", "interval": 1.0, "effects": [{"type": "poison", "value": 20, "duration": 3.0}]}]},
|
|
{"name": "mixed", "skills": [
|
|
{"hero_id": "H1", "interval": 0.5, "effects": [{"type": "damage", "value": 30}, {"type": "lifesteal", "value": 0.2}]},
|
|
{"hero_id": "H2", "interval": 2.0, "effects": [{"type": "chain", "value": 40, "jumps": 1}, {"type": "stun", "duration": 1.0}]},
|
|
]},
|
|
]
|
|
|
|
|
|
def py_result(sc):
|
|
rt = SR.init_runtime(sc)
|
|
enemies = mk_enemies()
|
|
events = []
|
|
total_damage = total_killed = total_events = 0.0
|
|
for t in range(10):
|
|
time = t * 0.5
|
|
out = SR.tick(rt, enemies, time, 0.5, events)
|
|
total_damage += out["extra_damage"]
|
|
total_killed += out["killed"]
|
|
total_events += out["effect_events"]
|
|
return {"name": sc["name"], "total_damage": round(total_damage, 4),
|
|
"total_killed": int(total_killed), "total_events": int(total_events),
|
|
"enemy_hp": [round(enemies[0]["hp"], 4), round(enemies[1]["hp"], 4)],
|
|
"damage_mult": round(SR.damage_mult(rt["skill_state"]), 4),
|
|
"events_sample": events[:3]}
|
|
|
|
|
|
def main() -> int:
|
|
r = subprocess.run([GODOT, "--headless", "--path", str(PROJECT),
|
|
"--script", "res://scripts/skill_runtime_parity_test.gd"],
|
|
capture_output=True, text=True, timeout=180)
|
|
if r.returncode != 0 or "SKILL_RT_PARITY_GD" not in r.stdout:
|
|
print("SKILL_RT_PARITY_FAIL emitter failed")
|
|
print(r.stdout[-500:], r.stderr[-500:])
|
|
return 1
|
|
gd = json.loads(GD_JSON.read_text())["results"]
|
|
problems = []
|
|
for i, grow in enumerate(gd):
|
|
py = py_result(SCENARIOS[i])
|
|
for key in py:
|
|
a, b = py[key], grow.get(key)
|
|
if isinstance(a, (int, float)) and not isinstance(a, bool):
|
|
if abs(float(a) - float(b)) > 1e-4:
|
|
problems.append(f"case {i} {py['name']}.{key}: py={a} gd={b}")
|
|
elif isinstance(a, list):
|
|
if len(a) != len(b) or any(abs(float(x)-float(y))>1e-4 for x,y in zip(a,b) if isinstance(x,(int,float))):
|
|
if a != b:
|
|
problems.append(f"case {i} {py['name']}.{key}: py={a} gd={b}")
|
|
elif a != b:
|
|
problems.append(f"case {i} {py['name']}.{key}: py={a} gd={b}")
|
|
if problems:
|
|
print(f"SKILL_RT_PARITY_FAIL {len(problems)} mismatch(es)")
|
|
for p in problems[:20]:
|
|
print(" " + p)
|
|
return 1
|
|
print(f"SKILL_RT_PARITY_PASS {len(gd)} cases, python==gd")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|