Difference between revisions of "Calamity track/Script"

From Wildermyth Wiki
(Created page with "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>calamity...")
 
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})
             add_entry(card_list,flavor,tracks[j]['onlyIfFlavorHasCards'],{'name':cardName + ' %s'%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})
             add_entry(card_list,flavor,0,{'name':cardName + ' %s'%cardNumbers[k],'cards':monsters,'count':k+1,'position':j})
         else:
         else:
           if 'trackAdvanceThresholds' in tracks[j]:
           if 'trackAdvanceThresholds' in tracks[j]:
Line 79: Line 79:
string += 'In this way, each faction has a [[calamity track]] consisting of successively more dangerous cards.\n'
string += 'In this way, each faction has a [[calamity track]] consisting of successively more dangerous cards.\n'
string += '==Table==\n'
string += '==Table==\n'
string += 'If drawn within a [[mission]], each card typically generates a number of the specified monster equal to the card\'s roman numeral. There are some exceptions, which are noted in the table.\n'
string += 'If drawn within a [[mission]], each card typically generates a number of the specified monster equal to the card\'s roman numeral. '
string += 'There are some exceptions, which are noted in the table. '
string += 'Also, \'\'italicized\'\' cards are not drawn as [[calamity]] cards but are instead available from a campaign\'s outset.\n'
string += '{| class="wikitable" style="text-align: center"\n'
string += '{| class="wikitable" style="text-align: center"\n'
string += '! Threshold<br>cards !! [[%s]] !! [[%s]] !! [[%s]] !! [[%s]] !! [[%s]]\n'%tuple(card_list)
string += '! Threshold<br>cards !! [[%s]] !! [[%s]] !! [[%s]] !! [[%s]] !! [[%s]]\n'%tuple(card_list)
Line 92: Line 94:
         if j > 0:
         if j > 0:
           string += '<br>'
           string += '<br>'
        if 'position' in card and card['position'] < 2:
          string += "''"
         string += card['name']
         string += card['name']
        if 'position' in card and card['position'] < 2:
          string += "''"
         if len(set(card['cards'])) > 1 or len(card['cards']) != card['count']:
         if len(set(card['cards'])) > 1 or len(card['cards']) != card['count']:
           string += '<ref>'
           string += '<ref>'
Line 104: Line 110:
string += '|}\n\n'
string += '|}\n\n'
string += '==Notes==\n'
string += '==Notes==\n'
string += '<small>Last updated [[%s]] using [[/Script|this script]].</small>\n'%version[:-1]
string += 'Last updated [[%s]] using [[/Script|this script]].\n'%version[:-1]
    
    
with open('calamityTable.txt', 'w') as f:
with open('calamityTable.txt', 'w') as f:
   f.write(string)</nowiki>
   f.write(string)</nowiki>
|}
|}

Revision as of 04:34, 20 February 2022

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