Show mastered decks on front page

master
trémeur 2 months ago
parent 113461ce19
commit 6edfaf7172

@ -28,6 +28,7 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards
- =collectthreshold=: minimum number of owned cards for putting a deck in the “collecting” category
- =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
- Run the following:
#+BEGIN_SRC bash
python3 setup.py

@ -226,6 +226,24 @@ def indexgen():
if sketch > 19:
content.write("<td align=\"center\">" + str(int(sketch / 20)) + " completed</td>\n")
content.write("</tr>\n</tbody>\n</table>")
decksofinterest = []
for card in tcgcore.ownedcards():
if card[0:4] != "sig_":
decksofinterest.append(card[:-2])
decksofinterest = sorted(list(dict.fromkeys(decksofinterest)))
mastereddecks = []
for deck in decksofinterest:
if tcgcore.deckmastered(deck):
mastereddecks.append({"name":deck,"date":tcgcore.datemastered(deck)})
mastereddecks = sorted(mastereddecks,key=lambda d: d["date"],reverse=True)
if len(mastereddecks) > 0:
content.write("<h2>mastered decks</h2>\n<p>")
masteredcount = 1
for deck in mastereddecks:
if masteredcount < variables.maxmastered:
content.write("<img src=\"/decks/" + deck["name"] + "/master.gif\" title=\"mastered " + deck["name"] + "\">")
masteredcount += 1
content.write("</p>\n")
sigs = []
for card in tcgcore.ownedcards():
if card[0:4] == "sig_":

@ -31,6 +31,36 @@ def deckmastered(deck):
else:
return False
def datemastered(deck):
if deckmastered(deck):
deckdates = []
for event in log.log:
try:
if event["received"]:
for card in event["received"]:
if card[:-2] == deck:
deckdates.append({"card":card,"date":event["date"],"event":"received"})
except:
pass
try:
if event["lost"]:
for card in event["lost"]:
if card[:-2] == deck:
deckdates.append({"card":card,"date":event["date"],"event":"lost"})
except:
pass
cards = {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0}
mastered = False
for event in deckdates:
if not mastered:
if event["event"] == "received":
cards[int(event["card"][-2:])] += 1
if event["event"] == "lost":
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
def collecting(deck):
if len (deckcards(deck)) < 20:
if deck in variables.highpriority:
@ -94,8 +124,12 @@ def printdeck(deck):
deckstring = "<table class=\"decktable "
with open("build/decks/" + deck + "/type") as thetype:
decktype = thetype.read()
deckstring += decktype + "\">\n<thead>\n <tr>\n <th colspan=\"5\">" + deck + " ["
deckstring += str(len(deckcards(deck))) + "/20]</th>\n </tr>\n</thead>\n<tbody>\n"
deckstring += decktype + "\">\n<thead>\n <tr>\n <th colspan=\"5\">" + deck
if deckmastered(deck):
deckstring += " [" + datemastered(deck).strftime("%Y-%m-%d") + "]"
else:
deckstring += " [" + str(len(deckcards(deck))) + "/20]"
deckstring += "</th>\n </tr>\n</thead>\n<tbody>\n"
test = 1
while test < 21:
if test % 5 == 1:

@ -30,12 +30,13 @@ def tradegen(colour=False):
else:
content.write(tcgcore.printcard(card))
else:
if not tcgcore.collecting(card[:-2]):
if colour:
if tcgcore.cardtype(card) == colour:
if not tcgcore.deckmastered(card[:-2]):
if not tcgcore.collecting(card[:-2]):
if colour:
if tcgcore.cardtype(card) == colour:
content.write(tcgcore.printcard(card))
else:
content.write(tcgcore.printcard(card))
else:
content.write(tcgcore.printcard(card))
previouscard = card
siglist = []
for card in tcgcore.ownedcards():

@ -10,3 +10,4 @@ british = True
collectthreshold = 2
keepsig = False
tradestatement = ""
maxmastered = 20

Loading…
Cancel
Save