summaryrefslogtreecommitdiff
path: root/clientdata.py
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2018-06-14 15:46:10 -0300
committerJesusaves <cpntb1@ymail.com>2018-06-14 15:46:10 -0300
commit416a9a7b40b9ef7caffaeebadaf852161cd7d28d (patch)
tree86d9b53e775c0ef3afe8f4f12b7b47de54fdfee9 /clientdata.py
parent04663c1a796d7aab19b0de113856c4d518d0e689 (diff)
downloadtools-416a9a7b40b9ef7caffaeebadaf852161cd7d28d.tar.gz
tools-416a9a7b40b9ef7caffaeebadaf852161cd7d28d.tar.bz2
tools-416a9a7b40b9ef7caffaeebadaf852161cd7d28d.tar.xz
tools-416a9a7b40b9ef7caffaeebadaf852161cd7d28d.zip
Sort weapons based on level, instead of ID.
Diffstat (limited to 'clientdata.py')
-rwxr-xr-xclientdata.py48
1 files changed, 37 insertions, 11 deletions
diff --git a/clientdata.py b/clientdata.py
index 3525003..8509bad 100755
--- a/clientdata.py
+++ b/clientdata.py
@@ -1,5 +1,9 @@
#!/usr/bin/python2.7
-# TODO: Retrieve weapon level, and sort based on that (higher level must be on top of list or it won't work as expected)
+
+class Item:
+ def __init__(self, xid):
+ self.id=xid
+ self.lvl=0
a=open("../client-data/items.xml", "r")
@@ -9,30 +13,52 @@ shields=[]
gid="0"
rid=0
+ctx=Item(0)
+mem=[]
+
for l in a:
if "<item id=" in l:
+ if ctx.id > 0:
+ mem.append(ctx)
+
gid=l.replace('\t', '').replace(' ','').replace('<itemid=', '').replace('"', '').replace("'", "")
+ rid=0
if "-" in gid:
gid="0"
continue
try:
rid=int(gid)
except:
- print "[CRITICAL] Invalid item ID format: " + gid
+ print "[CRITICAL] Invalid item ID format: " + l
+ exit(1)
+
+ ctx=Item(rid)
+
+ if "\tlevel=" in l or " level=" in l:
+ gid=l.replace('\t', '').replace(' ','').replace('level=', '').replace('"', '').replace("'", "")
+ try:
+ rid=int(gid)
+ except:
+ print "[CRITICAL] Invalid item level format: " + l
exit(1)
+ ctx.lvl=0+rid
+
+mem=sorted(mem, key=lambda xcv: xcv.lvl, reverse=True)
- 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)
+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()
-shields=sorted(shields, reverse=True)
-bows=sorted(bows, reverse=True)
-swords=sorted(swords, reverse=True)
+#shields=sorted(shields, reverse=True)
+#bows=sorted(bows, reverse=True)
+#swords=sorted(swords, reverse=True)
b=open("../client-data/weapons.xml", "w")