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.
118 lines
5.1 KiB
Python
118 lines
5.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Map talent `behavior` text to REAL skill-effect modifications (Stage C).
|
|
|
|
Today talents only feed stat/stat_value into growth modifiers; their
|
|
`behavior` (target_lowest_hp / pierce_extra / chain+1 / ... ) is display-only.
|
|
This module turns each behavior into a concrete change to a hero's skill
|
|
effects so the battle actually behaves differently when the talent is active.
|
|
|
|
Mirrored by p2_godot_sample/scripts/talent_behavior.gd (parity gated).
|
|
Identity: no active behavior talents -> skills unchanged.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Dict, List, Tuple
|
|
import cf_tuned_values as _TV
|
|
_T = _TV.TALENT # multipliers from CH linear families
|
|
|
|
# behavior text -> modification spec. These 11 are real combat behaviours.
|
|
BEHAVIOR_MODS: Dict[str, Dict[str, Any]] = {
|
|
"目标改为最低血量": {"target_mode": "lowest_hp"},
|
|
"穿透一个额外目标": {"pierce_extra": True},
|
|
"加一次弹射": {"chain_jumps": 1},
|
|
"溅射范围扩大": {"chain_jumps": 1},
|
|
"破甲叠层+1": {"armor_stack": _T["armor_stack"]},
|
|
"易伤窗口延长": {"debuff_duration": _T["debuff_duration"]},
|
|
"持续时间延长": {"all_duration": _T["all_duration"]},
|
|
"持续伤害叠层": {"poison_stack": _T["poison_stack"]},
|
|
"连击窗口延长": {"extra_hit": True},
|
|
"冷却缩短": {"interval": _T["interval"]},
|
|
"点击暴击充能": {"energy": _T["energy"]},
|
|
}
|
|
|
|
# These 2 are meta/out-of-combat rules; recorded but not faked into combat.
|
|
META_BEHAVIORS = {"自动化档位+1", "解锁/转换/上限/替代规则"}
|
|
|
|
|
|
def active_behaviors(hero_id: str, active_talents: Dict[str, Any],
|
|
talent_specs: Dict[str, Any]) -> Tuple[List[str], List[str]]:
|
|
"""Return (combat_behaviors, meta_behaviors) active for this hero."""
|
|
combat, meta = [], []
|
|
for tid, on in active_talents.items():
|
|
if not on:
|
|
continue
|
|
spec = talent_specs.get(str(tid))
|
|
if not spec or spec.get("hero") != hero_id:
|
|
continue
|
|
if not spec.get("changes_behavior"):
|
|
continue
|
|
b = str(spec.get("behavior", ""))
|
|
if b in META_BEHAVIORS:
|
|
meta.append(b)
|
|
elif b in BEHAVIOR_MODS:
|
|
combat.append(b)
|
|
return combat, meta
|
|
|
|
|
|
def apply_behaviors(skills: List[Dict[str, Any]], behaviors: List[str]) -> List[Dict[str, Any]]:
|
|
"""Apply combat behaviors to one hero's skill list. Returns a NEW list."""
|
|
out: List[Dict[str, Any]] = []
|
|
for sk in skills:
|
|
sk2 = dict(sk)
|
|
sk2["effects"] = [dict(e) for e in sk.get("effects", [])]
|
|
for b in behaviors:
|
|
mod = BEHAVIOR_MODS.get(b)
|
|
if not mod:
|
|
continue
|
|
if "target_mode" in mod:
|
|
sk2["target_mode"] = mod["target_mode"]
|
|
if mod.get("pierce_extra"):
|
|
merged = []
|
|
for e in sk2["effects"]:
|
|
merged.append(e)
|
|
if e.get("type") == "damage":
|
|
merged.append({"type": "chain", "value": e.get("value", 0.0), "jumps": 1})
|
|
sk2["effects"] = merged
|
|
if mod.get("chain_jumps"):
|
|
for e in sk2["effects"]:
|
|
if e.get("type") == "chain":
|
|
e["jumps"] = int(e.get("jumps", 2)) + int(mod["chain_jumps"])
|
|
if mod.get("armor_stack"):
|
|
for e in sk2["effects"]:
|
|
if e.get("type") == "debuff" and e.get("stat") == "armor":
|
|
e["value"] = round(float(e["value"]) * float(mod["armor_stack"]), 4)
|
|
if mod.get("debuff_duration"):
|
|
for e in sk2["effects"]:
|
|
if e.get("type") == "debuff" and "duration" in e:
|
|
e["duration"] = round(float(e["duration"]) * float(mod["debuff_duration"]), 4)
|
|
if mod.get("all_duration"):
|
|
for e in sk2["effects"]:
|
|
if "duration" in e:
|
|
e["duration"] = round(float(e["duration"]) * float(mod["all_duration"]), 4)
|
|
if mod.get("poison_stack"):
|
|
for e in sk2["effects"]:
|
|
if e.get("type") == "poison":
|
|
e["value"] = round(float(e["value"]) * float(mod["poison_stack"]), 4)
|
|
if mod.get("extra_hit"):
|
|
dmg = [e for e in sk2["effects"] if e.get("type") == "damage"]
|
|
if dmg:
|
|
sk2["effects"].append(dict(dmg[0]))
|
|
if "interval" in mod:
|
|
sk2["interval"] = round(float(sk2.get("interval", 2.0)) * float(mod["interval"]), 4)
|
|
if "energy" in mod:
|
|
sk2["effects"].append({"type": "energy", "value": float(mod["energy"])})
|
|
out.append(sk2)
|
|
return out
|
|
|
|
|
|
def validate_mapping() -> List[str]:
|
|
problems = []
|
|
if len(BEHAVIOR_MODS) != 11:
|
|
problems.append(f"expected 11 combat behaviors, got {len(BEHAVIOR_MODS)}")
|
|
if len(META_BEHAVIORS) != 2:
|
|
problems.append(f"expected 2 meta behaviors, got {len(META_BEHAVIORS)}")
|
|
for b, mod in BEHAVIOR_MODS.items():
|
|
if not mod:
|
|
problems.append(f"empty mod for {b}")
|
|
return problems
|