Track mass decks and use them to build the collecting page

master
trémeur 7 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) - =serverpath=: path to the site root on the server (with leading slash, without trailing slash)
- =name=: the name you use in the game - =name=: the name you use in the game
- =highpriority=: a list of high priority decks youre collecting - =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 - =tradepost=: URL of your trade post on Dreamwidth
- =faves=: a list of cards to showcase on the index page - =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 - =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 - =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 - =tradestatement=: statement to place on your trading page
- =maxmastered=: maximum number of most recently mastered decks to show on the index 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: - Run the following:
#+BEGIN_SRC bash #+BEGIN_SRC bash
python3 setup.py python3 setup.py

@ -1,5 +1,5 @@
import sys 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="") print("Checking for new decks … ",end="")
sys.stdout.flush() sys.stdout.flush()
@ -9,6 +9,9 @@ sys.stdout.flush()
indexgen.indexgen() indexgen.indexgen()
print(" done\nBuilding collecting page …",end="") print(" done\nBuilding collecting page …",end="")
sys.stdout.flush() sys.stdout.flush()
massgen.massall()
print(" done\nBuilding mass decks pages …",end="")
sys.stdout.flush()
collectinggen.collectingall() collectinggen.collectingall()
print(" done\nBuilding owned page …",end="") print(" done\nBuilding owned page …",end="")
sys.stdout.flush() 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: else:
header.write("<a href=\"/collecting\">collecting</a>") header.write("<a href=\"/collecting\">collecting</a>")
header.write("</li>\n <li>") 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": if pagename == "mastered":
header.write("mastered") header.write("mastered")
else: else:

@ -59,14 +59,20 @@ def datemastered(deck):
cards[int(event["card"][-2:])] -= 1 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: 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"] 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): def collecting(deck):
if 0 < len (deckcards(deck)) < 20: if 0 < len (deckcards(deck)) < 20:
if deck in variables.highpriority: if deck in variables.highpriority:
return True return True
else: else:
if deck in variables.medpriority: if deck in medium:
return True return True
else: else:
if len(deckcards(deck)) < variables.collectthreshold: if len(deckcards(deck)) < variables.collectthreshold:
@ -84,7 +90,7 @@ def priority(deck):
if len(deckcards(deck)) >= variables.highthreshold: if len(deckcards(deck)) >= variables.highthreshold:
return "high" return "high"
else: else:
if deck in variables.medpriority: if deck in medium:
return "medium" return "medium"
else: else:
if len(deckcards(deck)) >= variables.mediumthreshold: if len(deckcards(deck)) >= variables.mediumthreshold:

@ -2,7 +2,6 @@ servername = ""
serverpath = "" serverpath = ""
name = "your name" name = "your name"
highpriority = ["deckname","nameofadeck"] highpriority = ["deckname","nameofadeck"]
medpriority = ["deckname","nameofdeck"]
tradepost = "URL" tradepost = "URL"
faves = ["favecard01","favecard02"] faves = ["favecard01","favecard02"]
headerbackground = "#000000" headerbackground = "#000000"
@ -13,3 +12,4 @@ highthreshold = 10
keepsig = False keepsig = False
tradestatement = "" tradestatement = ""
maxmastered = 20 maxmastered = 20
masscollect = {"series":["firstdeck","seconddeck"]}

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

Loading…
Cancel
Save