From bcab0d3a2a8219a9ef3500dfb21f351a29252fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Fri, 6 Dec 2024 21:23:24 +0000 Subject: [PATCH] Attempt some refactoring --- searchgen.py | 20 +++++++++++++------- wantedgen.py | 28 +++++++++++++--------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/searchgen.py b/searchgen.py index 299b459..85a432c 100644 --- a/searchgen.py +++ b/searchgen.py @@ -10,14 +10,14 @@ def searchgen(): wantedcards = [] ownedcollecting = [] for deck in decksofinterest: - wantedlist = ["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20"] - for card in wantedlist: - combined = deck + card - if combined in tcgcore.ownedcards(): - if tcgcore.collecting(deck): + if tcgcore.collecting(deck): + wantedlist = ["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20"] + for card in wantedlist: + combined = deck + card + if combined in tcgcore.ownedcards(): ownedcollecting.append(combined) - else: - wantedcards.append(combined) + else: + wantedcards.append(combined) hpw = [] mpw = [] lpw = [] @@ -46,6 +46,12 @@ def searchgen(): else: lpt.append(card) previouscard = card + hpw = sorted(list(dict.fromkeys(hpw))) + mpw = sorted(list(dict.fromkeys(mpw))) + lpw = sorted(list(dict.fromkeys(lpw))) + hpt = sorted(list(dict.fromkeys(hpt))) + mpt = sorted(list(dict.fromkeys(mpt))) + lpt = sorted(list(dict.fromkeys(lpt))) if not os.path.isdir("build/search"): os.mkdir("build/search") thefile = "build/search/index.html" diff --git a/wantedgen.py b/wantedgen.py index 076db53..b554b96 100644 --- a/wantedgen.py +++ b/wantedgen.py @@ -13,25 +13,23 @@ def wantedgen(): decksofinterest = [] for card in tcgcore.ownedcards(): if card[0:4] != "sig_": - decksofinterest.append(card[:-2]) + decksofinterest.append(card[:-2]) decksofinterest = sorted(list(dict.fromkeys(decksofinterest))) - wantedcards = [] - for deck in decksofinterest: - wantedlist = ["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20"] - for card in wantedlist: - combined = deck + card - if combined not in tcgcore.ownedcards(): - wantedcards.append(combined) highpriority = [] medpriority = [] lowpriority = [] - for card in wantedcards: - if tcgcore.priority(card[:-2]) == "high": - highpriority.append(card) - elif tcgcore.priority(card[:-2]) == "medium": - medpriority.append(card) - elif tcgcore.priority(card[:-2]) == "low": - lowpriority.append(card) + for deck in decksofinterest: + if tcgcore.collecting(deck): + wantedlist = ["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20"] + for card in wantedlist: + combined = deck + card + if combined not in tcgcore.ownedcards(): + if tcgcore.priority(deck) == "high": + highpriority.append(combined) + elif tcgcore.priority(deck) == "medium": + medpriority.append(combined) + elif tcgcore.priority(deck) == "low": + lowpriority.append(combined) if len(highpriority) > 0: content.write("

High priority

\n\n

") for card in highpriority: