diff --git a/web/public/mtg/app.js b/web/public/mtg/app.js index a2f7679b..2708896a 100644 --- a/web/public/mtg/app.js +++ b/web/public/mtg/app.js @@ -64,6 +64,8 @@ function putIntoMapAndFetch(data) { document.getElementById('guess-type').innerText = 'Finding Fantastic Beasts' } else if (whichGuesser === 'basic') { document.getElementById('guess-type').innerText = 'How Basic' + } else if (whichGuesser === 'commander') { + document.getElementById('guess-type').innerText = 'General Knowledge' } setUpNewGame() } @@ -156,8 +158,8 @@ function determineIfSkip(card) { if (card.flavor_name) { return true } - // don't include racist cards - return card.content_warning + + return false } function putIntoMap(data) { diff --git a/web/public/mtg/importCards.py b/web/public/mtg/importCards.py index 14266c18..17a5e2c2 100644 --- a/web/public/mtg/importCards.py +++ b/web/public/mtg/importCards.py @@ -3,7 +3,7 @@ import requests import json # add category name here -allCategories = ['counterspell', 'beast', 'burn'] #, 'terror', 'wrath'] +allCategories = ['counterspell', 'beast', 'burn', 'commander'] #, 'terror', 'wrath'] specialCategories = ['set', 'basic'] @@ -23,10 +23,12 @@ def generate_initial_query(category): '%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' \ '+%28type%3Ainstant+or+type%3Asorcery%29+not%3Aadventure' + elif category == 'commander': + string_query += '-banned%3Acommander+is%3Acommander' # 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' \ '<%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+-set%3Adbl' \ + '%29+-name%3A%2F%5EA-%2F+not%3Adfc+not%3Asplit+-set%3Acmb2+-set%3Acmb1+-set%3Aplist' \ '+language%3Aenglish&order=released&dir=asc&unique=prints&page=' print(string_query) return string_query @@ -51,7 +53,7 @@ def fetch_and_write_all(category, query): response = fetch(query, count) will_repeat = response['has_more'] count+=1 - to_compact_write_form(all_cards, art_names, response, category) + to_compact_write_form(all_cards, art_names, response) with open('jsons/' + category + '.json', 'w') as f: json.dump(all_cards, f) @@ -88,12 +90,14 @@ def fetch_special(query): return response -def to_compact_write_form(smallJson, art_names, response, category): - fieldsInCard = ['name', 'image_uris', 'content_warning', 'flavor_name', 'reprint', 'frame_effects', 'digital', - 'set_type'] +def to_compact_write_form(smallJson, art_names, response): + fieldsInCard = ['name', 'image_uris', 'flavor_name', 'reprint', 'frame_effects', 'digital', 'set_type'] data = [] # write all fields needed in card for card in response['data']: + # do not include racist cards + if 'content_warning' in card and card['content_warning'] == True: + continue # do not repeat art if 'illustration_id' not in card or card['illustration_id'] in art_names: continue @@ -152,9 +156,9 @@ def write_image_uris(card_image_uris): if __name__ == "__main__": - # for category in allCategories: - # print(category) - # fetch_and_write_all(category, generate_initial_query(category)) + for category in allCategories: + print(category) + fetch_and_write_all(category, generate_initial_query(category)) for category in specialCategories: print(category) fetch_and_write_all_special(category, generate_initial_special_query(category)) diff --git a/web/public/mtg/index.html b/web/public/mtg/index.html index b58cc627..bfb324c1 100644 --- a/web/public/mtg/index.html +++ b/web/public/mtg/index.html @@ -17,6 +17,14 @@ f.parentNode.insertBefore(j, f) })(window, document, 'script', 'dataLayer', 'GTM-M3MBVGG') +