add dfc support to commanders (#865)
* fix https * add beasts * Remove extra file * Prettier-ify code * Prettier-ify * add basic land guesser also added fetcher to filter all cards instead of only unique art * default to original makes basic better * added set symbol to basics added set symbol to the basics game mode. Changed name to "How Basic" * cleanup * changed some pixels * only load set data if needed * hacked fix for removing image from name * removed check from original * remove check from original * sort names by set instead of by set symbol * include battlebond * update cards for categories update for dominaria united * added commander category commander category * update basic land art * can use double feature * removing racist cards upstream this way we don't have to store the cards in the json * remove generated cards from digital commanders * fix counterspell setting default * added difficulty rating * updated padding * add dfc support for commanders Co-authored-by: Austin Chen <akrolsmir@gmail.com>
This commit is contained in:
parent
18466afc78
commit
1ae0f0e273
|
@ -3,16 +3,16 @@ import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
# add category name here
|
# add category name here
|
||||||
allCategories = ['counterspell', 'beast', 'burn', 'commander'] #, 'terror', 'wrath']
|
allCategories = ['counterspell', 'beast', 'burn', 'commander', 'artist'] #, 'terror', 'wrath', 'zombie', 'artifact']
|
||||||
specialCategories = ['set', 'basic']
|
specialCategories = ['set', 'basic']
|
||||||
|
|
||||||
|
|
||||||
def generate_initial_query(category):
|
def generate_initial_query(category):
|
||||||
string_query = 'https://api.scryfall.com/cards/search?q='
|
string_query = 'https://api.scryfall.com/cards/search?q='
|
||||||
if category == 'counterspell':
|
if category == 'counterspell':
|
||||||
string_query += 'otag%3Acounterspell+t%3Ainstant+not%3Aadventure'
|
string_query += 'otag%3Acounterspell+t%3Ainstant+not%3Aadventure+not%3Adfc'
|
||||||
elif category == 'beast':
|
elif category == 'beast':
|
||||||
string_query += '-type%3Alegendary+type%3Abeast+-type%3Atoken'
|
string_query += '-type%3Alegendary+type%3Abeast+-type%3Atoken+not%3Adfc'
|
||||||
# elif category == 'terror':
|
# elif category == 'terror':
|
||||||
# string_query += 'otag%3Acreature-removal+o%3A%2Fdestroy+target.%2A+%28creature%7Cpermanent%29%2F+%28t' \
|
# string_query += 'otag%3Acreature-removal+o%3A%2Fdestroy+target.%2A+%28creature%7Cpermanent%29%2F+%28t' \
|
||||||
# '%3Ainstant+or+t%3Asorcery%29+o%3Atarget+not%3Aadventure'
|
# '%3Ainstant+or+t%3Asorcery%29+o%3Atarget+not%3Aadventure'
|
||||||
|
@ -22,13 +22,19 @@ def generate_initial_query(category):
|
||||||
string_query += '%28c>%3Dr+or+mana>%3Dr%29+%28o%3A%2Fdamage+to+them%2F+or+%28o%3Adeals+o%3Adamage+o%3A' \
|
string_query += '%28c>%3Dr+or+mana>%3Dr%29+%28o%3A%2Fdamage+to+them%2F+or+%28o%3Adeals+o%3Adamage+o%3A' \
|
||||||
'%2Fcontroller%28%5C.%7C+%29%2F%29+or+o%3A%2F~+deals+%28.%7C..%29+damage+to+%28any+target%7C' \
|
'%2Fcontroller%28%5C.%7C+%29%2F%29+or+o%3A%2F~+deals+%28.%7C..%29+damage+to+%28any+target%7C' \
|
||||||
'.*player%28%5C.%7C+or+planeswalker%29%7C.*opponent%28%5C.%7C+or+planeswalker%29%29%2F%29' \
|
'.*player%28%5C.%7C+or+planeswalker%29%7C.*opponent%28%5C.%7C+or+planeswalker%29%29%2F%29' \
|
||||||
'+%28type%3Ainstant+or+type%3Asorcery%29+not%3Aadventure'
|
'+%28type%3Ainstant+or+type%3Asorcery%29+not%3Aadventure+not%3Adfc'
|
||||||
elif category == 'commander':
|
elif category == 'commander':
|
||||||
string_query += 'is%3Acommander+%28not%3Adigital+-banned%3Acommander+or+is%3Adigital+legal%3Ahistoricbrawl+or+legal%3Acommander+or+legal%3Abrawl%29'
|
string_query += 'is%3Acommander+%28not%3Adigital+-banned%3Acommander+or+is%3Adigital+legal%3Ahistoricbrawl+or+legal%3Acommander+or+legal%3Abrawl%29'
|
||||||
|
# elif category == 'zombie':
|
||||||
|
# string_query += '-type%3Alegendary+type%3Azombie+-type%3Atoken'
|
||||||
|
# elif category == 'artifact':
|
||||||
|
# string_query += 't%3Aartifact&order=released&dir=asc&unique=prints&page='
|
||||||
|
# elif category == 'artist':
|
||||||
|
# string_query+= 'a%3A"Wylie+Beckert"+or+a%3A“Ernanda+Souza”+or+a%3A"randy+gallegos"+or+a%3A“Amy+Weber”+or+a%3A“Dan+Frazier”+or+a%3A“Thomas+M.+Baxa”+or+a%3A“Phil+Foglio”+or+a%3A“DiTerlizzi”+or+a%3A"steve+argyle"+or+a%3A"Veronique+Meignaud"+or+a%3A"Magali+Villeneuve"+or+a%3A"Michael+Sutfin"+or+a%3A“Volkan+Baǵa”+or+a%3A“Franz+Vohwinkel”+or+a%3A"Nils+Hamm"+or+a%3A"Mark+Poole"+or+a%3A"Carl+Critchlow"+or+a%3A"rob+alexander"+or+a%3A"igor+kieryluk"+or+a%3A“Victor+Adame+Minguez”+or+a%3A"johannes+voss"+or+a%3A"Svetlin+Velinov"+or+a%3A"ron+spencer"+or+a%3A"rk+post"+or+a%3A"kev+walker"+or+a%3A"rebecca+guay"+or+a%3A"seb+mckinnon"+or+a%3A"pete+venters"+or+a%3A"greg+staples"+or+a%3A"Christopher+Moeller"+or+a%3A"christopher+rush"+or+a%3A"Mark+Tedin"'
|
||||||
# add category string query here
|
# add category string query here
|
||||||
string_query += '+-%28set%3Asld+%28%28cn>%3D231+cn<%3D233%29+or+%28cn>%3D321+cn<%3D324%29+or+%28cn>%3D185+cn' \
|
string_query += '+-%28set%3Asld+%28%28cn>%3D231+cn<%3D233%29+or+%28cn>%3D321+cn<%3D324%29+or+%28cn>%3D185+cn' \
|
||||||
'<%3D189%29+or+%28cn>%3D138+cn<%3D142%29+or+%28cn>%3D364+cn<%3D368%29+or+cn%3A669+or+cn%3A670%29' \
|
'<%3D189%29+or+%28cn>%3D138+cn<%3D142%29+or+%28cn>%3D364+cn<%3D368%29+or+cn%3A669+or+cn%3A670%29' \
|
||||||
'%29+-name%3A%2F%5EA-%2F+not%3Adfc+not%3Asplit+-set%3Acmb2+-set%3Acmb1+-set%3Aplist' \
|
'%29+-name%3A%2F%5EA-%2F+not%3Asplit+-set%3Acmb2+-set%3Acmb1+-set%3Aplist+-st%3Amemorabilia' \
|
||||||
'+language%3Aenglish&order=released&dir=asc&unique=prints&page='
|
'+language%3Aenglish&order=released&dir=asc&unique=prints&page='
|
||||||
print(string_query)
|
print(string_query)
|
||||||
return string_query
|
return string_query
|
||||||
|
@ -53,7 +59,7 @@ def fetch_and_write_all(category, query):
|
||||||
response = fetch(query, count)
|
response = fetch(query, count)
|
||||||
will_repeat = response['has_more']
|
will_repeat = response['has_more']
|
||||||
count+=1
|
count+=1
|
||||||
to_compact_write_form(all_cards, art_names, response)
|
to_compact_write_form(all_cards, art_names, response, category)
|
||||||
|
|
||||||
with open('jsons/' + category + '.json', 'w') as f:
|
with open('jsons/' + category + '.json', 'w') as f:
|
||||||
json.dump(all_cards, f)
|
json.dump(all_cards, f)
|
||||||
|
@ -90,7 +96,7 @@ def fetch_special(query):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def to_compact_write_form(smallJson, art_names, response):
|
def to_compact_write_form(smallJson, art_names, response, category):
|
||||||
fieldsInCard = ['name', 'image_uris', 'flavor_name', 'reprint', 'frame_effects', 'digital', 'set_type']
|
fieldsInCard = ['name', 'image_uris', 'flavor_name', 'reprint', 'frame_effects', 'digital', 'set_type']
|
||||||
data = []
|
data = []
|
||||||
# write all fields needed in card
|
# write all fields needed in card
|
||||||
|
@ -99,15 +105,26 @@ def to_compact_write_form(smallJson, art_names, response):
|
||||||
if 'content_warning' in card and card['content_warning'] == True:
|
if 'content_warning' in card and card['content_warning'] == True:
|
||||||
continue
|
continue
|
||||||
# do not repeat art
|
# do not repeat art
|
||||||
if 'illustration_id' not in card or card['illustration_id'] in art_names:
|
if 'card_faces' in card:
|
||||||
|
card_face = card['card_faces'][0]
|
||||||
|
if 'illustration_id' not in card_face or card_face['illustration_id'] in art_names:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
art_names.add(card_face['illustration_id'])
|
||||||
|
elif 'illustration_id' not in card or card['illustration_id'] in art_names:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
art_names.add(card['illustration_id'])
|
art_names.add(card['illustration_id'])
|
||||||
write_card = dict()
|
write_card = dict()
|
||||||
for field in fieldsInCard:
|
for field in fieldsInCard:
|
||||||
|
# if field == 'name' and category == 'artifact':
|
||||||
|
# write_card['name'] = card['released_at'].split('-')[0]
|
||||||
if field == 'name' and 'card_faces' in card:
|
if field == 'name' and 'card_faces' in card:
|
||||||
write_card['name'] = card['card_faces'][0]['name']
|
write_card['name'] = card['card_faces'][0]['name']
|
||||||
elif field == 'image_uris':
|
elif field == 'image_uris':
|
||||||
|
if 'card_faces' in card and 'image_uris' in card['card_faces'][0]:
|
||||||
|
write_card['image_uris'] = write_image_uris(card['card_faces'][0]['image_uris'])
|
||||||
|
else:
|
||||||
write_card['image_uris'] = write_image_uris(card['image_uris'])
|
write_card['image_uris'] = write_image_uris(card['image_uris'])
|
||||||
elif field in card:
|
elif field in card:
|
||||||
write_card[field] = card[field]
|
write_card[field] = card[field]
|
||||||
|
@ -119,6 +136,9 @@ def to_compact_write_form_special(smallJson, art_names, response, category):
|
||||||
data = []
|
data = []
|
||||||
# write all fields needed in card
|
# write all fields needed in card
|
||||||
for card in response['data']:
|
for card in response['data']:
|
||||||
|
# do not include racist cards
|
||||||
|
if 'content_warning' in card and card['content_warning'] == True:
|
||||||
|
continue
|
||||||
if category == 'basic':
|
if category == 'basic':
|
||||||
write_card = dict()
|
write_card = dict()
|
||||||
# do not repeat art
|
# do not repeat art
|
||||||
|
|
1
web/public/mtg/jsons/artist.json
Normal file
1
web/public/mtg/jsons/artist.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user