Allow not trading medium for high priority cards

master
trémeur 3 days ago
parent 3c463fa65f
commit 1cee7bfe9e

@ -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 youre 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

@ -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 = '<span class=\"sorttitle\">Wanted (high priority):</span> <span class=\"searchresults\">' + hpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('hpwfound').innerHTML = '';\n };\n if ((mpwfound.length) > 0) {\n document.getElementById('mpwfound').innerHTML = '<span class=\"sorttitle\">Wanted (medium priority):</span> <span class=\"searchresults\">' + mpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('mpwfound').innerHTML = '';\n };\n if ((lpwfound.length) > 0) {\n document.getElementById('lpwfound').innerHTML = '<span class=\"sorttitle\">Wanted (low priority):</span> <span class=\"searchresults\">' + lpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('lpwfound').innerHTML = '';\n };\n if ((hptfound.length) > 0) {\n document.getElementById('hptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"")
if len(variables.subfolder) > 0:
content.write("/" + variables.subfolder)
content.write("/wanted\">high priority cards</a> only:</span> <span class=\"searchresults\">' + hptfound.join(', ') + '</span>';\n } else {\n document.getElementById('hptfound').innerHTML = '';\n };\n if ((mptfound.length) > 0) {\n document.getElementById('mptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"")
content.write("];\n const searchstring = document.getElementById('cardinput').value;\n const dupesarray = searchstring.replaceAll(' ','').replaceAll('\\n',',').replaceAll('\\r',',').toLowerCase().split(',');\n const 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 };\n if (mpw.includes(element)) {\n mpwfound.push(element);\n };\n if (lpw.includes(element)) {\n lpwfound.push(element);\n };\n if (hpt.includes(element)) {\n hptfound.push(element);\n };\n if (mpt.includes(element)) {\n mptfound.push(element);\n };\n if (lpt.includes(element)) {\n lptfound.push(element);\n };\n };\n if ((hpwfound.length) > 0) {\n document.getElementById('hpwfound').innerHTML = '<span class=\"sorttitle\">Wanted (high priority):</span> <span class=\"searchresults\">' + hpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('hpwfound').innerHTML = '';\n };\n if ((mpwfound.length) > 0) {\n document.getElementById('mpwfound').innerHTML = '<span class=\"sorttitle\">Wanted (medium priority):</span> <span class=\"searchresults\">' + mpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('mpwfound').innerHTML = '';\n };\n if ((lpwfound.length) > 0) {\n document.getElementById('lpwfound').innerHTML = '<span class=\"sorttitle\">Wanted (low priority):</span> <span class=\"searchresults\">' + lpwfound.join(', ') + '</span>';\n } else {\n document.getElementById('lpwfound').innerHTML = '';\n };")
if variables.trademedium:
content.write("\n if ((hptfound.length) > 0) {\n document.getElementById('hptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"")
if len(variables.subfolder) > 0:
content.write("/" + variables.subfolder)
content.write("/wanted\">high priority cards</a> only:</span> <span class=\"searchresults\">' + hptfound.join(', ') + '</span>';\n } else {\n document.getElementById('hptfound').innerHTML = '';\n };")
content.write("\n if ((mptfound.length) > 0) {\n document.getElementById('mptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"")
if len(variables.subfolder) > 0:
content.write("/" + variables.subfolder)
content.write("/wanted\">high or medium priority cards</a>:</span> <span class=\"searchresults\">' + mptfound.join(', ') + '</span>';\n } else {\n document.getElementById('mptfound').innerHTML = '';\n };\n if ((lptfound.length) > 0) {\n document.getElementById('lptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"")
if len(variables.subfolder) > 0:
content.write("/" + variables.subfolder)
content.write("/wanted\">any wanted card</a>:</span> <span class=\"searchresults\">' + lptfound.join(', ') + '</span>';\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</script>\n </main>\n </body>\n</html>")
content.write("/wanted\">any wanted card</a>:</span> <span class=\"searchresults\">' + lptfound.join(', ') + '</span>';\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</script>\n </main>\n </body>\n</html>")
content.close()
if __name__ == "__main__":

@ -3,6 +3,7 @@ serverpath = ""
subfolder = ""
name = "your name"
highpriority = ["deckname","nameofadeck"]
trademedium = True
tradepost = "URL"
faves = ["favecard01","favecard02"]
headerbackground = "#000000"

Loading…
Cancel
Save