Skip to content

Commit

Permalink
Merge pull request #52 from lstern/grindstones
Browse files Browse the repository at this point in the history
Exporting Grindstones
  • Loading branch information
fperegrinvs committed Mar 25, 2016
2 parents b642f97 + 14e4ec1 commit 7b8e2e9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
24 changes: 16 additions & 8 deletions SWParser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ def rune_set_id(id):
else:
return "???"

def map_craft(craft, craft_id):
type_str = str(craft['craft_type_id'])
return {
'id': craft_id,
'item_id': craft['craft_item_id'],
'type': 'E' if craft['craft_type'] == 1 else 'G',
'set': rune_set_id(int(type_str[:-4])),
'stat': rune_effect_type(int(type_str[-4:-2])),
'grade': int(type_str[-1:])
}

def map_rune(rune, rune_id, monster_id=0, monster_uid=0):
cvs_map ={
'slot': rune['slot_no'],
Expand Down Expand Up @@ -201,14 +212,6 @@ def map_rune(rune, rune_id, monster_id=0, monster_uid=0):
"m_v": rune['pri_eff'][1],
"i_t": rune_effect_type(rune['prefix_eff'][0]),
"i_v": rune['prefix_eff'][1],
"s1_t": rune_effect_type(rune['sec_eff'][0][0]) if len(rune['sec_eff']) >= 1 else "",
"s1_v": rune['sec_eff'][0][1] + rune['sec_eff'][0][3] if len(rune['sec_eff']) >= 1 else 0,
"s2_t": rune_effect_type(rune['sec_eff'][1][0]) if len(rune['sec_eff']) >= 2 else "",
"s2_v": rune['sec_eff'][1][1] + rune['sec_eff'][1][3] if len(rune['sec_eff']) >= 2 else 0,
"s3_t": rune_effect_type(rune['sec_eff'][2][0]) if len(rune['sec_eff']) >= 3 else "",
"s3_v": rune['sec_eff'][2][1] + rune['sec_eff'][2][3] if len(rune['sec_eff']) >= 3 else 0,
"s4_t": rune_effect_type(rune['sec_eff'][3][0]) if len(rune['sec_eff']) >= 4 else "",
"s4_v": rune['sec_eff'][3][1] + rune['sec_eff'][3][3] if len(rune['sec_eff']) >= 4 else 0,
"locked":0,
"sub_res": subs['RES'],
"sub_cdmg": subs['CDmg'],
Expand All @@ -222,6 +225,11 @@ def map_rune(rune, rune_id, monster_id=0, monster_uid=0):
"sub_spd": subs['SPD'],
"sub_crate": subs['CRate']}

for sub in range(0,4):
optimizer_map['s%s_t' % (sub + 1)] = rune_effect_type(rune['sec_eff'][sub][0]) if len(rune['sec_eff']) >= sub + 1 else ""
optimizer_map['s%s_v' % (sub + 1)] = rune['sec_eff'][sub][1] + rune['sec_eff'][sub][3] if len(rune['sec_eff']) >= sub + 1 else 0
optimizer_map['s%s_data' % (sub + 1)] = {"enchanted": rune['sec_eff'][sub][2] == 1,
"gvalue": rune['sec_eff'][sub][3]} if len(rune['sec_eff']) >= sub + 1 else {}
return optimizer_map, cvs_map

def map_monster(monster, monster_id_mapping, storage_id, wizard_name=None):
Expand Down
13 changes: 13 additions & 0 deletions plugins/GenerateRunes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def parse_login_data(data):
runes = data['runes']
except:
runes = []
try:
crafts = data['rune_craft_item_list']
except:
crafts = []

if isinstance(runes, dict):
runes = runes.values()
Expand Down Expand Up @@ -69,6 +73,8 @@ def parse_login_data(data):

runes.sort(key = lambda r: (r['set_id'], r['slot_no']))

crafts.sort(key = lambda c: (c['craft_type'], c['craft_item_id']))

with open(str(wizard['wizard_id']) + ".json", "w") as f:
f.write(json.dumps(data, indent=4))

Expand Down Expand Up @@ -125,11 +131,18 @@ def parse_login_data(data):
optimizer = {
"runes": [],
"mons": [],
"crafts": [],
"savedBuilds": [],
}

rune_id_mapping = {}
monster_id_mapping = {}

craft_id = 1
for craft in crafts:
optimizer['crafts'].append(map_craft(craft, craft_id))
craft_id += 1

rune_id = 1
for rune in runes:
rune_id_mapping[rune['rune_id']] = rune_id
Expand Down

0 comments on commit 7b8e2e9

Please sign in to comment.