From 9898c298153cf74322c86fc49f20cb44cf62bdb4 Mon Sep 17 00:00:00 2001 From: Sol Date: Wed, 18 Nov 2015 04:22:48 +0000 Subject: [PATCH] - Script for creating new edition files from mtgjson --- .gitattributes | 1 + forge-gui/tools/editionCreator.py | 37 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 forge-gui/tools/editionCreator.py diff --git a/.gitattributes b/.gitattributes index 02a00f7311a..92007519fc6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18345,6 +18345,7 @@ forge-gui/tools/assignSetInfo.py svneol=native#text/x-python forge-gui/tools/cardTemplateScript.py svneol=native#text/x-python forge-gui/tools/deckAiCompat.py -text forge-gui/tools/deckForgeCompat.py -text +forge-gui/tools/editionCreator.py -text forge-gui/tools/extractSetInfo.py -text forge-gui/tools/formatCards -text forge-gui/tools/formats.txt -text diff --git a/forge-gui/tools/editionCreator.py b/forge-gui/tools/editionCreator.py new file mode 100644 index 00000000000..6f46c23428b --- /dev/null +++ b/forge-gui/tools/editionCreator.py @@ -0,0 +1,37 @@ +import sys +import requests +import argparse + +parser = argparse.ArgumentParser(description='Edition File Generator') + +# -s for set code +parser.add_argument('-c', action='store', dest='setcode', help='Required setcode', default=None) +parser.add_argument('-n', action='store', dest='name', help='Name of edition', default='NEW SET XXX') +parser.add_argument('-t', action='store', dest='settype', help='Type of edition (Expansion, Duel_Decks, Other, etc)', default='Expansion') + +result = parser.parse_args() + +if result.setcode is None: + print "Missing required set code. Please provide a -c command line argument.\n" + print parser.parse_args(['-h']) + sys.exit(1) + +r = requests.get('http://mtgjson.com/json/%s.json' % result.setcode) +d = r.json() +cards = d['cards'] + +f = open('%s.txt' % result.name, 'w') + +f.write('[metadata]\n') +f.write('Code=%s\n' % result.setcode) +f.write('Date=2015-XX-XX\n') +f.write('Name=%s\n' % result.name) +f.write('Code2=%s\n' % result.setcode) +f.write('Type=%s\n\n' % result.settype) +f.write('[cards]\n') + +for c in cards: + rarity = c['rarity'][0] + if rarity == 'B': + rarity = 'L' + f.write(rarity + ' ' + c['name'].replace(u'\xc6', 'AE') + '\n') \ No newline at end of file