#!/usr/bin/env python3 """Produce a validated level-one Vanilla roster; never modify live characters.""" import argparse import collections import json import pathlib import re RACES = {"Human":1,"Orc":2,"Dwarf":3,"Night Elf":4,"Undead":5,"Tauren":6,"Gnome":7,"Troll":8} CLASSES = {"Warrior":1,"Paladin":2,"Hunter":3,"Rogue":4,"Priest":5,"Shaman":7,"Mage":8,"Warlock":9,"Druid":11} ALLOWED = {1:{1,2,4,5,8,9},2:{1,3,4,7,9},3:{1,2,3,4,5},4:{1,3,4,5,11},5:{1,4,5,8,9},6:{1,3,7,11},7:{1,4,8,9},8:{1,3,4,5,7,8}} ALLIANCE = {"Human","Dwarf","Night Elf","Gnome","Draenei"} def plan(bots): if len(bots) != 50 or len({b['name'].lower() for b in bots}) != 50: raise ValueError("Exactly 50 unique active identities required") result = [] for b in bots: if not re.fullmatch(r'[A-Za-z]{2,12}',b['name']): raise ValueError("Invalid native character name") race, role = b['race'], b['role'] team = 0 if race in ALLIANCE else 1 if role == 'Death Knight': role = 'Warrior' if team == 0 and role == 'Shaman': role = 'Paladin' if team == 1 and role == 'Paladin': role = 'Shaman' if race == 'Draenei': race = 'Dwarf' if role in ('Hunter','Paladin','Warrior') else 'Human' if race == 'Blood Elf': race = 'Tauren' if role == 'Shaman' else 'Undead' race_id, class_id = RACES[race], CLASSES[role] if class_id not in ALLOWED[race_id]: raise ValueError(f"Invalid Vanilla combination: {b['name']} {race} {role}") if (race in ALLIANCE) != (team == 0): raise ValueError('Faction changed') result.append(dict(id=b['id'],name=b['name'],race=race,role=role,raceId=race_id,classId=class_id,team=team,level=1, oldRace=b['race'],oldRole=b['role'],oldLevel=b['level'])) if collections.Counter(x['team'] for x in result) != {0:25,1:25}: raise ValueError('Roster must be 25 Alliance and 25 Horde') return result if __name__ == '__main__': parser=argparse.ArgumentParser() parser.add_argument('active',type=pathlib.Path) parser.add_argument('output',type=pathlib.Path) args=parser.parse_args() rows=plan(json.loads(args.active.read_text())) args.output.write_text(json.dumps(rows,indent=2)+'\n') print('Validated: 50 identities, 25 Alliance, 25 Horde, all start at level 1')