From c1d73d661fe3f3c2a410e2fec50cba5b5071ede0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Wed, 13 Nov 2024 19:17:24 +0000 Subject: [PATCH] Add thresholds for medium and high priority --- README.org | 2 ++ collectinggen.py | 4 ++-- searchgen.py | 14 ++++++-------- tcgcore.py | 16 ++++++++++++++++ variables-template.py | 2 ++ wantedgen.py | 9 ++++----- 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/README.org b/README.org index 77a723a..2519d7f 100644 --- a/README.org +++ b/README.org @@ -26,6 +26,8 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards - =headerbackground=: an HTML colour to display behind your header image and set as a theme colour - =british=: =True= if you want “grey” to display on the site, =False= if you want “gray” - =collectthreshold=: minimum number of owned cards for putting a deck in the “collecting” category + - =mediumthreshold=: minimum number of owned cards for marking a deck as medium priority + - =highthreshold=: minimum number of owned cards for marking a deck as high priority - =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 diff --git a/collectinggen.py b/collectinggen.py index 8dbda25..89dd98e 100644 --- a/collectinggen.py +++ b/collectinggen.py @@ -29,9 +29,9 @@ def collectinggen(colour=False): lowpriority = [] for deck in decksofinterest: if tcgcore.collecting(deck): - if deck in variables.highpriority: + if tcgcore.priority(deck) == "high": highpriority.append(deck) - elif deck in variables.medpriority: + elif tcgcore.priority(deck) == "medium": medpriority.append(deck) else: lowpriority.append(deck) diff --git a/searchgen.py b/searchgen.py index 0d78207..299b459 100644 --- a/searchgen.py +++ b/searchgen.py @@ -25,13 +25,12 @@ def searchgen(): mpt = [] lpt = [] for card in wantedcards: - if card[:-2] in variables.highpriority: + if tcgcore.priority(card[:-2]) == "high": hpw.append(card) - elif card[:-2] in variables.medpriority: + elif tcgcore.priority(card[:-2]) == "medium": mpw.append(card) - else: - if tcgcore.collecting(card[:-2]): - lpw.append(card) + elif tcgcore.priority(card[:-2]) == "low": + lpw.append(card) previouscard = "" for card in tcgcore.ownedcards(): if card[0:4] != "sig_": @@ -40,10 +39,9 @@ def searchgen(): else: if not tcgcore.deckmastered(card[:-2]): if card in ownedcollecting: - if card[:-2] in variables.medpriority: + if tcgcore.priority(card[:-2]) == "medium": hpt.append(card) - else: - if card[:-2] not in variables.highpriority: + elif tcgcore.priority(card[:-2]) == "low": mpt.append(card) else: lpt.append(card) diff --git a/tcgcore.py b/tcgcore.py index 6b75d7e..c2ba491 100644 --- a/tcgcore.py +++ b/tcgcore.py @@ -76,6 +76,22 @@ def collecting(deck): else: return False +def priority(deck): + if collecting(deck): + if deck in variables.highpriority: + return "high" + else: + if len(deckcards(deck)) >= variables.highthreshold: + return "high" + else: + if deck in variables.medpriority: + return "medium" + else: + if len(deckcards(deck)) >= variables.mediumthreshold: + return "medium" + else: + return ("low") + def cardtype(card): with open("build/decks/" + card[:-2] + "/type") as thetype: cardtype = thetype.read() diff --git a/variables-template.py b/variables-template.py index d442cee..0e81306 100644 --- a/variables-template.py +++ b/variables-template.py @@ -8,6 +8,8 @@ faves = ["favecard01","favecard02"] headerbackground = "#000000" british = True collectthreshold = 2 +mediumthreshold = 5 +highthreshold = 10 keepsig = False tradestatement = "" maxmastered = 20 diff --git a/wantedgen.py b/wantedgen.py index e56a295..a93e133 100644 --- a/wantedgen.py +++ b/wantedgen.py @@ -26,13 +26,12 @@ def wantedgen(): medpriority = [] lowpriority = [] for card in wantedcards: - if card[:-2] in variables.highpriority: + if tcgcore.priority(card[:-2]) == "high": highpriority.append(card) - elif card[:-2] in variables.medpriority: + elif tcgcore.priority(card[:-2]) == "medium": medpriority.append(card) - else: - if tcgcore.collecting(card[:-2]): - lowpriority.append(card) + elif tcgcore.priority(card[:-2]) == "low": + lowpriority.append(card) if len(highpriority) > 0: content.write("

High priority: ") for card in highpriority: