Difference between revisions of "User:Sten/Legacy to spreadsheet"

From Wildermyth Wiki
m
Line 59: Line 59:
hooks = []
hooks = []
abilities = []
abilities = []
for entry in data['entries']:
weapons = []
offhands = []
for i_entry, entry in enumerate(data['entries']):
   hook = 0
   hook = 0
   themes_ = []
   themes_ = []
   abilities_ = []
   abilities_ = []
   class_ = ''
   class_ = ''
  weapons_ = []
  offhand = ''
   try:
   try:
     tier = int(entry['tier'])+1
     tier = int(entry['tier'])+1
Line 77: Line 81:
   entities = entry['snapshots'][snapshot]['entities']
   entities = entry['snapshots'][snapshot]['entities']
   for j in range(len(entities)):
   for j in range(len(entities)):
     try:
     if 'individual' in entities[j]:
       name = entities[j][6]['name']
       for i in range(len(entities[j])):
    except:
        if entities[j][i] == 'status':   
      continue
          name = entities[j][i+1]['name']
    for entry_ in entities[j][6]['aspects']['entries']:
          print('reading entry %d: %s'%(i_entry,name))
      if entry_[0] in ['hunter','warrior','mystic'] and entry_[1]['value'] == 1:
          for entry_ in entities[j][i+1]['aspects']['entries']:
        class_ = entry_[0]
            if entry_[0] in ['hunter','warrior','mystic'] and entry_[1]['value'] == 1:
      elif entry_[0].startswith('themePiece_') and entry_[1]['value'] == 1:
              class_ = entry_[0]
        themes_ += [dictionary[entry_[0]]]
            elif entry_[0].startswith('themePiece_') and entry_[1]['value'] == 1:
      elif entry_[0].startswith('hookResolved_retirementAgeBoost') and entry_[1]['value'] == 1:
              themes_ += [dictionary[entry_[0]]]
        hook += 1
            elif entry_[0].startswith('hookResolved_retirementAgeBoost') and entry_[1]['value'] == 1:
      elif test_ability(entry_[0]) and entry_[1]['value'] == 1:
              hook += 1
        abilities_ += [dictionary[entry_[0]]]
            elif test_ability(entry_[0]) and entry_[1]['value'] == 1:
              abilities_ += [dictionary[entry_[0]]]
    elif 'item' in entities[j]:
      for i in range(len(entities[j])):
        if entities[j][i] == 'status':   
          itemName = entities[j][i+1]['name']
          itemID = entities[j][i+1]['localizableName'].split('.')[-1]
        elif entities[j][i] == 'item':   
          if 'MAIN_HAND' in entities[j][i+1]['slots']:
            try:
              if entities[j][i+1]['artifact']:
                weapons_ += [itemName]
              else:
                raise
            except:
              weapons_ += [itemID]
          elif 'OFF_HAND' in entities[j][i+1]['slots'] and 'MAIN_HAND' not in entities[j][i+1]['slots']:
            offhand = itemName
     
   names += [name]
   names += [name]
   tiers += [tier]
   tiers += [tier]
Line 97: Line 119:
   abilities += [abilities_]
   abilities += [abilities_]
   hooks += [hook]
   hooks += [hook]
weapons = []
for entry in data['entries']:
  weapons_ = []
  entities = entry['snapshots'][snapshot]['entities']
  for j in range(len(entities)):
    try:
      if 'MAIN_HAND' in entities[j][6]['slots']:
        try:
          if entities[j][6]['artifact']:
            weapons_ += [entities[j][4]['name']]
          else:
            raise
        except:
          weapons_ += [entities[j][4]['localizableName'].split('.')[-1]]
    except:
      pass
   weapons += [weapons_]
   weapons += [weapons_]
offhands = []
for entry in data['entries']:
  offhand = ''
  entities = entry['snapshots'][snapshot]['entities']
  for j in range(len(entities)):
    try:
      if 'OFF_HAND' in entities[j][6]['slots'] and 'MAIN_HAND' not in entities[j][6]['slots']:
        offhand = entities[j][4]['name']
    except:
      pass
   offhands += [offhand]
   offhands += [offhand]



Revision as of 16:23, 19 February 2022

This is a Python script to export a player's legacy into a spreadsheet. You need a Python installation to run it.

Usage

Copy the code in the box below into a text file named legacy_table.py (or whatever you want) inside the Wildermyth/Players/<player ID> directory. Then run it by calling python legacy_table.py from the command line. It will create a text file called legacy_table.txt, which is tab-delimited and can be loaded by any spreadsheet software or viewed in a text editor.

Output

This script does not make any changes to the legacy.

The following fields appear in the output table (legacy_table.txt):

  • Name
  • Playable (Y/N)
  • Legacy tier
  • Class
  • Number of hooks resolved
  • Themes
  • Weapons
  • Offhand item
  • Abilities

Example

Example image
Example legacy export, viewed in Microsoft Excel