From bb33cc084d76847bae5afe012adf844f117671ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Wed, 18 Dec 2024 00:33:55 +0000 Subject: [PATCH] Make it possible to include single cards in mass collects --- README.org | 2 +- massgen.py | 25 +++++++++++++++++++++---- searchgen.py | 21 ++++++++++++++++----- tcgcore.py | 7 +++++-- tradegen.py | 16 ++++++++++++---- variables-template.py | 2 +- 6 files changed, 56 insertions(+), 17 deletions(-) diff --git a/README.org b/README.org index 10fe483..543bdee 100644 --- a/README.org +++ b/README.org @@ -32,7 +32,7 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards - =maxmastered=: maximum number of most recently mastered decks to show on the index page - =ownedpage=: =True= if you want a page displaying your entire collection, =False= otherwise - =firstmasteries=: a list of decks you mastered first - - =masscollect=: list (python dict) of series/themes being mass collected and which decks to include in each one + - =masscollect=: list (python dict) of series/themes being mass collected, each containing a dict which contains at least one of ="decks"= specifying a list of decks, or ="singles"= specifying a list of individual cards - Run the following: #+BEGIN_SRC bash python3 setup.py diff --git a/massgen.py b/massgen.py index 8471f8c..86d5b78 100644 --- a/massgen.py +++ b/massgen.py @@ -6,8 +6,16 @@ massowned = {} for series in massdecks: ownedlist = [] for card in tcgcore.ownedcards(): - if card[:-2] in massdecks[series]: - ownedlist.append(card) + try: + if card[:-2] in massdecks[series]["decks"]: + ownedlist.append(card) + except: + pass + try: + if card in massdecks[series]["singles"]: + ownedlist.append(card) + except: + pass if len(ownedlist) > 0: ownedlist = sorted(list(dict.fromkeys(ownedlist))) massowned[series] = ownedlist @@ -23,11 +31,20 @@ def massindexgen(): content.write("

mass collecting

\n\n") diff --git a/searchgen.py b/searchgen.py index 85a432c..9755aac 100644 --- a/searchgen.py +++ b/searchgen.py @@ -38,13 +38,24 @@ def searchgen(): lpt.append(card) else: if not tcgcore.deckmastered(card[:-2]): - if card in ownedcollecting: - if tcgcore.priority(card[:-2]) == "medium": + mass = False + for series in variables.masscollect: + try: + if card in variables.masscollect[series]["singles"]: + mass = True + except: + pass + if mass == True: + if tcgcore.priority(card[:-2]) != "high": hpt.append(card) - elif tcgcore.priority(card[:-2]) == "low": - mpt.append(card) else: - lpt.append(card) + if card in ownedcollecting: + if tcgcore.priority(card[:-2]) == "medium": + hpt.append(card) + elif tcgcore.priority(card[:-2]) == "low": + mpt.append(card) + else: + lpt.append(card) previouscard = card hpw = sorted(list(dict.fromkeys(hpw))) mpw = sorted(list(dict.fromkeys(mpw))) diff --git a/tcgcore.py b/tcgcore.py index fb408a4..ac4314b 100644 --- a/tcgcore.py +++ b/tcgcore.py @@ -63,8 +63,11 @@ def datemastered(deck): medium = [] for series in variables.masscollect: - for deck in variables.masscollect[series]: - medium.append(deck) + try: + for deck in variables.masscollect[series]["decks"]: + medium.append(deck) + except: + pass medium = sorted(list(dict.fromkeys(medium))) def collecting(deck): diff --git a/tradegen.py b/tradegen.py index a2fd7ea..91c1396 100644 --- a/tradegen.py +++ b/tradegen.py @@ -32,11 +32,19 @@ def tradegen(colour=False): else: if not tcgcore.deckmastered(card[:-2]): if not tcgcore.collecting(card[:-2]): - if colour: - if tcgcore.cardtype(card) == colour: + mass = False + for series in variables.masscollect: + try: + if card in variables.masscollect[series]["singles"]: + mass = True + except: + pass + if mass == False: + if colour: + if tcgcore.cardtype(card) == colour: + tradelist.append(card) + else: tradelist.append(card) - else: - tradelist.append(card) previouscard = card siglist = [] for card in tcgcore.ownedcards(): diff --git a/variables-template.py b/variables-template.py index af4377d..af1ec3f 100644 --- a/variables-template.py +++ b/variables-template.py @@ -14,4 +14,4 @@ tradestatement = "" maxmastered = 20 ownedpage = False firstmasteries = ["deckname","nameofdeck"] -masscollect = {"series":["firstdeck","seconddeck"]} +masscollect = {"series":{"decks":["firstdeck","seconddeck"],"singles":["card01","card02"]}}