Advertisement
Omega_K2

Exporting Winterheart start items with PyPoE

Jan 22nd, 2016
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.43 KB | None | 0 0
  1. from PyPoE.poe.constants import SOCKET_COLOUR
  2. from PyPoE.poe.file.dat import RelationalReader
  3.  
  4. # I have the content.ggpk extracted to C:/Temp
  5. r = RelationalReader(path_or_ggpk='C:/Temp/', read_options={'use_dat_value': False})
  6.  
  7. def stuff():
  8.     print('<table class="wikitable sortable">')
  9.    
  10.     headers = ['Char', 'Item', 'Sockets', 'Links', 'Skill Gems', 'Mods', 'Inventory', 'Stack Size']
  11.     print('<tr><th>' + '</th><th>'.join(headers) + '</th></tr>')
  12.    
  13.     for row in r['CharacterStartItems.dat']:
  14.         if row['CharacterStartStatesKey'].rowid < 21:
  15.             continue
  16.        
  17.         cells = []
  18.        
  19.         cells.append(row['CharacterStartStatesKey']['Id'])
  20.        
  21.         # {{il|item name}} is a wiki template to link to items
  22.         cells.append('{{il|%s}}' % row['BaseItemTypesKey']['Name'])
  23.        
  24.         if row['Sockets']:
  25.             sockets = []
  26.             for socketid in row['Sockets']:
  27.                 for socket in SOCKET_COLOUR:
  28.                     if socket.id == socketid:
  29.                         sockets.append(socket.char)
  30.                         break
  31.             cells.append('-'.join(sockets))
  32.         else:
  33.             cells.append('N/A')
  34.            
  35.         if row['Links']:
  36.             cells.append(', '.join([str(x) for x in row['Links']]))
  37.         else:
  38.             cells.append('N/A')
  39.            
  40.         if row['Socketed_SkillGemsKeys']:
  41.             gems = []
  42.             for i, skill_gem in enumerate(row['Socketed_SkillGemsKeys']):
  43.                 # {{sl|skill name}} is a wiki template to link to skills
  44.                 gems.append('{{sl|%s}} (Lv: %s)' % (skill_gem['BaseItemTypesKey']['Name'], row['SkillGemLevels'][i]))
  45.        
  46.             cells.append('<br>'.join(gems))
  47.         else:
  48.             cells.append('N/A')
  49.            
  50.         if row['ModsKeys']:
  51.             # [[modid|modname]] is basically linking to wikipage of name modid using the name of the mod, since there may be multiple mods with the same name
  52.             cells.append(', '.join(['[[%s|%s]]' % (mod['Id'], mod['Name']) for mod in row['ModsKeys']]))
  53.         else:
  54.             cells.append('N/A')
  55.            
  56.         cells.append(row['InventoryIndex'])
  57.            
  58.         if row['StackSize']:
  59.             cells.append(str(row['StackSize']))
  60.         else:
  61.             cells.append('N/A')
  62.        
  63.         print ('<tr><td>' + '</td><td>'.join(cells) + '</td></tr>')
  64.     print('</table>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement