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

247 lines
10 KiB
Python

3 weeks ago
import datetime,os
import log,variables,skel
3 weeks ago
def collectinggen():
if not os.path.isdir("build/collecting"):
os.mkdir("build/collecting")
if os.path.exists("build/collecting/index.html"):
os.remove("build/collecting/index.html")
thefile = "build/collecting/index.html"
skel.headerwrite(thefile,"collecting")
content = open(thefile,"a")
content.write("<h1>decks in progress</h1>\n")
ownedcards = []
decksofinterest = []
for event in log.log:
for card in event["received"]:
ownedcards.append(card)
decksofinterest.append(card[:-2])
ownedcards = sorted(ownedcards)
decksofinterest = sorted(list(dict.fromkeys(decksofinterest)))
highpriority = []
medpriority = []
for deck in decksofinterest:
if deck in variables.highpriority:
3 weeks ago
highpriority.append(deck)
else:
medpriority.append(deck)
if len(highpriority) > 0:
content.write("<h2>High priority</h2>\n")
for deck in highpriority:
with open("build/decks/" + deck + "/type") as thetype:
decktype = thetype.read()
cardcount = sum(deck in card for card in ownedcards)
content.write("<table class=\"decktable " + decktype + "\">\n<thead>\n <tr>\n <th colspan=\"5\">" + deck + " [" + str(cardcount) + "/20]</th>\n </tr>\n</thead>\n<tbody>\n <tr>\n <td><img src=\"/decks/" + deck + "/")
3 weeks ago
if deck + "01" in ownedcards:
content.write("01")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "02" in ownedcards:
content.write("02")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "03" in ownedcards:
content.write("03")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "04" in ownedcards:
content.write("04")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "05" in ownedcards:
content.write("05")
else:
content.write("00")
content.write(".gif\"></td>\n </tr>\n <tr>\n <td><img src=\"/decks/" + deck + "/")
if deck + "06" in ownedcards:
content.write("06")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "07" in ownedcards:
content.write("07")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "08" in ownedcards:
content.write("08")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "09" in ownedcards:
content.write("09")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "10" in ownedcards:
content.write("10")
else:
content.write("00")
content.write(".gif\"></td>\n </tr>\n <tr>\n <td><img src=\"/decks/" + deck + "/")
if deck + "11" in ownedcards:
content.write("11")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "12" in ownedcards:
content.write("12")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "13" in ownedcards:
content.write("13")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "14" in ownedcards:
content.write("14")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "15" in ownedcards:
content.write("15")
else:
content.write("00")
content.write(".gif\"></td>\n </tr>\n <tr>\n <td><img src=\"/decks/" + deck + "/")
if deck + "16" in ownedcards:
content.write("16")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "17" in ownedcards:
content.write("17")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "18" in ownedcards:
content.write("18")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "19" in ownedcards:
content.write("19")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "20" in ownedcards:
content.write("20")
else:
content.write("00")
content.write(".gif\"></td>\n </tr>\n</tbody>\n</table>\n")
if len(medpriority) > 0:
content.write("<h2>Medium priority</h2>\n")
for deck in medpriority:
with open("build/decks/" + deck + "/type") as thetype:
decktype = thetype.read()
cardcount = sum(deck in card for card in ownedcards)
content.write("<table class=\"decktable " + decktype + "\">\n<thead>\n <tr>\n <th colspan=\"5\">" + deck + " [" + str(cardcount) + "/20]</th>\n </tr>\n</thead>\n<tbody>\n <tr>\n <td><img src=\"/decks/" + deck + "/")
3 weeks ago
if deck + "01" in ownedcards:
content.write("01")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "02" in ownedcards:
content.write("02")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "03" in ownedcards:
content.write("03")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "04" in ownedcards:
content.write("04")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "05" in ownedcards:
content.write("05")
else:
content.write("00")
content.write(".gif\"></td>\n </tr>\n <tr>\n <td><img src=\"/decks/" + deck + "/")
if deck + "06" in ownedcards:
content.write("06")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "07" in ownedcards:
content.write("07")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "08" in ownedcards:
content.write("08")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "09" in ownedcards:
content.write("09")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "10" in ownedcards:
content.write("10")
else:
content.write("00")
content.write(".gif\"></td>\n </tr>\n <tr>\n <td><img src=\"/decks/" + deck + "/")
if deck + "11" in ownedcards:
content.write("11")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "12" in ownedcards:
content.write("12")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "13" in ownedcards:
content.write("13")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "14" in ownedcards:
content.write("14")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "15" in ownedcards:
content.write("15")
else:
content.write("00")
content.write(".gif\"></td>\n </tr>\n <tr>\n <td><img src=\"/decks/" + deck + "/")
if deck + "16" in ownedcards:
content.write("16")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "17" in ownedcards:
content.write("17")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "18" in ownedcards:
content.write("18")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "19" in ownedcards:
content.write("19")
else:
content.write("00")
content.write(".gif\"></td>\n <td><img src=\"/decks/" + deck + "/")
if deck + "20" in ownedcards:
content.write("20")
else:
content.write("00")
content.write(".gif\"></td>\n </tr>\n</tbody>\n</table>\n")
content.close()
skel.footerwrite(thefile)
if __name__ == "__main__":
collectinggen()