Attempt some refactoring

master
trémeur 2 weeks ago
parent d3e97605ac
commit bcab0d3a2a

@ -10,11 +10,11 @@ def searchgen():
wantedcards = [] wantedcards = []
ownedcollecting = [] ownedcollecting = []
for deck in decksofinterest: 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"] 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: for card in wantedlist:
combined = deck + card combined = deck + card
if combined in tcgcore.ownedcards(): if combined in tcgcore.ownedcards():
if tcgcore.collecting(deck):
ownedcollecting.append(combined) ownedcollecting.append(combined)
else: else:
wantedcards.append(combined) wantedcards.append(combined)
@ -46,6 +46,12 @@ def searchgen():
else: else:
lpt.append(card) lpt.append(card)
previouscard = 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"): if not os.path.isdir("build/search"):
os.mkdir("build/search") os.mkdir("build/search")
thefile = "build/search/index.html" thefile = "build/search/index.html"

@ -15,23 +15,21 @@ def wantedgen():
if card[0:4] != "sig_": if card[0:4] != "sig_":
decksofinterest.append(card[:-2]) decksofinterest.append(card[:-2])
decksofinterest = sorted(list(dict.fromkeys(decksofinterest))) decksofinterest = sorted(list(dict.fromkeys(decksofinterest)))
wantedcards = [] highpriority = []
medpriority = []
lowpriority = []
for deck in decksofinterest: 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"] 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: for card in wantedlist:
combined = deck + card combined = deck + card
if combined not in tcgcore.ownedcards(): if combined not in tcgcore.ownedcards():
wantedcards.append(combined) if tcgcore.priority(deck) == "high":
highpriority = [] highpriority.append(combined)
medpriority = [] elif tcgcore.priority(deck) == "medium":
lowpriority = [] medpriority.append(combined)
for card in wantedcards: elif tcgcore.priority(deck) == "low":
if tcgcore.priority(card[:-2]) == "high": lowpriority.append(combined)
highpriority.append(card)
elif tcgcore.priority(card[:-2]) == "medium":
medpriority.append(card)
elif tcgcore.priority(card[:-2]) == "low":
lowpriority.append(card)
if len(highpriority) > 0: if len(highpriority) > 0:
content.write("<h2>High priority</h2>\n<textarea readonly>" + ", ".join(highpriority) + "</textarea>\n<p>") content.write("<h2>High priority</h2>\n<textarea readonly>" + ", ".join(highpriority) + "</textarea>\n<p>")
for card in highpriority: for card in highpriority:

Loading…
Cancel
Save