diff --git a/README.org b/README.org index 2519d7f..46726fd 100644 --- a/README.org +++ b/README.org @@ -20,7 +20,6 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards - =serverpath=: path to the site root on the server (with leading slash, without trailing slash) - =name=: the name you use in the game - =highpriority=: a list of high priority decks you’re collecting - - =mediumpriority=: a list of other decks you’re collecting - =tradepost=: URL of your trade post on Dreamwidth - =faves=: a list of cards to showcase on the index page - =headerbackground=: an HTML colour to display behind your header image and set as a theme colour @@ -31,6 +30,7 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards - =keepsig=: =True= if you always want to keep one copy of your signature, =False= if you want to make them all available for trading - =tradestatement=: statement to place on your trading page - =maxmastered=: maximum number of most recently mastered decks to show on the index page + - =masscollect=: list (python dict) of series/themes being mass collected and which decks to include in each one - Run the following: #+BEGIN_SRC bash python3 setup.py diff --git a/generate.py b/generate.py index c5e2b94..4d57a41 100644 --- a/generate.py +++ b/generate.py @@ -1,5 +1,5 @@ import sys -import download,indexgen,collectinggen,ownedgen,wantedgen,loggen,levelsgen,tradegen,masteredgen,portfoliosgen,searchgen +import download,indexgen,collectinggen,ownedgen,wantedgen,loggen,levelsgen,tradegen,masteredgen,portfoliosgen,searchgen,massgen print("Checking for new decks … ",end="") sys.stdout.flush() @@ -9,6 +9,9 @@ sys.stdout.flush() indexgen.indexgen() print(" done\nBuilding collecting page …",end="") sys.stdout.flush() +massgen.massall() +print(" done\nBuilding mass decks pages …",end="") +sys.stdout.flush() collectinggen.collectingall() print(" done\nBuilding owned page …",end="") sys.stdout.flush() diff --git a/massgen.py b/massgen.py new file mode 100644 index 0000000..f12c8e0 --- /dev/null +++ b/massgen.py @@ -0,0 +1,59 @@ +import datetime,os +import log,skel,tcgcore,variables + +massdecks = dict(sorted(variables.masscollect.items())) +massowned = {} +for series in massdecks: + ownedlist = [] + for card in tcgcore.ownedcards(): + if card[:-2] in massdecks[series]: + ownedlist.append(card) + if len(ownedlist) > 0: + massowned[series] = ownedlist + +def massindexgen(): + if not os.path.isdir("build/mass"): + os.mkdir("build/mass") + thefile = "build/mass/index.html" + if os.path.exists(thefile): + os.remove(thefile) + skel.headerwrite(thefile,"mass") + content = open(thefile,"a") + content.write("

mass collecting

\n\n") + content.close() + skel.footerwrite(thefile) + +def massseriesgen(series,massindex): + if not os.path.isdir("build/mass/" + str(massindex)): + os.mkdir("build/mass/" + str(massindex)) + thefile = "build/mass/" + str(massindex) + "/index.html" + if os.path.exists(thefile): + os.remove(thefile) + skel.headerwrite(thefile,"mass") + content = open(thefile,"a") + content.write("

" + series + "

\n

back to mass decks page

\n

") + for card in massowned[series]: + content.write(tcgcore.printcard(card)) + content.write("

\n") + content.close() + skel.footerwrite(thefile) + +def massall(): + massindexgen() + massindex = 1 + for series in massowned: + massseriesgen(series,massindex) + massindex += 1 + +if __name__ == "__main__": + massall() diff --git a/skel.py b/skel.py index 506fac4..bfbd054 100644 --- a/skel.py +++ b/skel.py @@ -13,6 +13,11 @@ def headerwrite(thefile,pagename): else: header.write("collecting") header.write("\n
  • ") + if pagename == "mass": + header.write("mass collecting") + else: + header.write("mass collecting") + header.write("
  • \n
  • ") if pagename == "mastered": header.write("mastered") else: diff --git a/tcgcore.py b/tcgcore.py index a062911..9f129a8 100644 --- a/tcgcore.py +++ b/tcgcore.py @@ -59,14 +59,20 @@ def datemastered(deck): cards[int(event["card"][-2:])] -= 1 if cards[1] > 0 and cards[2] > 0 and cards[3] > 0 and cards[4] > 0 and cards[5] > 0 and cards[6] > 0 and cards[7] > 0 and cards[8] > 0 and cards[9] > 0 and cards[10] > 0 and cards[11] > 0 and cards[12] > 0 and cards[13] > 0 and cards[14] > 0 and cards[15] > 0 and cards[16] > 0 and cards[17] > 0 and cards[18] > 0 and cards[19] > 0 and cards[20] > 0: mastered = event["date"] - return mastered + return mastered + +medium = [] +for series in variables.masscollect: + for deck in variables.masscollect[series]: + medium.append(deck) +medium = sorted(list(dict.fromkeys(medium))) def collecting(deck): if 0 < len (deckcards(deck)) < 20: if deck in variables.highpriority: return True else: - if deck in variables.medpriority: + if deck in medium: return True else: if len(deckcards(deck)) < variables.collectthreshold: @@ -84,7 +90,7 @@ def priority(deck): if len(deckcards(deck)) >= variables.highthreshold: return "high" else: - if deck in variables.medpriority: + if deck in medium: return "medium" else: if len(deckcards(deck)) >= variables.mediumthreshold: diff --git a/variables-template.py b/variables-template.py index 0e81306..82afa3e 100644 --- a/variables-template.py +++ b/variables-template.py @@ -2,7 +2,6 @@ servername = "" serverpath = "" name = "your name" highpriority = ["deckname","nameofadeck"] -medpriority = ["deckname","nameofdeck"] tradepost = "URL" faves = ["favecard01","favecard02"] headerbackground = "#000000" @@ -13,3 +12,4 @@ highthreshold = 10 keepsig = False tradestatement = "" maxmastered = 20 +masscollect = {"series":["firstdeck","seconddeck"]} diff --git a/wantedgen.py b/wantedgen.py index 2f0e26b..076db53 100644 --- a/wantedgen.py +++ b/wantedgen.py @@ -59,6 +59,7 @@ def wantedgen(): else: content.write(", ") content.write("

    \n") + content.write("

    I’m probably also interested in anything I’m mass collecting.

    \n") content.close() skel.footerwrite(thefile)