You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tcg/collectinggen.py

82 lines
3.2 KiB
Python

import datetime,os
import log,variables,skel,tcgcore
def collectinggen(colour=False):
if not os.path.isdir("build/collecting"):
os.mkdir("build/collecting")
if colour:
if not os.path.isdir("build/collecting/" + colour):
os.mkdir("build/collecting/" + colour)
thefile = "build/collecting/" + colour + "/index.html"
else:
thefile = "build/collecting/index.html"
if os.path.exists(thefile):
os.remove(thefile)
skel.headerwrite(thefile,"collecting")
content = open(thefile,"a")
content.write("<h1>decks in progress</h1>\n")
decksofinterest = []
for card in tcgcore.ownedcards():
if card[0:4] != "sig_":
if colour:
if tcgcore.cardtype(card) == colour:
decksofinterest.append(card[:-2])
else:
decksofinterest.append(card[:-2])
decksofinterest = sorted(list(dict.fromkeys(decksofinterest)))
highpriority = []
medpriority = []
lowpriority = []
for deck in decksofinterest:
if deck in variables.highpriority:
highpriority.append(deck)
elif deck in variables.medpriority:
medpriority.append(deck)
else:
if tcgcore.collecting(deck):
lowpriority.append(deck)
content.write("<p>")
if colour:
content.write("Filtered to <b>")
if colour == "gray":
if variables.british:
content.write("grey")
else:
content.write("gray")
else:
content.write(colour)
content.write("</b>. <a href=\"/collecting\">Show all</a>")
else:
content.write("Filter: <a href=\"/collecting/red\" title=\"red\">🔴</a> <a href=\"/collecting/orange\" title=\"orange\">🟠</a> <a href=\"/collecting/yellow\" title=\"yellow\">🟡</a> <a href=\"/collecting/green\" title=\"green\">🟢</a> <a href=\"/collecting/blue\" title=\"blue\">🔵</a> <a href=\"/collecting/purple\" title=\"purple\">🟣</a> <a href=\"/collecting/brown\" title=\"brown\">🟤</a> <a href=\"/collecting/gray\" title=\"")
if variables.british:
content.write("grey")
else:
content.write("gray")
content.write("\">⚪</a> <a href=\"/collecting/special\" title=\"special\">✨</a>")
content.write("</p>\n")
if len(highpriority) > 0:
content.write("<div>\n<h2 class=\"collectingheader\">High priority</h2>\n")
for deck in highpriority:
content.write(tcgcore.printdeck(deck))
content.write("</div>\n")
if len(medpriority) > 0:
content.write("<div>\n<h2 class=\"collectingheader\">Medium priority</h2>\n")
for deck in medpriority:
content.write(tcgcore.printdeck(deck))
content.write("</div>\n")
if len(lowpriority) > 0:
content.write("<div>\n<h2 class=\"collectingheader\">Low priority</h2>\n")
for deck in lowpriority:
content.write(tcgcore.printdeck(deck))
content.write("</div>\n")
content.close()
skel.footerwrite(thefile)
def collectingall():
collectinggen()
for type in tcgcore.typelist:
collectinggen(type)
if __name__ == "__main__":
collectingall()