Allow not trading medium for high priority cards
This commit is contained in:
parent
3c463fa65f
commit
1cee7bfe9e
3 changed files with 36 additions and 27 deletions
|
@ -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)
|
- =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
|
- =name=: the name you use in the game
|
||||||
- =highpriority=: a list of high priority decks you’re collecting
|
- =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
|
- =tradepost=: URL of your trade post on Dreamwidth
|
||||||
- =faves=: a list of cards to showcase on the index page
|
- =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
|
- =headerbackground=: an HTML colour to display behind your header image and set as a theme colour
|
||||||
|
|
61
colors.py
61
colors.py
|
@ -317,30 +317,31 @@ for deck in decks:
|
||||||
thedeck["priority"] = 4
|
thedeck["priority"] = 4
|
||||||
decklist.append(thedeck)
|
decklist.append(thedeck)
|
||||||
|
|
||||||
print("Checking for new card images")
|
if __name__ == "__main__":
|
||||||
|
print("Checking for new card images")
|
||||||
|
|
||||||
for card in cardlist:
|
for card in cardlist:
|
||||||
if card["colour"] == "sig":
|
if card["colour"] == "sig":
|
||||||
if not os.path.exists("build/decks/sigs/" + card["name"][4:] + ".gif"):
|
if not os.path.exists("build/decks/sigs/" + card["name"][4:] + ".gif"):
|
||||||
print("Downloading " + card["name"])
|
print("Downloading " + card["name"])
|
||||||
r = requests.get("https://colors-tcg.eu/cards/" + card["name"] + ".gif")
|
r = requests.get("https://colors-tcg.eu/cards/" + card["name"] + ".gif")
|
||||||
open("build/decks/sigs/" + card["name"][4:] + ".gif","wb").write(r.content)
|
open("build/decks/sigs/" + card["name"][4:] + ".gif","wb").write(r.content)
|
||||||
|
|
||||||
for deck in decklist:
|
for deck in decklist:
|
||||||
if not os.path.isdir("build/decks/" + deck["name"]):
|
if not os.path.isdir("build/decks/" + deck["name"]):
|
||||||
os.mkdir("build/decks/" + deck["name"])
|
os.mkdir("build/decks/" + deck["name"])
|
||||||
print("Downloading " + deck["name"])
|
print("Downloading " + deck["name"])
|
||||||
number = 0
|
number = 0
|
||||||
while number < 21:
|
while number < 21:
|
||||||
if number < 10:
|
if number < 10:
|
||||||
r = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + "0" + str(number) + ".gif")
|
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)
|
open("build/decks/" + deck["name"] + "/0" + str(number) + ".gif","wb").write(r.content)
|
||||||
else:
|
else:
|
||||||
r = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + str(number) + ".gif")
|
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)
|
open("build/decks/" + deck["name"] + "/" + str(number) + ".gif","wb").write(r.content)
|
||||||
number += 1
|
number += 1
|
||||||
master = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + "master.gif")
|
master = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + "master.gif")
|
||||||
open("build/decks/" + deck["name"] + "/master.gif","wb").write(master.content)
|
open("build/decks/" + deck["name"] + "/master.gif","wb").write(master.content)
|
||||||
|
|
||||||
print("Getting list of wanted cards")
|
print("Getting list of wanted cards")
|
||||||
|
|
||||||
|
@ -2008,16 +2009,22 @@ def searchgen():
|
||||||
content.write(", ")
|
content.write(", ")
|
||||||
content.write("'" + card["name"] + "'")
|
content.write("'" + card["name"] + "'")
|
||||||
precomma = True
|
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=\"")
|
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 len(variables.subfolder) > 0:
|
if variables.trademedium:
|
||||||
content.write("/" + variables.subfolder)
|
content.write("\n if ((hptfound.length) > 0) {\n document.getElementById('hptfound').innerHTML = '<span class=\"sorttitle\">Will trade out for <a href=\"")
|
||||||
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=\"")
|
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:
|
if len(variables.subfolder) > 0:
|
||||||
content.write("/" + variables.subfolder)
|
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=\"")
|
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:
|
if len(variables.subfolder) > 0:
|
||||||
content.write("/" + variables.subfolder)
|
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()
|
content.close()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -3,6 +3,7 @@ serverpath = ""
|
||||||
subfolder = ""
|
subfolder = ""
|
||||||
name = "your name"
|
name = "your name"
|
||||||
highpriority = ["deckname","nameofadeck"]
|
highpriority = ["deckname","nameofadeck"]
|
||||||
|
trademedium = True
|
||||||
tradepost = "URL"
|
tradepost = "URL"
|
||||||
faves = ["favecard01","favecard02"]
|
faves = ["favecard01","favecard02"]
|
||||||
headerbackground = "#000000"
|
headerbackground = "#000000"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue