From af395bc486d6cae73b9d71c07cd2d01fbef3c03b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Thu, 7 Nov 2024 23:36:25 +0000 Subject: [PATCH] Add card search --- build/style.css | 10 +++++ generate.py | 3 +- searchgen.py | 103 ++++++++++++++++++++++++++++++++++++++++++++++++ skel.py | 5 +++ 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 searchgen.py diff --git a/build/style.css b/build/style.css index d0d742c..eb0be8c 100644 --- a/build/style.css +++ b/build/style.css @@ -548,3 +548,13 @@ table.portfolio.gray td.deck7 { table.portfolio.gray td.deck8 { color: rgb(228,222,220); } + +/* card search */ + +form * { + display: block; +} + +span.sorttitle { + font-weight: bold; +} diff --git a/generate.py b/generate.py index d92b106..f27cbbe 100644 --- a/generate.py +++ b/generate.py @@ -1,4 +1,4 @@ -import download,indexgen,collectinggen,ownedgen,wantedgen,loggen,levelsgen,tradegen,masteredgen,portfoliosgen +import download,indexgen,collectinggen,ownedgen,wantedgen,loggen,levelsgen,tradegen,masteredgen,portfoliosgen,searchgen download.getimg() indexgen.indexgen() @@ -10,3 +10,4 @@ levelsgen.levelsgen() tradegen.tradeall() masteredgen.masteredall() portfoliosgen.portfoliosgen() +searchgen.searchgen() diff --git a/searchgen.py b/searchgen.py new file mode 100644 index 0000000..adf53df --- /dev/null +++ b/searchgen.py @@ -0,0 +1,103 @@ +import os +import skel,tcgcore,variables + +def searchgen(): + decksofinterest = [] + for card in tcgcore.ownedcards(): + if card[0:4] != "sig_": + decksofinterest.append(card[:-2]) + decksofinterest = sorted(list(dict.fromkeys(decksofinterest))) + wantedcards = [] + ownedcollecting = [] + for deck in decksofinterest: + wantedlist = ["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20"] + for card in wantedlist: + combined = deck + card + if combined in tcgcore.ownedcards(): + if tcgcore.collecting(deck): + ownedcollecting.append(combined) + else: + wantedcards.append(combined) + hpw = [] + mpw = [] + lpw = [] + hpt = [] + mpt = [] + lpt = [] + for card in wantedcards: + if card[:-2] in variables.highpriority: + hpw.append(card) + elif card[:-2] in variables.medpriority: + mpw.append(card) + else: + if tcgcore.collecting(card[:-2]): + lpw.append(card) + previouscard = "" + for card in tcgcore.ownedcards(): + if card[0:4] != "sig_": + if card == previouscard: + lpt.append(card) + else: + if not tcgcore.deckmastered(card[:-2]): + if card in ownedcollecting: + if card[:-2] in variables.medpriority: + hpt.append(card) + else: + if card[:-2] not in variables.highpriority: + mpt.append(card) + else: + lpt.append(card) + if not os.path.isdir("build/search"): + os.mkdir("build/search") + thefile = "build/search/index.html" + if os.path.exists(thefile): + os.remove(thefile) + skel.headerwrite(thefile,"search") + content = open(thefile,"a") + content.write("

card search

\n
\n \n \n \n
\n

\n

\n

\n

\n

\n

\n

\n\n \n \n") + content.close() + +if __name__ == "__main__": + searchgen() diff --git a/skel.py b/skel.py index e8e056e..506fac4 100644 --- a/skel.py +++ b/skel.py @@ -33,6 +33,11 @@ def headerwrite(thefile,pagename): else: header.write("wanted") header.write("\n
  • ") + if pagename == "search": + header.write("search") + else: + header.write("search") + header.write("
  • \n
  • ") if pagename == "log": header.write("log") else: