diff --git a/README.org b/README.org index 5372cd4..49c9149 100644 --- a/README.org +++ b/README.org @@ -21,6 +21,7 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards - =subfolder=: subfolder under your (sub)domain in which the TCG pages will be located (leave as an empty string if they are at the top level) - =name=: the name you use in the game - =highpriority=: a list of high priority decks you’re collecting + - =trademedium=: whether to allow trading medium-priority cards away in exchange for high-priority cards - =tradepost=: URL of your trade post on Dreamwidth - =faves=: a list of cards to showcase on the index page - =headerbackground=: an HTML colour to display behind your header image and set as a theme colour diff --git a/colors.py b/colors.py index bfc48e9..4395f42 100644 --- a/colors.py +++ b/colors.py @@ -317,30 +317,31 @@ for deck in decks: thedeck["priority"] = 4 decklist.append(thedeck) -print("Checking for new card images") +if __name__ == "__main__": + print("Checking for new card images") -for card in cardlist: - if card["colour"] == "sig": - if not os.path.exists("build/decks/sigs/" + card["name"][4:] + ".gif"): - print("Downloading " + card["name"]) - r = requests.get("https://colors-tcg.eu/cards/" + card["name"] + ".gif") - open("build/decks/sigs/" + card["name"][4:] + ".gif","wb").write(r.content) + for card in cardlist: + if card["colour"] == "sig": + if not os.path.exists("build/decks/sigs/" + card["name"][4:] + ".gif"): + print("Downloading " + card["name"]) + r = requests.get("https://colors-tcg.eu/cards/" + card["name"] + ".gif") + open("build/decks/sigs/" + card["name"][4:] + ".gif","wb").write(r.content) -for deck in decklist: - if not os.path.isdir("build/decks/" + deck["name"]): - os.mkdir("build/decks/" + deck["name"]) - print("Downloading " + deck["name"]) - number = 0 - while number < 21: - if number < 10: - r = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + "0" + str(number) + ".gif") - open("build/decks/" + deck["name"] + "/0" + str(number) + ".gif","wb").write(r.content) - else: - r = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + str(number) + ".gif") - open("build/decks/" + deck["name"] + "/" + str(number) + ".gif","wb").write(r.content) - number += 1 - master = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + "master.gif") - open("build/decks/" + deck["name"] + "/master.gif","wb").write(master.content) + for deck in decklist: + if not os.path.isdir("build/decks/" + deck["name"]): + os.mkdir("build/decks/" + deck["name"]) + print("Downloading " + deck["name"]) + number = 0 + while number < 21: + if number < 10: + r = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + "0" + str(number) + ".gif") + open("build/decks/" + deck["name"] + "/0" + str(number) + ".gif","wb").write(r.content) + else: + r = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + str(number) + ".gif") + open("build/decks/" + deck["name"] + "/" + str(number) + ".gif","wb").write(r.content) + number += 1 + master = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + "master.gif") + open("build/decks/" + deck["name"] + "/master.gif","wb").write(master.content) print("Getting list of wanted cards") @@ -2008,16 +2009,22 @@ def searchgen(): content.write(", ") content.write("'" + card["name"] + "'") precomma = True - content.write("];\n const searchstring = document.getElementById('cardinput').value;\n const dupesarray = searchstring.replaceAll(' ','').replaceAll('\\n',',').replaceAll('\\r',',').toLowerCase().split(',');\n var searcharray = [ ...new Set(dupesarray) ];\n const hpwfound = [];\n const mpwfound = [];\n const lpwfound = [];\n const hptfound = [];\n const mptfound = [];\n const lptfound = [];\n for (const element of searcharray) {\n let cardend = element.substring(element.length, element.length - 2);\n if (!(thecards.includes(cardend))) {\n for (const ending of thecards) {\n searcharray.push(element + ending);\n };\n };\n };\n for (const element of searcharray) {\n if (hpw.includes(element)) {\n hpwfound.push(element);\n } else if (mpw.includes(element)) {\n mpwfound.push(element);\n } else if (lpw.includes(element)) {\n lpwfound.push(element);\n } else if (hpt.includes(element)) {\n hptfound.push(element);\n } else if (mpt.includes(element)) {\n mptfound.push(element);\n } else if (lpt.includes(element)) {\n lptfound.push(element);\n };\n };\n if ((hpwfound.length) > 0) {\n document.getElementById('hpwfound').innerHTML = 'Wanted (high priority): ' + hpwfound.join(', ') + '';\n } else {\n document.getElementById('hpwfound').innerHTML = '';\n };\n if ((mpwfound.length) > 0) {\n document.getElementById('mpwfound').innerHTML = 'Wanted (medium priority): ' + mpwfound.join(', ') + '';\n } else {\n document.getElementById('mpwfound').innerHTML = '';\n };\n if ((lpwfound.length) > 0) {\n document.getElementById('lpwfound').innerHTML = 'Wanted (low priority): ' + lpwfound.join(', ') + '';\n } else {\n document.getElementById('lpwfound').innerHTML = '';\n };\n if ((hptfound.length) > 0) {\n document.getElementById('hptfound').innerHTML = 'Will trade out for 0: - content.write("/" + variables.subfolder) - content.write("/wanted\">high priority cards only: ' + hptfound.join(', ') + '';\n } else {\n document.getElementById('hptfound').innerHTML = '';\n };\n if ((mptfound.length) > 0) {\n document.getElementById('mptfound').innerHTML = 'Will trade out for 0) {\n document.getElementById('hpwfound').innerHTML = 'Wanted (high priority): ' + hpwfound.join(', ') + '';\n } else {\n document.getElementById('hpwfound').innerHTML = '';\n };\n if ((mpwfound.length) > 0) {\n document.getElementById('mpwfound').innerHTML = 'Wanted (medium priority): ' + mpwfound.join(', ') + '';\n } else {\n document.getElementById('mpwfound').innerHTML = '';\n };\n if ((lpwfound.length) > 0) {\n document.getElementById('lpwfound').innerHTML = 'Wanted (low priority): ' + lpwfound.join(', ') + '';\n } else {\n document.getElementById('lpwfound').innerHTML = '';\n };") + if variables.trademedium: + content.write("\n if ((hptfound.length) > 0) {\n document.getElementById('hptfound').innerHTML = 'Will trade out for 0: + content.write("/" + variables.subfolder) + content.write("/wanted\">high priority cards only: ' + hptfound.join(', ') + '';\n } else {\n document.getElementById('hptfound').innerHTML = '';\n };") + content.write("\n if ((mptfound.length) > 0) {\n document.getElementById('mptfound').innerHTML = 'Will trade out for 0: content.write("/" + variables.subfolder) content.write("/wanted\">high or medium priority cards: ' + mptfound.join(', ') + '';\n } else {\n document.getElementById('mptfound').innerHTML = '';\n };\n if ((lptfound.length) > 0) {\n document.getElementById('lptfound').innerHTML = 'Will trade out for 0: content.write("/" + variables.subfolder) - content.write("/wanted\">any wanted card: ' + lptfound.join(', ') + '';\n } else {\n document.getElementById('lptfound').innerHTML = '';\n };\n if ((hpwfound.length) + (mpwfound.length) + (lpwfound.length) + (hptfound.length) + (mptfound.length) + (lptfound.length) == 0) {\n document.getElementById('nothing').innerHTML = 'No results';\n } else {\n document.getElementById('nothing').innerHTML = '';\n }\n }\n\n \n \n") + content.write("/wanted\">any wanted card: ' + lptfound.join(', ') + '';\n } else {\n document.getElementById('lptfound').innerHTML = '';\n };\n if ((hpwfound.length) + (mpwfound.length) + (lpwfound.length)") + if variables.trademedium: + content.write(" + (hptfound.length)") + content.write(" + (mptfound.length) + (lptfound.length) == 0) {\n document.getElementById('nothing').innerHTML = 'No results';\n } else {\n document.getElementById('nothing').innerHTML = '';\n }\n }\n\n \n \n") content.close() if __name__ == "__main__": diff --git a/variables-template.py b/variables-template.py index 6a5ba55..d3dd68d 100644 --- a/variables-template.py +++ b/variables-template.py @@ -3,6 +3,7 @@ serverpath = "" subfolder = "" name = "your name" highpriority = ["deckname","nameofadeck"] +trademedium = True tradepost = "URL" faves = ["favecard01","favecard02"] headerbackground = "#000000"