Files
WoW-Hybrid-gateway/ops/warrior_stance_profile.py
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

49 lines
2.5 KiB
Python

#!/usr/bin/env python3
"""Generate the native warrior policy from the pinned complete stance component."""
import argparse
import hashlib
import json
from pathlib import Path
def generate(component):
data=json.loads(component)
if data['component']!='warrior-autostance-v1':raise ValueError('unqualified warrior component')
rows=sorted(data['abilities'],key=lambda row:row['ability_spell'])
if len(rows)!=data['count'] or len({r['ability_spell']for r in rows})!=len(rows):raise ValueError('duplicate/incomplete ability policy')
masks={2457:65536,71:131072,2458:262144}
for row in rows:
if row['excluded_mask'] or not row['required_mask'] or row['required_mask']&~458752:raise ValueError('unqualified stance mask')
if set(row['allowed_stances'])!={spell for spell,mask in masks.items()if row['required_mask']&mask}:raise ValueError('stance list/mask disagreement')
body='\n'.join(' {%du,%du},'%(r['ability_spell'],r['required_mask'])for r in rows)
return '''#pragma once
// Generated by ops/warrior_stance_profile.py. Source forms: SharedDefines.h
// Battle=17, Defensive=18, Berserker=19; source masks use 1 << (form-1).
// Component SHA256: %s
#include <array>
#include <cstdint>
#include <optional>
#include <set>
namespace gateway::warrior_stance {
struct Rule {uint32_t spell,mask;};
inline constexpr std::array<Rule,%d> Rules={{
%s
}};
struct Choice {uint32_t spell=0;uint8_t form=0;};
// No optimistic form, learned-spell, cooldown or resource state. The existing
// genuine server cast path owns GCD/rage checks and stance-switch rage clamping.
inline std::optional<Choice> choose(uint32_t ability,uint8_t player_class,
std::optional<uint8_t> form,const std::set<uint32_t>&learned){
if(player_class!=1||!form||!learned.contains(ability))return std::nullopt;
if(*form!=0&&*form!=17&&*form!=18&&*form!=19)return std::nullopt;
uint32_t mask=0;for(const auto&rule:Rules)if(rule.spell==ability){mask=rule.mask;break;}
if(!mask||(*form&&mask&(uint32_t(1)<<(*form-1))))return std::nullopt;
// Owner-approved priority: Battle, Berserker, Defensive, among learned forms.
for(const auto choice:std::array<Choice,3>{{{2457,17},{2458,19},{71,18}}})
if((mask&(uint32_t(1)<<(choice.form-1)))&&learned.contains(choice.spell))return choice;
return std::nullopt;
}
}
'''%(hashlib.sha256(component).hexdigest(),len(rows),body)
if __name__=='__main__':
p=argparse.ArgumentParser();p.add_argument('component',type=Path);p.add_argument('output',type=Path);a=p.parse_args();a.output.write_text(generate(a.component.read_bytes()))