Difference between revisions of "Calamity track/Script"

From Wildermyth Wiki
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
This is a [https://www.python.org/downloads/ Python] script to generate the [[calamity track]] table. Copy the code in the box below into a text file named '''<nowiki>calamityTable.py</nowiki>''' (or whatever you want) inside the '''<nowiki>Wildermyth</nowiki>''' directory. Then run it by calling '''<nowiki>python calamityTable.py</nowiki>''' from the command line. It will create a text file named '''<nowiki>calamityTable.txt</nowiki>''', which is wiki-formatted and can be pasted into the [[calamity track]] page.
This is a [https://www.python.org/downloads/ Python] script to generate the [[calamity track]] table. Copy the code in the box below into a text file named '''<nowiki>wikiCalamityTable.py</nowiki>''' (or whatever you want) inside the '''<nowiki>Wildermyth</nowiki>''' directory. Then run it by calling '''<nowiki>python wikiCalamityTable.py</nowiki>''' from the command line. It will create a text file named '''<nowiki>wikiCalamityTable.txt</nowiki>''', which is wiki-formatted and can be pasted into the [[calamity track]] page.


{| role="presentation" class="wikitable mw-collapsible mw-collapsed"
{| role="presentation" class="wikitable mw-collapsible mw-collapsed"
| '''<nowiki>calamityTable.py</nowiki>'''
| '''<nowiki>wikiCalamityTable.py</nowiki>'''
|-
|-
|
|
Line 64: Line 64:
         if k == 0:
         if k == 0:
           if 'onlyIfFlavorHasCards' in tracks[j]:
           if 'onlyIfFlavorHasCards' in tracks[j]:
             add_entry(card_list,flavor,tracks[j]['onlyIfFlavorHasCards'],{'name':cardName + ' %s'%cardNumbers[k],'cards':monsters,'count':k+1,'position':j})
             add_entry(card_list,flavor,tracks[j]['onlyIfFlavorHasCards'],{'name':cardName,'numeral':cardNumbers[k],'cards':monsters,'count':k+1,'position':j})
             max_cards = max(tracks[j]['onlyIfFlavorHasCards'],max_cards)
             max_cards = max(tracks[j]['onlyIfFlavorHasCards'],max_cards)
           else:
           else:
             add_entry(card_list,flavor,0,{'name':cardName + ' %s'%cardNumbers[k],'cards':monsters,'count':k+1,'position':j})
             add_entry(card_list,flavor,0,{'name':cardName,'numeral':cardNumbers[k],'cards':monsters,'count':k+1,'position':j})
         else:
         else:
           if 'trackAdvanceThresholds' in tracks[j]:
           if 'trackAdvanceThresholds' in tracks[j]:
             add_entry(card_list,flavor,tracks[j]['trackAdvanceThresholds'][k-1],{'name':cardName + ' %s'%cardNumbers[k],'cards':monsters,'count':k+1})
             add_entry(card_list,flavor,tracks[j]['trackAdvanceThresholds'][k-1],{'name':cardName,'numeral':cardNumbers[k],'cards':monsters,'count':k+1})
             max_cards = max(tracks[j]['trackAdvanceThresholds'][k-1],max_cards)
             max_cards = max(tracks[j]['trackAdvanceThresholds'][k-1],max_cards)
           else:
           else:
Line 96: Line 96:
         if 'position' in card and card['position'] < 2:
         if 'position' in card and card['position'] < 2:
           string += "''"
           string += "''"
         string += card['name']
         string += '[[%s|%s]] %s'%(card['cards'][0],card['name'],card['numeral'])
         if 'position' in card and card['position'] < 2:
         if 'position' in card and card['position'] < 2:
           string += "''"
           string += "''"
Line 112: Line 112:
string += 'Last updated [[%s]] using [[/Script|this script]].\n'%version[:-1]
string += 'Last updated [[%s]] using [[/Script|this script]].\n'%version[:-1]
    
    
with open('calamityTable.txt', 'w') as f:
with open('wikiCalamityTable.txt', 'w') as f:
   f.write(string)</nowiki>
   f.write(string)</nowiki>
|}
|}

Latest revision as of 13:38, 5 March 2022

This is a Python script to generate the calamity track table. Copy the code in the box below into a text file named wikiCalamityTable.py (or whatever you want) inside the Wildermyth directory. Then run it by calling python wikiCalamityTable.py from the command line. It will create a text file named wikiCalamityTable.txt, which is wiki-formatted and can be pasted into the calamity track page.