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

64 lines
2.3 KiB
Python

1 month ago
import datetime,os
import log,variables,skel,tcgcore
1 month ago
def collectinggen(colour=False):
1 month ago
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)
1 month ago
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])
1 month ago
decksofinterest = sorted(list(dict.fromkeys(decksofinterest)))
highpriority = []
medpriority = []
lowpriority = []
1 month ago
for deck in decksofinterest:
if tcgcore.collecting(deck):
if tcgcore.priority(deck) == "high":
highpriority.append(deck)
elif tcgcore.priority(deck) == "medium":
medpriority.append(deck)
else:
lowpriority.append(deck)
content.write(tcgcore.filterwrite("collecting",colour))
1 month ago
if len(highpriority) > 0:
content.write("<div>\n<h2 class=\"collectingheader\">High priority</h2>\n")
1 month ago
for deck in highpriority:
content.write(tcgcore.printdeck(deck,False))
content.write("</div>\n")
1 month ago
if len(medpriority) > 0:
content.write("<div>\n<h2 class=\"collectingheader\">Medium priority</h2>\n")
1 month ago
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")
1 month ago
content.close()
skel.footerwrite(thefile)
def collectingall():
1 month ago
collectinggen()
for type in tcgcore.typelist:
collectinggen(type)
if __name__ == "__main__":
collectingall()