42 lines
2.2 KiB
Python
42 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Tooltip data for the 773-item lane's budgetless items (stats/armor the 70334 ItemSparse cannot store).
|
|
|
|
Reads itemsparse-773.json rules and writes:
|
|
client_addons/WoWHybridUI/SourceItemStatData.lua - source stat/resistance/block/armor lines per item
|
|
client_addons/WoWHybridUI/SourceItemArmorData.lua - existing entries kept byte-for-byte, new item armor appended
|
|
"""
|
|
import json, re, sys
|
|
from pathlib import Path
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
UI = ROOT / 'client_addons/WoWHybridUI'
|
|
STAT_NAMES = {0: 'Mana', 1: 'Health', 3: 'Agility', 4: 'Strength', 5: 'Intellect', 6: 'Spirit', 7: 'Stamina'}
|
|
|
|
def text(kind, value):
|
|
name = STAT_NAMES.get(kind, kind) if isinstance(kind, int) else kind
|
|
if not isinstance(name, str): raise SystemExit(f'unreviewed stat type {kind}')
|
|
if name == 'Block': return f'{value} Block'
|
|
if name == 'Armor': return f'{value} Armor'
|
|
return f'{value:+d} {name}'
|
|
|
|
def main(path):
|
|
rules = json.loads(Path(path).read_text())['rules']
|
|
out = ['-- Generated by ops/claude_itemsparse_773/presentation_data.py; source item lines the 70334 client cannot',
|
|
'-- compute (poor/common quality and item levels without a stat budget). Server applies the real values.',
|
|
'GatewaySourceItemStatData = {', ' schemaVersion = 1, locale = "enUS",', ' items = {']
|
|
for ident in sorted(rules['stat_presentation'], key=int):
|
|
lines = [text(k, v) for k, v in rules['stat_presentation'][ident]]
|
|
out.append(' [%d] = {%s},' % (int(ident), ','.join(json.dumps(l) for l in lines)))
|
|
out += [' },', '}', '']
|
|
(UI / 'SourceItemStatData.lua').write_text('\n'.join(out))
|
|
armor = UI / 'SourceItemArmorData.lua'
|
|
lua = armor.read_text()
|
|
have = {int(m[1]) for m in re.finditer(r'\[(\d+)\] = (\d+),', lua)}
|
|
new = {int(k): v for k, v in rules['armor_presentation'].items() if int(k) not in have}
|
|
tail = ' },\n}\n'
|
|
if not lua.endswith(tail): raise SystemExit('SourceItemArmorData.lua layout changed')
|
|
lua = lua[:-len(tail)] + ''.join(f' [{k}] = {v},\n' for k, v in sorted(new.items())) + tail
|
|
armor.write_text(lua)
|
|
print('stat items', len(rules['stat_presentation']), 'armor added', len(new))
|
|
|
|
if __name__ == '__main__': main(sys.argv[1])
|