User: "数值应该都可以有对应关系." Completed the numeric provenance: - cf_formulas.py/.gd: added nearest_family(v) (which CH linear family a tuned coefficient maps to), monster_hp_mult(tier,boss) (CH monster_growth 1.6^L / 1.145^L + boss 1.5x), skill_duration_scale (CH skills.json duration 30s -> 5s combat timebase). CF_FORMULA_PARITY_PASS 41 cases py==gd. - edict_rules.py now reads coefficients from CH LINEAR_COEFF (D02=linear10 0.10, D03/D05=linear15 0.15, D04=linear20 0.20, D06=linear25 0.25) instead of hardcoded values; only interval/cooldown remain new-game tuning. - PRODUCTION/52 documents every remaining number's CH correspondence: skill damage -> nearest linear family, buff/debuff 5s -> CH 30s/6, stun 1.5s -> 5s*0.3, enemy multipliers -> CH monster curve. Honest boundary: values that are new-game tuned (interval multipliers, exact skill damage coefficients) are documented as CH-family-derived + tuning, not passed off as exact CH numbers. Full P2_CHECKS_PASS (93 gates). prototype/ untracked.
100 lines
4.7 KiB
Python
100 lines
4.7 KiB
Python
#!/usr/bin/env python3
|
||
"""Stage D: turn each edict's description into a REAL rule, not a flat +DPS.
|
||
|
||
Edicts are new-sky-retained permanent choices that should change a *class of
|
||
rules* (combat speed, elemental DoT, energy, summoning, ...). Here the 6 combat
|
||
edicts rewrite every visible hero's skills globally; the 3 out-of-combat edicts
|
||
(economy / node branches / challenge modifiers) are honestly recorded as meta
|
||
rules instead of being faked into damage numbers.
|
||
|
||
Mirrored by p2_godot_sample/scripts/edict_rules.gd (parity gated).
|
||
Identity: no active combat edict -> skills unchanged.
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
from typing import Any, Dict, List
|
||
|
||
# value on add_effect is a COEFFICIENT (scaled by hero base DPS by the caller).
|
||
# Coefficient magnitudes come from CH's real linear formula families via
|
||
# cf_formulas.LINEAR_COEFF (legacy CH ancient/relic coefficients):
|
||
# D02 buff 0.10 = linear10, D03 poison 0.15 = linear15,
|
||
# D04 damage 0.20 = linear20, D05 energy 0.15 = linear15,
|
||
# D06 summon 0.25 = linear25. Duration/cooldown are new-game tuning.
|
||
import cf_formulas as _CF
|
||
|
||
|
||
def _c(family: str) -> float:
|
||
return _CF.LINEAR_COEFF[family]
|
||
|
||
|
||
EDICT_RULES: Dict[str, Dict[str, Any]] = {
|
||
"D01": {"kind": "combat", "rule": "疾风:连战加速,全队技能冷却 -15%",
|
||
"interval": 0.85}, # new-game tuning (CH has no interval multiplier)
|
||
"D02": {"kind": "combat", "rule": "守望:弱点强化,全队攻击 +10%(CH linear10)",
|
||
"add_effect": {"type": "buff", "stat": "atk", "value": _c("linear10")}},
|
||
"D03": {"kind": "combat", "rule": "烈焰:全队技能附带持续灼烧(CH linear15)",
|
||
"add_effect": {"type": "poison", "value": _c("linear15"), "duration": 3.0}},
|
||
"D04": {"kind": "combat", "rule": "影行:目标切换至最低血量 + 暴击增伤(CH linear20)",
|
||
"target_mode": "lowest_hp",
|
||
"add_effect": {"type": "damage", "value": _c("linear20")}},
|
||
"D05": {"kind": "combat", "rule": "星辉:全队技能附加能量获取(CH linear15)",
|
||
"add_effect": {"type": "energy", "value": _c("linear15")}},
|
||
"D06": {"kind": "combat", "rule": "根脉:全队技能附带召唤增援(CH linear25)",
|
||
"add_effect": {"type": "summon", "value": _c("linear25")}},
|
||
"D07": {"kind": "meta", "rule": "商路:金币/装备/商店(跨战斗经济规则)"},
|
||
"D08": {"kind": "meta", "rule": "远征:事件/节点/奖励分支(跨战斗推进规则)"},
|
||
"D09": {"kind": "meta", "rule": "裂隙:无限层/挑战词缀(跨战斗挑战规则)"},
|
||
}
|
||
DAMAGE_LIKE = {"damage", "chain", "shield", "heal", "summon", "poison"}
|
||
|
||
|
||
def apply(hero_skills: List[Dict[str, Any]], active_edicts: Dict[str, Any],
|
||
dps: float, rules: Dict[str, Dict[str, Any]] | None = None) -> List[Dict[str, Any]]:
|
||
"""Apply active combat edict rules to one hero's skills. Returns a NEW list."""
|
||
rules = rules or EDICT_RULES
|
||
out: List[Dict[str, Any]] = []
|
||
for sk in hero_skills:
|
||
sk2 = dict(sk)
|
||
sk2["effects"] = [dict(e) for e in sk.get("effects", [])]
|
||
for eid, on in active_edicts.items():
|
||
if not on:
|
||
continue
|
||
rule = rules.get(str(eid))
|
||
if not rule or rule.get("kind") != "combat":
|
||
continue
|
||
if "interval" in rule:
|
||
sk2["interval"] = round(float(sk2.get("interval", 2.0)) * float(rule["interval"]), 4)
|
||
if "target_mode" in rule:
|
||
sk2["target_mode"] = rule["target_mode"]
|
||
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)
|
||
out.append(sk2)
|
||
return out
|
||
|
||
|
||
def classify(active_edicts: Dict[str, Any], rules: Dict[str, Dict[str, Any]] | None = None) -> Dict[str, List[str]]:
|
||
rules = rules or EDICT_RULES
|
||
combat, meta = [], []
|
||
for eid, on in active_edicts.items():
|
||
if not on:
|
||
continue
|
||
rule = rules.get(str(eid))
|
||
if not rule:
|
||
continue
|
||
(combat if rule.get("kind") == "combat" else meta).append(str(eid))
|
||
return {"combat": combat, "meta": meta}
|
||
|
||
|
||
def validate() -> List[str]:
|
||
problems = []
|
||
if len(EDICT_RULES) != 9:
|
||
problems.append(f"expected 9 edicts, got {len(EDICT_RULES)}")
|
||
combat = sum(1 for r in EDICT_RULES.values() if r.get("kind") == "combat")
|
||
meta = sum(1 for r in EDICT_RULES.values() if r.get("kind") == "meta")
|
||
if combat != 6 or meta != 3:
|
||
problems.append(f"expected 6 combat + 3 meta, got {combat}+{meta}")
|
||
return problems
|