Attempt some refactoring

master
trémeur 2 weeks ago
parent d3e97605ac
commit bcab0d3a2a

@ -10,14 +10,14 @@ def searchgen():
wantedcards = [] wantedcards = []
ownedcollecting = [] ownedcollecting = []
for deck in decksofinterest: 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"] if tcgcore.collecting(deck):
for card in wantedlist: wantedlist = ["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20"]
combined = deck + card for card in wantedlist:
if combined in tcgcore.ownedcards(): combined = deck + card
if tcgcore.collecting(deck): if combined in tcgcore.ownedcards():
ownedcollecting.append(combined) ownedcollecting.append(combined)
else: else:
wantedcards.append(combined) wantedcards.append(combined)
hpw = [] hpw = []
mpw = [] mpw = []
lpw = [] lpw = []
@ -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"

@ -13,25 +13,23 @@ def wantedgen():
decksofinterest = [] decksofinterest = []
for card in tcgcore.ownedcards(): for card in tcgcore.ownedcards():
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 = []
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 = [] highpriority = []
medpriority = [] medpriority = []
lowpriority = [] lowpriority = []
for card in wantedcards: for deck in decksofinterest:
if tcgcore.priority(card[:-2]) == "high": if tcgcore.collecting(deck):
highpriority.append(card) wantedlist = ["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20"]
elif tcgcore.priority(card[:-2]) == "medium": for card in wantedlist:
medpriority.append(card) combined = deck + card
elif tcgcore.priority(card[:-2]) == "low": if combined not in tcgcore.ownedcards():
lowpriority.append(card) 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: 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