Track mass decks and use them to build the collecting page

master
trémeur 5 days ago
parent 5a4de3d8cd
commit 6e3f617aba

@ -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 youre collecting
- =mediumpriority=: a list of other decks youre 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

@ -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()

@ -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("<h1>mass collecting</h1>\n<ul>\n")
massindex = 1
for series in massowned:
content.write("<li><a href=\"/mass/" + str(massindex) + "\">" + series + "</a> (")
if len(massowned[series]) == len(variables.masscollect[series]) * 20:
content.write("complete")
else:
content.write(str(len(massowned[series])) + "/" + str(len(variables.masscollect[series]) * 20))
content.write(")</li>\n")
massindex += 1
content.write("</ul>\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("<h1>" + series + "</h1>\n<p><a href=\"/mass\">back to mass decks page</a></p>\n<p>")
for card in massowned[series]:
content.write(tcgcore.printcard(card))
content.write("</p>\n")
content.close()
skel.footerwrite(thefile)
def massall():
massindexgen()
massindex = 1
for series in massowned:
massseriesgen(series,massindex)
massindex += 1
if __name__ == "__main__":
massall()

@ -13,6 +13,11 @@ def headerwrite(thefile,pagename):
else:
header.write("<a href=\"/collecting\">collecting</a>")
header.write("</li>\n <li>")
if pagename == "mass":
header.write("mass collecting")
else:
header.write("<a href=\"/mass\">mass collecting</a>")
header.write("</li>\n <li>")
if pagename == "mastered":
header.write("mastered")
else:

@ -61,12 +61,18 @@ def datemastered(deck):
mastered = event["date"]
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:

@ -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"]}

@ -59,6 +59,7 @@ def wantedgen():
else:
content.write(", ")
content.write("</p>\n")
content.write("<p>Im probably also interested in anything Im <a href=\"/mass\">mass collecting</a>.</p>\n")
content.close()
skel.footerwrite(thefile)

Loading…
Cancel
Save