diff options
Diffstat (limited to 'client/weapons.py')
-rwxr-xr-x | client/weapons.py | 79 |
1 files changed, 51 insertions, 28 deletions
diff --git a/client/weapons.py b/client/weapons.py index be2f60e..8b4d663 100755 --- a/client/weapons.py +++ b/client/weapons.py @@ -1,25 +1,26 @@ #!/usr/bin/python2.7 +import copy +TYPE_NUL=0 +TYPE_WPN=1 +TYPE_BOW=2 +TYPE_SHD=3 class Item: - def __init__(self, xid): + def __init__(self, xid, typ=TYPE_NUL): self.id=xid self.lvl=0 - -a=open("../../client-data/items.xml", "r") - -swords=[] -bows=[] -shields=[] - -gid="0" -rid=0 -ctx=Item(0) -mem=[] - -for l in a: + 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 "<item id=" in l: if ctx.id > 0: - mem.append(ctx) + mem.append(copy.copy(ctx)) gid=l.replace('\t', '').replace(' ','').replace('<itemid=', '').replace('"', '').replace("'", "") rid=0 @@ -32,29 +33,51 @@ for l in a: print "[CRITICAL] Invalid item ID format: " + l exit(1) - ctx=Item(rid) + ctx=Item(rid, typ) if "\tlevel=" in l or " level=" in l: gid=l.replace('\t', '').replace(' ','').replace('level=', '').replace('"', '').replace("'", "") try: - rid=int(gid) + ctx.lvl=int(gid) except: print "[CRITICAL] Invalid item level format: " + l - rid=0 + ctx.lvl=0 + + if "\tattack-range=" in l or " attack-range=" in l: + tip=l.replace('\t', '').replace(' ','').replace('attack-range=', '').replace('"', '').replace("'", "").replace(">", "") + 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: - rid=r.id - if rid >= 2700 and rid <= 2899: - shields.append(rid) - elif rid >= 3500 and rid <= 3999: - swords.append(rid) - elif rid >= 6000 and rid <= 6499: - bows.append(rid) - -a.close() + 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) @@ -65,7 +88,7 @@ b=open("weapons.tmp", "w") b.write('<?xml version="1.0" encoding="utf-8"?>\n\ <!-- Author: 4144, Jesusalva\n\ Copyright (C) 2015 Evol Online\n\ -Copyright (C) 2019-2020 The Mana World\n -->\n\ +Copyright (C) 2019-2021 The Mana World\n -->\n\ \n\ <weapons>\n') |