Add card type filter

master
trémeur 3 weeks ago
parent ad95e08715
commit cc59c175ec

1
.gitignore vendored

@ -1,3 +1,4 @@
build/*/*/index.html
build/*/index.html build/*/index.html
build/index.html build/index.html
build/decks/*/*.gif build/decks/*/*.gif

@ -1,18 +1,27 @@
import datetime,os import datetime,os
import log,variables,skel,tcgcore import log,variables,skel,tcgcore
def collectinggen(): def collectinggen(colour=False):
if not os.path.isdir("build/collecting"): if not os.path.isdir("build/collecting"):
os.mkdir("build/collecting") os.mkdir("build/collecting")
if os.path.exists("build/collecting/index.html"): if colour:
os.remove("build/collecting/index.html") 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" thefile = "build/collecting/index.html"
if os.path.exists(thefile):
os.remove(thefile)
skel.headerwrite(thefile,"collecting") skel.headerwrite(thefile,"collecting")
content = open(thefile,"a") content = open(thefile,"a")
content.write("<h1>decks in progress</h1>\n") content.write("<h1>decks in progress</h1>\n")
decksofinterest = [] decksofinterest = []
for card in tcgcore.ownedcards(): for card in tcgcore.ownedcards():
if card[0:4] != "sig_": if card[0:4] != "sig_":
if colour:
if tcgcore.cardtype(card) == colour:
decksofinterest.append(card[:-2])
else:
decksofinterest.append(card[:-2]) decksofinterest.append(card[:-2])
decksofinterest = sorted(list(dict.fromkeys(decksofinterest))) decksofinterest = sorted(list(dict.fromkeys(decksofinterest)))
highpriority = [] highpriority = []
@ -26,6 +35,25 @@ def collectinggen():
else: else:
if tcgcore.collecting(deck): if tcgcore.collecting(deck):
lowpriority.append(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: if len(highpriority) > 0:
content.write("<div>\n<h2 class=\"collectingheader\">High priority</h2>\n") content.write("<div>\n<h2 class=\"collectingheader\">High priority</h2>\n")
for deck in highpriority: for deck in highpriority:
@ -44,5 +72,10 @@ def collectinggen():
content.close() content.close()
skel.footerwrite(thefile) skel.footerwrite(thefile)
if __name__ == "__main__": def collectingall():
collectinggen() collectinggen()
for type in tcgcore.typelist:
collectinggen(type)
if __name__ == "__main__":
collectingall()

@ -14,7 +14,7 @@ def getimg():
index = 0 # adapted from https://stackoverflow.com/a/64536882 index = 0 # adapted from https://stackoverflow.com/a/64536882
indexValidList = [] indexValidList = []
print("Deck type for " + card[:-2] + ":") print("Deck type for " + card[:-2] + ":")
options = ["red","orange","yellow","green","blue","purple","brown","gray","special"] options = tcgcore.typelist
for optionName in options: for optionName in options:
index = index + 1 index = index + 1
indexValidList.extend([options.index(optionName)]) indexValidList.extend([options.index(optionName)])

@ -2,9 +2,9 @@ import download,indexgen,collectinggen,ownedgen,wantedgen,loggen,levelsgen,trade
download.getimg() download.getimg()
indexgen.indexgen() indexgen.indexgen()
collectinggen.collectinggen() collectinggen.collectingall()
ownedgen.ownedgen() ownedgen.ownedall()
wantedgen.wantedgen() wantedgen.wantedgen()
loggen.loggen() loggen.loggen()
levelsgen.levelsgen() levelsgen.levelsgen()
tradegen.tradegen() tradegen.tradeall()

@ -1,21 +1,53 @@
import datetime,os import datetime,os
import log,skel,tcgcore import log,skel,tcgcore,variables
def ownedgen(): def ownedgen(colour=False):
if not os.path.isdir("build/owned"): if not os.path.isdir("build/owned"):
os.mkdir("build/owned") os.mkdir("build/owned")
if os.path.exists("build/owned/index.html"): if colour:
os.remove("build/owned/index.html") if not os.path.isdir("build/owned/" + colour):
os.mkdir("build/owned/" + colour)
thefile = "build/owned/" + colour + "/index.html"
else:
thefile = "build/owned/index.html" thefile = "build/owned/index.html"
if os.path.exists(thefile):
os.remove(thefile)
skel.headerwrite(thefile,"owned") skel.headerwrite(thefile,"owned")
content = open(thefile,"a") content = open(thefile,"a")
content.write("<h1>owned cards</h1>\n<p>") content.write("<h1>owned cards</h1>\n<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=\"/owned\">Show all</a>")
else:
content.write("Filter: <a href=\"/owned/red\" title=\"red\">🔴</a> <a href=\"/owned/orange\" title=\"orange\">🟠</a> <a href=\"/owned/yellow\" title=\"yellow\">🟡</a> <a href=\"/owned/green\" title=\"green\">🟢</a> <a href=\"/owned/blue\" title=\"blue\">🔵</a> <a href=\"/owned/purple\" title=\"purple\">🟣</a> <a href=\"/owned/brown\" title=\"brown\">🟤</a> <a href=\"/owned/gray\" title=\"")
if variables.british:
content.write("grey")
else:
content.write("gray")
content.write("\">⚪</a> <a href=\"/owned/special\" title=\"special\">✨</a>")
content.write("</p>\n<p>")
for card in tcgcore.ownedcards(): for card in tcgcore.ownedcards():
if card[0:4] != "sig_": if card[0:4] != "sig_":
if colour:
if tcgcore.cardtype(card) == colour:
content.write(tcgcore.printcard(card))
else:
content.write(tcgcore.printcard(card)) content.write(tcgcore.printcard(card))
content.write("</p>\n") content.write("</p>\n")
content.close() content.close()
skel.footerwrite(thefile) skel.footerwrite(thefile)
if __name__ == "__main__": def ownedall():
ownedgen() ownedgen()
for type in tcgcore.typelist:
ownedgen(type)
if __name__ == "__main__":
ownedall()

@ -1,5 +1,7 @@
import log,variables import log,variables
typelist = ["red","orange","yellow","green","blue","purple","brown","gray","special"]
def ownedcards(): def ownedcards():
ownedcards = [] ownedcards = []
for event in log.log: for event in log.log:
@ -35,35 +37,38 @@ def collecting(deck):
else: else:
return True return True
def cardtype(card):
with open("build/decks/" + card[:-2] + "/type") as thetype:
cardtype = thetype.read()
return(cardtype)
def cardtext(card): def cardtext(card):
cardtext = "<span class=\"cardname\">" cardtext = "<span class=\"cardname\">"
if card[0:4] == "sig_": if card[0:4] == "sig_":
cardtext += "<span title=\"signature\">✍</span>" + card + "</span>" cardtext += "<span title=\"signature\">✍</span>" + card + "</span>"
else: else:
with open("build/decks/" + card[:-2] + "/type") as thetype: if cardtype(card) == "red":
cardtype = thetype.read()
if cardtype == "red":
cardtext += "<span title=\"red\">🔴</span>" cardtext += "<span title=\"red\">🔴</span>"
elif cardtype == "orange": elif cardtype(card) == "orange":
cardtext += "<span title=\"orange\">🟠</span>" cardtext += "<span title=\"orange\">🟠</span>"
elif cardtype == "yellow": elif cardtype(card) == "yellow":
cardtext += "<span title=\"yellow\">🟡</span>" cardtext += "<span title=\"yellow\">🟡</span>"
elif cardtype == "green": elif cardtype(card) == "green":
cardtext += "<span title=\"green\">🟢</span>" cardtext += "<span title=\"green\">🟢</span>"
elif cardtype == "blue": elif cardtype(card) == "blue":
cardtext += "<span title=\"blue\">🔵</span>" cardtext += "<span title=\"blue\">🔵</span>"
elif cardtype == "purple": elif cardtype(card) == "purple":
cardtext += "<span title=\"purple\">🟣</span>" cardtext += "<span title=\"purple\">🟣</span>"
elif cardtype == "brown": elif cardtype(card) == "brown":
cardtext += "<span title=\"brown\">🟤</span>" cardtext += "<span title=\"brown\">🟤</span>"
elif cardtype == "gray": elif cardtype(card) == "gray":
cardtext += "<span title=\"" cardtext += "<span title=\""
if variables.british: if variables.british:
cardtext += "grey" cardtext += "grey"
else: else:
cardtext += "gray" cardtext += "gray"
cardtext += "\">⚪</span>" cardtext += "\">⚪</span>"
elif cardtype == "special": elif cardtype(card) == "special":
cardtext += "<span title=\"special\">✨</span>" cardtext += "<span title=\"special\">✨</span>"
cardtext += card + "</span>" cardtext += card + "</span>"
return cardtext return cardtext

@ -1,17 +1,45 @@
import datetime,os import datetime,os
import log,skel,tcgcore,variables import log,skel,tcgcore,variables
def tradegen(): def tradegen(colour=False):
if not os.path.isdir("build/trade"): if not os.path.isdir("build/trade"):
os.mkdir("build/trade") os.mkdir("build/trade")
if os.path.exists("build/trade/index.html"): if colour:
os.remove("build/trade/index.html") if not os.path.isdir("build/trade/" + colour):
os.mkdir("build/trade/" + colour)
thefile = "build/trade/" + colour + "/index.html"
else:
thefile = "build/trade/index.html" thefile = "build/trade/index.html"
if os.path.exists(thefile):
os.remove(thefile)
skel.headerwrite(thefile,"trade") skel.headerwrite(thefile,"trade")
content = open(thefile,"a") content = open(thefile,"a")
content.write("<h1>available for trade</h1>\n<p>") content.write("<h1>available for trade</h1>\n<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=\"/trade\">Show all</a>")
else:
content.write("Filter: <a href=\"/trade/red\" title=\"red\">🔴</a> <a href=\"/trade/orange\" title=\"orange\">🟠</a> <a href=\"/trade/yellow\" title=\"yellow\">🟡</a> <a href=\"/trade/green\" title=\"green\">🟢</a> <a href=\"/trade/blue\" title=\"blue\">🔵</a> <a href=\"/trade/purple\" title=\"purple\">🟣</a> <a href=\"/trade/brown\" title=\"brown\">🟤</a> <a href=\"/trade/gray\" title=\"")
if variables.british:
content.write("grey")
else:
content.write("gray")
content.write("\">⚪</a> <a href=\"/trade/special\" title=\"special\">✨</a> <a href=\"/trade/sig\" title=\"sig\">✍</a>")
content.write("</p>\n<p>")
for card in tcgcore.ownedcards(): for card in tcgcore.ownedcards():
if card[0:4] != "sig_": if card[0:4] != "sig_":
if colour:
if not tcgcore.collecting(card[:-2]):
if tcgcore.cardtype(card) == colour:
content.write(tcgcore.printcard(card))
else:
if not tcgcore.collecting(card[:-2]): if not tcgcore.collecting(card[:-2]):
content.write(tcgcore.printcard(card)) content.write(tcgcore.printcard(card))
siglist = [] siglist = []
@ -20,11 +48,22 @@ def tradegen():
siglist.append(card) siglist.append(card)
if variables.keepsig == True: if variables.keepsig == True:
siglist.remove(siglist[0]) siglist.remove(siglist[0])
if colour:
if colour == "sig":
for sig in siglist:
content.write(tcgcore.printcard(sig))
else:
for sig in siglist: for sig in siglist:
content.write(tcgcore.printcard(sig)) content.write(tcgcore.printcard(sig))
content.write("</p>\n<p>Trade cards <a href=\"" + variables.tradepost + "\">here</a></p>\n") content.write("</p>\n<p>Trade cards <a href=\"" + variables.tradepost + "\">here</a></p>\n")
content.close() content.close()
skel.footerwrite(thefile) skel.footerwrite(thefile)
if __name__ == "__main__": def tradeall():
tradegen() tradegen()
for type in tcgcore.typelist:
tradegen(type)
tradegen("sig")
if __name__ == "__main__":
tradeall()

Loading…
Cancel
Save