diff --git a/res/cardTemplateScript.py b/res/cardTemplateScript.py index 9cc1fab1edb..863955a951a 100755 --- a/res/cardTemplateScript.py +++ b/res/cardTemplateScript.py @@ -4,6 +4,7 @@ pathToMtgData = "mtg-data.txt" ############IMPLEMENTATION FOLLOWS############ import os,sys,fnmatch +import re class Card: def __init__(self, name): @@ -144,8 +145,74 @@ def initSets(): # Return to Ravnica forgeSets.append('RTR') #forgeSets.append('GTC') - #forgeSets.append('UNK') + #forgeSets.append('UNK') +def initKeywords(): + keyWords.append('Cascade') + keyWords.append('Convoke') + keyWords.append('Deathtouch') + keyWords.append('Defender') + keyWords.append('Delve') + keyWords.append('Desertwalk') + keyWords.append('Double Strike') + keyWords.append('Epic') + keyWords.append('Exalted') + keyWords.append('Fear') + keyWords.append('First Strike') + keyWords.append('Flanking') + keyWords.append('Flash') + keyWords.append('Flying') + keyWords.append('Forestwalk') + keyWords.append('Haste') + keyWords.append('Hexproof') + keyWords.append('Hideaway') + keyWords.append('Horsemanship') + keyWords.append('Indestructible') + keyWords.append('Infect') + keyWords.append('Intimidate') + keyWords.append('Islandwalk') + keyWords.append('Lifelink') + keyWords.append('Living Weapon') + keyWords.append('Mountainwalk') + keyWords.append('Persist') + keyWords.append('Phasing') + keyWords.append('Plainswalk') + keyWords.append('Provoke') + keyWords.append('Reach') + keyWords.append('Rebound') + keyWords.append('Shadow') + keyWords.append('Shroud') + keyWords.append('Soulbond') + keyWords.append('Storm') + keyWords.append('Sunburst') + keyWords.append('Swampwalk') + keyWords.append('Trample') + keyWords.append('Unblockable') + keyWords.append('Undying') + keyWords.append('Vigilance') + keyWords.append('Wither') + + +def handleKeyords(line,keywords): + # split line by spaces to see if first token matches a keyword + line = line.rstrip(); + p = re.compile( '\s\(.*\)$') + line = p.sub('',line) + allKeywords = True + if line.find('Enchant') != -1 : + print 'K:'+line + return allKeywords + else : + # Multiple keywords could be comma seperated in mtgdata + words=line.split(', ') + for token in words : + if token.title() in keywords : + print 'K:'+token.title() + else : + allKeywords = False + + return allKeywords + if not os.path.exists(pathToMtgData) : print("This script requires the text version of Arch's mtg-data to be present.You can download it from slightlymagic.net's forum and either place the text version next to this script or edit this script and provide the path to the file at the top.") print("Press Enter to exit") @@ -153,6 +220,7 @@ if not os.path.exists(pathToMtgData) : sys.exit() forgeSets = [] +keyWords = [] mtgDataCards = {} setCodes = [] tmpName = "" @@ -160,6 +228,7 @@ line = "" # initialize sets supported by Forge initSets() +initKeywords() #Parse mtg-data mtgdata = open(pathToMtgData,"r") line = mtgdata.readline() @@ -231,6 +300,7 @@ while inputName != 'quit' : cleanName = cleanName.replace("'",'') cleanName = cleanName.replace(',','') cleanName = cleanName.replace(' ','_') + cleanName = cleanName.replace('-','_') print '\nName:'+cardData.name print 'ManaCost:'+cardData.cost print 'Types:'+cardData.types @@ -239,10 +309,31 @@ while inputName != 'quit' : print 'PT:'+cardData.pt elif cardData.types.find('Planeswalker') != -1 : print 'Loyalty:'+cardData.pt - print "\n