Fix costs in text (#107)

* Replace anything found in `{}` with uppercase, single character versions

* Remove debug print
This commit is contained in:
tritoch 2017-07-07 16:27:00 -05:00 committed by GitHub
parent c13a719944
commit 4d62dcf946

View File

@ -93,9 +93,21 @@ def correct_cards(mtgjson, manual_cards=[], card_corrections=[], delete_cards=[]
mtgjson = {"cards": mtgjson2}
for card in mtgjson['cards']:
if '{' in card['text']:
card['text'] = re.sub(r'{(.*?)}', replace_costs, card['text'])
return mtgjson
def replace_costs(match):
full_cost = match.group(1)
individual_costs = []
if len(full_cost) > 0:
for x in range(0, len(full_cost)):
individual_costs.append('{' + str(full_cost[x]).upper() + '}')
return ''.join(individual_costs)
def error_check(mtgjson, card_corrections={}):
errors = []
for card in mtgjson['cards']: