added set symbol to basics

added set symbol to the basics game mode. Changed name to "How Basic"
This commit is contained in:
marsteralex 2022-08-15 19:55:39 -04:00
parent 0333de143d
commit d09a46482c
8 changed files with 96 additions and 29 deletions

View File

@ -18,7 +18,13 @@ online = false
firstPrint = false
flag = true
page = 1
sets = {}
fetch('jsons/set.json')
.then((response) => response.json())
.then((data) => (sets = data))
window.console.log(sets)
document.location.search.split('&').forEach((pair) => {
let v = pair.split('=')
if (v[0] === '?whichguesser') {
@ -55,7 +61,7 @@ function putIntoMapAndFetch(data) {
} else if (whichGuesser === 'beast') {
document.getElementById('guess-type').innerText = 'Finding Fantastic Beasts'
} else if (whichGuesser === 'basic') {
document.getElementById('guess-type').innerText = 'Basic B****'
document.getElementById('guess-type').innerText = 'How Basic'
}
setUpNewGame()
}
@ -128,7 +134,7 @@ function determineIfSkip(card) {
}
if (firstPrint) {
if (whichGuesser == 'basic') {
if (card.set_type !== 'expansion') {
if (card.set_type !== 'expansion' && card.set_type !== 'funny') {
return true
}
} else {
@ -159,6 +165,13 @@ function putIntoMap(data) {
if (card.card_faces) {
name = card.card_faces[0].name
}
if (whichGuesser === 'basic') {
name =
'<img class="symbol" style="width: 15px; height: 15px" src="' +
sets[name][1] +
'" /> ' +
sets[name][0]
}
let normalImg = ''
if (card.image_uris.normal) {
normalImg = card.image_uris.normal
@ -219,7 +232,7 @@ function setUpNewGame() {
for (nameIndex = 1; nameIndex <= k + extra; nameIndex++) {
currName = document.getElementById('name-' + nameIndex)
// window.console.log(currName)
currName.innerText = namesList[nameIndex - 1]
currName.innerHTML = namesList[nameIndex - 1]
nameBank.appendChild(currName)
}
}
@ -347,6 +360,10 @@ function dropOnCard(id, data) {
}
function setWordsLeft() {
cardName = 'Unused Card Names: '
if (whichGuesser === 'basic') {
cardName = 'Unused Set Names: '
}
document.getElementById('words-left').innerText =
'Unused Card Names: ' + wordsLeft + '/Images: ' + imagesLeft
cardName + wordsLeft + '/Images: ' + imagesLeft
}

View File

@ -3,7 +3,8 @@ import requests
import json
# add category name here
allCategories = ['counterspell', 'beast', 'basic', 'burn'] #, 'terror', 'wrath']
allCategories = ['counterspell', 'beast', 'burn'] #, 'terror', 'wrath']
specialCategories = ['set', 'basic']
def generate_initial_query(category):
@ -22,14 +23,21 @@ 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 == 'basic':
string_query += 't%3Abasic&order=released&dir=asc&unique=prints&page='
# add category string query here
if category != 'basic':
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' \
'+-frame%3Aextendedart+language%3Aenglish&order=released&dir=asc&unique=prints&page='
'+language%3Aenglish&order=released&dir=asc&unique=prints&page='
print(string_query)
return string_query
def generate_initial_special_query(category):
string_query = 'https://api.scryfall.com/cards/search?q='
if category == 'set':
return 'https://api.scryfall.com/sets'
elif category == 'basic':
string_query += 't%3Abasic&order=released&dir=asc&unique=prints&page='
# add category string query here
print(string_query)
return string_query
@ -49,6 +57,24 @@ def fetch_and_write_all(category, query):
json.dump(all_cards, f)
def fetch_and_write_all_special(category, query):
count = 1
will_repeat = True
all_cards = {'data' : []}
art_names = set()
while will_repeat:
if category == 'set':
response = fetch_special(query)
else:
response = fetch(query, count)
will_repeat = response['has_more']
count+=1
to_compact_write_form_special(all_cards, art_names, response, category)
with open('jsons/' + category + '.json', 'w') as f:
json.dump(all_cards, f)
def fetch(query, count):
query += str(count)
@ -56,11 +82,15 @@ def fetch(query, count):
time.sleep(0.1)
return response
def fetch_special(query):
response = requests.get(f"{query}").json()
time.sleep(0.1)
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']
fieldsInBasic = ['image_uris', 'set_name', 'set_type', 'digital']
data = []
# write all fields needed in card
for card in response['data']:
@ -69,17 +99,7 @@ def to_compact_write_form(smallJson, art_names, response, category):
continue
else:
art_names.add(card['illustration_id'])
write_card = dict()
if category == 'basic':
for field in fieldsInBasic:
if field == 'image_uris':
write_card['image_uris'] = write_image_uris(card['image_uris'])
elif field == 'set_name':
write_card['name'] = card['set_name']
elif field in card:
write_card[field] = card[field]
else:
for field in fieldsInCard:
if field == 'name' and 'card_faces' in card:
write_card['name'] = card['card_faces'][0]['name']
@ -90,6 +110,32 @@ def to_compact_write_form(smallJson, art_names, response, category):
data.append(write_card)
smallJson['data'] += data
def to_compact_write_form_special(smallJson, art_names, response, category):
fieldsInBasic = ['image_uris', 'set', 'set_type', 'digital']
data = []
# write all fields needed in card
for card in response['data']:
if category == 'basic':
write_card = dict()
# do not repeat art
if 'illustration_id' not in card or card['illustration_id'] in art_names:
continue
else:
art_names.add(card['illustration_id'])
for field in fieldsInBasic:
if field == 'image_uris':
write_card['image_uris'] = write_image_uris(card['image_uris'])
elif field == 'set':
write_card['name'] = card['set']
elif field in card:
write_card[field] = card[field]
data.append(write_card)
else:
if card['set_type'] != 'token':
smallJson[card['code']] = [card['name'],card['icon_svg_uri']]
smallJson['data'] += data
# only write images needed
def write_image_uris(card_image_uris):
@ -106,6 +152,9 @@ def write_image_uris(card_image_uris):
if __name__ == "__main__":
for category in allCategories:
# 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(category, generate_initial_query(category))
fetch_and_write_all_special(category, generate_initial_special_query(category))

View File

@ -165,7 +165,7 @@
class="thumbnail"
src="https://c1.scryfall.com/file/scryfall-cards/art_crop/front/0/3/03683fbb-9843-4c14-bb95-387150e97c90.jpg?1642161346"
/>
<h3>Basic B****round</h3></label
<h3>How Basic</h3></label
>
<br />

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long