From 042d143b04b40e8b9efd72ec810b7b4ffb55d14e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Sat, 8 Mar 2025 11:00:39 +0000 Subject: [PATCH] Show mastered donated decks --- new.py | 64 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/new.py b/new.py index 030fb34..ebcc4cc 100644 --- a/new.py +++ b/new.py @@ -464,12 +464,20 @@ def footerwrite(thefile): footer.close() def printcard(card): - if card["colour"] == "sig": - return "" - else: - deck = card["name"][:-2] - cardid = card["name"][-2:] - return "" + if type(card) == dict: + if card["colour"] == "sig": + return "" + else: + deck = card["name"][:-2] + cardid = card["name"][-2:] + return "" + elif type(card) == str: + if card[0:4] == "sig_": + return "" + else: + deck = card[:-2] + cardid = card[-2:] + return "" def cardtext(card): cardtext = "" @@ -1096,10 +1104,7 @@ def indexgen(): content.write("

faves

\n

") faveslist = sorted(variables.faves) for card in faveslist: - for thecard in cardlist: - if card == thecard["name"]: - content.write(printcard(thecard)) - break + content.write(printcard(card)) content.write("

\n") if len(coupons) > 0: content.write("

coupons

\n

") @@ -1114,26 +1119,43 @@ def indexgen(): content.write("

\n") donations = [] try: - for deck in variables.donations["decks"]: - donations.append(deck + "00") + for donatedeck in variables.donations["decks"]: + donation = {} + donation["name"] = donatedeck + for deck in decklist: + if deck["name"] == donatedeck: + if deck["mastered"]: + donation["type"] = "mastered" + else: + donation["type"] = "deck" + break + donations.append(donation) except: pass try: for card in variables.donations["scrapbook"]: - donations.append(card) + donation = {} + donation["name"] = card + donation["type"] = "single" + donations.append(donation) except: pass if len(donations) > 0: - donations = sorted(donations) + donations = sorted(donations, key=lambda d: d["name"]) content.write("

donations

\n

") for donation in donations: - if donation[-2:] == "00": - content.write("") - else: - for thecard in cardlist: - if donation == thecard["name"]: - content.write(printcard(thecard)) - break + if donation["type"] == "deck": + content.write("") + elif donation["type"] == "mastered": + content.write("") + elif donation["type"] == "single": + content.write(printcard(donation["name"])) content.write("

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