import datetime,os
import log,variables,skel,tcgcore
def masteredgen(colour=False):
if not os.path.isdir("build/mastered"):
os.mkdir("build/mastered")
if colour:
if not os.path.isdir("build/mastered/" + colour):
os.mkdir("build/mastered/" + colour)
thefile = "build/mastered/" + colour + "/index.html"
else:
thefile = "build/mastered/index.html"
if os.path.exists(thefile):
os.remove(thefile)
skel.headerwrite(thefile,"mastered")
content = open(thefile,"a")
content.write("
mastered decks
\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)))
mastereddecks = []
for deck in decksofinterest:
if tcgcore.deckmastered(deck):
mastereddecks.append(deck)
content.write(tcgcore.filterwrite("mastered",colour))
for deck in mastereddecks:
content.write(tcgcore.printdeck(deck))
content.close()
skel.footerwrite(thefile)
def masteredall():
masteredgen()
for type in tcgcore.typelist:
masteredgen(type)
if __name__ == "__main__":
masteredall()