Skip to content

Commit

Permalink
Update card list
Browse files Browse the repository at this point in the history
  • Loading branch information
april committed Jan 21, 2019
1 parent ea08763 commit e8c0353
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion js/cards/decklist-cards-min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/cards/generatecards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -e
# Clean up a bit
rm -f -- *.js *.zip

curl http://mtgjson.com/json/AllCards-x.json.zip > AllCards-x.json.zip
unzip AllCards-x.json.zip
curl https://mtgjson.com/json/AllCards.json.zip > AllCards.json.zip
unzip AllCards.json.zip

# Parse out the giant JSON and make a much smaller one
./parsecards.py
Expand Down
28 changes: 10 additions & 18 deletions js/cards/parsecards.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,24 @@
# n (actual name) = 'true name nemesis' to 'True Name Nemesis'
# t (type) = 1 = land, 2 = creature, 3 = instant or sorcery 4 = other

FORMATS = ('Standard', 'Modern', 'Legacy')
FORMATS = {
'standard': 's',
'modern': 'm',
'legacy': 'l'
}

def getLegalities(card, cards):
# Let's figure out legalities
banned = 'sml'

for legality in cards[card].get('legalities', []):
if legality.get('format') in FORMATS and legality.get('legality') != 'Banned':
banned = banned.replace(legality.get('format')[0].lower(), '')

# if 'legalities' not in cards[card]: pass
# else:
#
# If it doesn't have an entry in the JSON file, that means it's outside the format; we'll call that banned
# if 'Standard' not in cards[card]['legalities']: cards[card]['legalities']['Standard'] = "Banned"
# if 'Modern' not in cards[card]['legalities']: cards[card]['legalities']['Modern'] = "Banned"
# if 'Legacy' not in cards[card]['legalities']: cards[card]['legalities']['Legacy'] = "Banned"

# Now to see if we should add them to our list
# if cards[card]['legalities']['Standard'] == "Banned": banned += "s"
# if cards[card]['legalities']['Modern'] == "Banned": banned += "m"
# if cards[card]['legalities']['Legacy'] == "Banned": banned += "l"
for gameformat, abbrevation in FORMATS.items():
if cards[card].get('legalities', {}).get(gameformat) == 'Legal':
banned = banned.replace(abbrevation, '')

return(banned)

# Open the JSON file
jsonfh = open("AllCards-x.json", "r")
jsonfh = open("AllCards.json", "r")

# Load all the cards into a giant dictionary
cards = json.load(jsonfh)
Expand Down

0 comments on commit e8c0353

Please sign in to comment.