Difference between revisions of "Ability/Script"

From Wildermyth Wiki
(Created page with "This is a [https://www.python.org/downloads/ Python] script to generate the Ability tables. Copy the code in the box below into a text file named '''<nowiki>abilityTable.p...")
 
Line 96: Line 96:
         break
         break
   return string
   return string
linkwords = [
  'Bonus Damage',
  'Potency',
  'Stunt Chance',
  'Temp Health',
  'Temporary Health',
  'Armor',
  'Warding',
  'Dodge',
  'Block',
  'Speed',
  'Recovery Rate',
  'Retirement Age',
  'Grayplane',
  'bonus damage',
  'spell damage',
  'armor',
  'warding',
  'dodge',
  'block',
  'augment',
  'grayplane',
  ]


def parse(blurb):
def parse(blurb):
Line 107: Line 131:
   out = out.replace('<name>','Hero')
   out = out.replace('<name>','Hero')
    
    
   out = re.sub(r'\<int.*?\>', 'x', out)
   out = re.sub(r'\<int:(.*?)\>', 'x', out)
   out = re.sub(r'\<float.*?\>', 'x', out)
   out = re.sub(r'\<float:(.*?)\>', 'x', out)
 
   out = re.sub(r'\<mf:.*?/.*?/(.*?)\>', '\g<1>', out)
   out = re.sub(r'\<mf:.*?/.*?/(.*?)\>', '\g<1>', out)
  #out = re.sub(r'\[b\](.*?)\[.*?\]', "'''\g<1>'''", out)
  #out = re.sub(r'\[blue\](.*?)\[.*?\]', "\g<1>", out)
  #out = re.sub(r'\[gray\](.*?)\[.*?\]', "\g<1>", out)
   out = re.sub(r'\[:statusEffect\.(.*?)\](.*?)\[\]', '[[\g<1>|\g<2>]]', out)
   out = re.sub(r'\[:statusEffect\.(.*?)\](.*?)\[\]', '[[\g<1>|\g<2>]]', out)
   out = re.sub(r'\[statusEffect:(.*?)\](.*?)\[\]', '[[\g<1>|\g<2>]]', out)
   out = re.sub(r'\[statusEffect:(.*?)\](.*?)\[\]', '[[\g<1>|\g<2>]]', out)
Line 122: Line 144:
    
    
   out = out.replace('\\n','<br />')
   out = out.replace('\\n','<br />')
   out = out.replace('Bonus Damage','[[Bonus Damage]]')
    
  out = out.replace('Potency','[[Potency]]')
   for word in linkwords:
  out = out.replace('Stunt Chance','[[Stunt Chance]]')
    out = out.replace(word,'[[%s]]'%word)
  out = out.replace('Temp Health','[[Temp Health]]')
   out = out.replace('Temporary Health','[[Temporary Health]]')
  out = out.replace('Armor','[[Armor]]')
  out = out.replace('Warding','[[Warding]]')
  out = out.replace('Recovery Rate','[[Recovery Rate]]')
  out = out.replace('Retirement Age','[[Retirement Age]]')
  out = out.replace('bonus damage','[[bonus damage]]')
  out = out.replace('spell damage','[[spell damage]]')
  out = out.replace('armor','[[armor]]')
  out = out.replace('warding','[[warding]]')
   return out
   return out


Line 160: Line 172:
         reqname = reqname.replace('(','')
         reqname = reqname.replace('(','')
         reqname = reqname.replace(')','')
         reqname = reqname.replace(')','')
         requirements += ['[[%s]]'%reqname]
         requirements += ['[[%s|%s]]'%(reqname,aspectNames[req])]
       string += '| %s\n'%(', '.join(requirements))
       string += '| %s\n'%(', '.join(requirements))
     string += '| %s\n|-\n'%parse(blurb)
     string += '| %s\n|-\n'%parse(blurb)

Revision as of 02:49, 5 March 2022

This is a Python script to generate the Ability tables. Copy the code in the box below into a text file named abilityTable.py (or whatever you want) inside the Wildermyth directory. Then run it by calling python abilityTable.py from the command line. It will create a text file named abilityTable.txt with the appropriate wiki-formatted content.