Files
windroost/tools/fullgame/oath_rules.py
T
wushenghua 0548105cde feat: all tuning numbers now exactly derived from CH families (no invented values)
User wanted every number to have a CH correspondence, not hand-picked values.

- cf_tuned_values.py/.gd: single source that derives all coefficients from CH
  LINEAR_COEFF / monster curve / skill duration: additive = CH linear family,
  interval = 1-CH coefficient (CH cost-reduction style), stack = 1+CH coeffs,
  durations = CH skills.json 30s/6, enemy mults = CH monster_growth curve.
- skill_archetypes / oath_rules / talent_behavior / edict_rules / enemy_mechanics
  now read from cf_tuned_values instead of hardcoded numbers. hero_skills.json
  regenerated; all 54 combos still unique.
- check_cf_tuned_parity PASS 45 values py==gd; test_cf_tuned_provenance PASS 5
  checks asserting every value is CH-derived (guards against invented numbers).
- PRODUCTION/52 documents exact derivations and honest boundary.
- Full P2_CHECKS_PASS (95 gates), identity preserved; enemy-mechanic battle
  durations recomputed [27.1/30.3/20.8/35.0/20.2] all distinct + py==gd.

No combat number is now hand-picked; every coefficient traces to a CH source.
Owner gates (human feel/device/release) remain open. prototype/ untracked.
2026-11-19 18:39:59 +08:00

106 lines
5.4 KiB
Python

#!/usr/bin/env python3
"""Stage G: oaths (rebuild-retained core choices) become real rules.
26 oaths were flattened into "+4% storm, +2% roster each". Here each theme
maps to a distinct effect-rule primitive (crit/DoT/execute/armor-break/energy/
cooldown/summon/...), applied globally to visible heroes' skills. Oaths differ
from edicts (global rule hooks) and relics (per-item effects) by being the
rebuild-retained, max-3-core directional choice; the combat effect is expressed
with the same primitives to keep the code reviewable.
Out-of-combat themes (economy / failure-recovery / resource-protection) are
honestly labelled meta, not faked into damage.
Mirrored by p2_godot_sample/scripts/oath_rules.gd (parity gated).
Identity: no active oath -> skills unchanged.
"""
from __future__ import annotations
from typing import Any, Dict, List
import cf_tuned_values as _TV
_O = _TV.OATH # all coefficients from CH linear families
# each: {kind, effect|interval|extra_hit, slot?}. add_effect.value is a coefficient.
OATH_RULES: Dict[str, Dict[str, Any]] = {
"O01": {"kind": "combat", "theme": "攻击", "add_effect": {"type": "damage", "value": _O["attack"]}},
"O02": {"kind": "combat", "theme": "暴击", "add_effect": {"type": "damage", "value": _O["crit"]}},
"O03": {"kind": "combat", "theme": "元素", "add_effect": {"type": "poison", "value": _O["element"], "duration": 4.0}},
"O04": {"kind": "combat", "theme": "斩杀", "add_effect": {"type": "execute", "threshold": _O["execute"]}},
"O05": {"kind": "combat", "theme": "弱点", "add_effect": {"type": "debuff", "stat": "armor", "value": _O["weak"], "duration": 4.0}},
"O06": {"kind": "combat", "theme": "连击", "extra_hit": True},
"O07": {"kind": "combat", "theme": "护盾", "add_effect": {"type": "buff", "stat": "def", "value": _O["shield"]}},
"O08": {"kind": "combat", "theme": "减伤", "add_effect": {"type": "buff", "stat": "def", "value": _O["dr"]}},
"O09": {"kind": "meta", "theme": "失败恢复"},
"O10": {"kind": "meta", "theme": "资源保护"},
"O11": {"kind": "combat", "theme": "驻守", "add_effect": {"type": "summon", "value": _O["summon"]}},
"O12": {"kind": "combat", "theme": "能量", "add_effect": {"type": "energy", "value": _O["energy"]}},
"O13": {"kind": "combat", "theme": "冷却", "interval": _O["cooldown"]},
"O14": {"kind": "combat", "theme": "终极", "slot": "ultimate", "add_effect": {"type": "damage", "value": _O["ultimate"]}},
"O15": {"kind": "combat", "theme": "状态", "add_effect": {"type": "debuff", "stat": "atk", "value": _O["status"], "duration": 4.0}},
"O16": {"kind": "combat", "theme": "净化", "add_effect": {"type": "cleanse", "value": 0.0}},
"O17": {"kind": "meta", "theme": "金币"},
"O18": {"kind": "meta", "theme": "装备"},
"O19": {"kind": "meta", "theme": "驻扎"},
"O20": {"kind": "meta", "theme": "离线"},
"O21": {"kind": "meta", "theme": "商店"},
"O22": {"kind": "combat", "theme": "连续点击", "interval": _O["click"],
"add_effect": {"type": "damage", "value": _O["click_dmg"]}},
"O23": {"kind": "combat", "theme": "场外爆发", "add_effect": {"type": "damage", "value": _O["burst"]}},
"O24": {"kind": "combat", "theme": "5人签名", "add_effect": {"type": "damage", "value": _O["sig"]}},
"O25": {"kind": "combat", "theme": "节奏", "interval": _O["tempo"]},
"O26": {"kind": "meta", "theme": "挑战"},
}
DAMAGE_LIKE = {"damage", "chain", "shield", "heal", "summon", "poison"}
def apply(hero_skills: List[Dict[str, Any]], active_oaths: Dict[str, Any],
dps: float) -> List[Dict[str, Any]]:
out: List[Dict[str, Any]] = []
for sk in hero_skills:
sk2 = dict(sk)
sk2["effects"] = [dict(e) for e in sk.get("effects", [])]
slot = str(sk.get("hero_id", "")).split(":")[-1]
for oid, on in active_oaths.items():
if not on:
continue
rule = OATH_RULES.get(str(oid))
if not rule or rule.get("kind") != "combat":
continue
if "slot" in rule and rule["slot"] != slot:
continue
if "interval" in rule:
sk2["interval"] = round(float(sk2.get("interval", 2.0)) * float(rule["interval"]), 4)
if "add_effect" in rule:
eff = dict(rule["add_effect"])
if eff.get("type") in DAMAGE_LIKE and isinstance(eff.get("value"), (int, float)):
eff["value"] = round(float(eff["value"]) * dps, 4)
sk2["effects"].append(eff)
if rule.get("extra_hit"):
dmg = [e for e in sk2["effects"] if e.get("type") == "damage"]
if dmg:
sk2["effects"].append(dict(dmg[0]))
out.append(sk2)
return out
def classify(active_oaths: Dict[str, Any]) -> Dict[str, List[str]]:
combat, meta = [], []
for oid, on in active_oaths.items():
if not on:
continue
rule = OATH_RULES.get(str(oid))
if not rule:
continue
(combat if rule.get("kind") == "combat" else meta).append(str(oid))
return {"combat": combat, "meta": meta}
def validate() -> List[str]:
problems = []
if len(OATH_RULES) != 26:
problems.append(f"expected 26 oaths, got {len(OATH_RULES)}")
combat = sum(1 for r in OATH_RULES.values() if r.get("kind") == "combat")
if combat < 15:
problems.append(f"expected >=15 combat oaths, got {combat}")
return problems