#!/usr/bin/env python3 import copy TYPE_NUL=0 TYPE_WPN=1 TYPE_BOW=2 TYPE_SHD=3 class Item: def __init__(self, xid, typ=TYPE_NUL): self.id=xid self.lvl=0 self.type=typ def main(a, typ=TYPE_NUL): global swords, bows, shields, gid, rid, tip, ctx, mem gid="0" rid=0 tip=TYPE_NUL ctx=Item(0, typ) for l in a: if "", "") try: if int(tip) > 2: ctx.type=TYPE_BOW else: ctx.type=TYPE_WPN except: print("[CRITICAL] Invalid item range format: " + l) ctx.type=TYPE_NUL ctx.lvl=0+rid return swords=[] bows=[] shields=[] mem=[] f1=open("../../client-data/items/equip-1hand.xml", "r"); main(f1); f1.close() f2=open("../../client-data/items/equip-2hand.xml", "r"); main(f2); f2.close() f3=open("../../client-data/items/equip-shield.xml", "r"); main(f3, TYPE_SHD); f3.close() mem=sorted(mem, key=lambda xcv: xcv.lvl, reverse=True) for r in mem: if r.type == TYPE_SHD: shields.append(r.id) elif r.type == TYPE_WPN: swords.append(r.id) elif r.type == TYPE_BOW: bows.append(r.id) else: print("Wrong type for item %d" % r.id) #shields=sorted(shields, reverse=True) #bows=sorted(bows, reverse=True) #swords=sorted(swords, reverse=True) b=open("weapons.tmp", "w") b.write('\n\ \n\ \n\ \n') b.write(' \n') for i in swords: b.write(' \n' % i) b.write(' \n \n') for i in bows: b.write(' \n' % i) b.write(' \n \n') for i in shields: b.write(' \n' % i) b.write(' \n') b.close()