import log,variables typelist = ["red","orange","yellow","green","blue","purple","brown","gray","special"] def ownedcards(): ownedcards = [] for event in log.log: try: for card in event["received"]: ownedcards.append(card) except: pass try: for card in event["lost"]: ownedcards.remove(card) except: pass return sorted(ownedcards) def deckcards(deck): deckcards = [] for card in ownedcards(): if card[:-2] == deck: deckcards.append(int(card[-2:])) deckcards = sorted(list(dict.fromkeys(deckcards))) return deckcards def deckmastered(deck): if len(deckcards(deck)) == 20: return True else: return False def datemastered(deck): if deckmastered(deck): deckdates = [] for event in log.log: try: if event["received"]: for card in event["received"]: if card[:-2] == deck: deckdates.append({"card":card,"date":event["date"],"event":"received"}) except: pass try: if event["lost"]: for card in event["lost"]: if card[:-2] == deck: deckdates.append({"card":card,"date":event["date"],"event":"lost"}) except: pass cards = {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0} mastered = False for event in deckdates: if not mastered: if event["event"] == "received": cards[int(event["card"][-2:])] += 1 if event["event"] == "lost": cards[int(event["card"][-2:])] -= 1 if cards[1] > 0 and cards[2] > 0 and cards[3] > 0 and cards[4] > 0 and cards[5] > 0 and cards[6] > 0 and cards[7] > 0 and cards[8] > 0 and cards[9] > 0 and cards[10] > 0 and cards[11] > 0 and cards[12] > 0 and cards[13] > 0 and cards[14] > 0 and cards[15] > 0 and cards[16] > 0 and cards[17] > 0 and cards[18] > 0 and cards[19] > 0 and cards[20] > 0: mastered = event["date"] return mastered medium = [] for series in variables.masscollect: try: for deck in variables.masscollect[series]["decks"]: medium.append(deck) except: pass medium = sorted(list(dict.fromkeys(medium))) def collecting(deck): if 0 < len (deckcards(deck)) < 20: if deck in variables.highpriority: return True else: portfoliocollecting = False for event in log.log: if portfoliocollecting == False: if event["event"] == "portfolio": if deck in event["decks"]: portfoliocollecting = True return True if portfoliocollecting == False: if deck in medium: return True else: if len(deckcards(deck)) < variables.collectthreshold: return False else: return True else: return False def priority(deck): if collecting(deck): if deck in variables.highpriority: return "high" elif len(deckcards(deck)) >= variables.highthreshold: return "high" else: portfoliopriority = False for event in log.log: if portfoliopriority == False: if event["event"] == "portfolio": if deck in event["decks"]: portfoliopriority = True return "high" if portfoliopriority == False: if deck in medium: return "medium" elif 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() return(cardtype) def cardtext(card): cardtext = "" if card[0:4] == "sig_": cardtext += "" + card + "" else: if cardtype(card) == "red": cardtext += "🔴" elif cardtype(card) == "orange": cardtext += "🟠" elif cardtype(card) == "yellow": cardtext += "🟡" elif cardtype(card) == "green": cardtext += "🟢" elif cardtype(card) == "blue": cardtext += "🔵" elif cardtype(card) == "purple": cardtext += "🟣" elif cardtype(card) == "brown": cardtext += "🟤" elif cardtype(card) == "gray": cardtext += "" elif cardtype(card) == "special": cardtext += "" cardtext += card + "" return cardtext def printcard(card): if card[0:4] == "sig_": return "" else: deck = card[:-2] cardid = card[-2:] return "" def printdeck(deck,fold=True): if fold: deckstring = "
\n" + deck + " [" if deckmastered(deck): deckstring += datemastered(deck).strftime("%Y-%m-%d") else: deckstring += str(len(deckcards(deck))) + "/20" deckstring += "]\n" else: deckstring = "" deckstring += "\n" if not fold: deckstring += "\n \n \n \n\n" deckstring += "\n" test = 1 while test < 21: if test % 5 == 1: deckstring += " \n" deckstring += " \n" if test % 5 == 0: deckstring += " \n" test += 1 if deckmastered(deck): deckstring += " \n \n" deckstring += "\n
" + deck + " [" if deckmastered(deck): deckstring += datemastered(deck).strftime("%Y-%m-%d") else: deckstring += str(len(deckcards(deck))) + "/20" deckstring += "]
" if test in deckcards(deck): if test > 9: deckstring += printcard(deck + str(test)) else: deckstring += printcard(deck + "0" + str(test)) else: deckstring += "" deckstring += "
\n
\n" if fold: deckstring += "
\n" return deckstring def filterwrite(page,colour=False,sigs=False): filterstring = "

" if colour: filterstring += "Filtered to " if colour == "gray": if variables.british: filterstring += "grey" else: filterstring += "gray" else: filterstring += colour filterstring += ". Show all" else: filterstring += "Filter: 🔴 🟠 🟡 🟢 🔵 🟣 🟤 " if sigs: filterstring += " " filterstring += "

\n" return filterstring def getpalettes(): palette = [] for event in log.log: if event["event"] == "portfolio": if cardtype(event["decks"][0] + "01") != cardtype(event["decks"][1] + "01"): for deck in event["decks"]: event[cardtype(deck + "01")] = deck palette.append(event) return palette def getmonochrome(): monochrome = [] for event in log.log: if event["event"] == "portfolio": if cardtype(event["decks"][0] + "01") == cardtype(event["decks"][1] + "01"): event["colour"] = cardtype(event["decks"][0] + "01") event["decks"] = sorted(event["decks"]) monochrome.append(event) return monochrome def portfoliogen(portfolio,thetype,portnumber): if thetype == "palette": portstring = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
" + variables.name.lower() + "
" try: if deckmastered(portfolio["red"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["red"] except: if deckmastered(portfolio["special"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["special"] portstring += "" try: if deckmastered(portfolio["blue"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["blue"] except: if deckmastered(portfolio["special"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["special"] portstring += "
" try: if deckmastered(portfolio["orange"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["orange"] except: if deckmastered(portfolio["special"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["special"] portstring += "" try: if deckmastered(portfolio["purple"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["purple"] except: if deckmastered(portfolio["special"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["special"] portstring += "
" try: if deckmastered(portfolio["yellow"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["yellow"] except: if deckmastered(portfolio["special"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["special"] portstring += "" try: if deckmastered(portfolio["brown"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["brown"] except: if deckmastered(portfolio["special"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["special"] portstring += "
" try: if deckmastered(portfolio["green"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["green"] except: if deckmastered(portfolio["special"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["special"] portstring += "" try: if deckmastered(portfolio["gray"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["gray"] except: if deckmastered(portfolio["special"]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["special"] portstring += "
palette portfolio " if portnumber < 10: portstring += "0" + str(portnumber) else: portstring += str(portnumber) portstring += "
\n" elif thetype == "monochrome": portstring = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
" + variables.name.lower() + "
" if deckmastered(portfolio["decks"][0]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["decks"][0] + "" if deckmastered(portfolio["decks"][4]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["decks"][4] + "
" if deckmastered(portfolio["decks"][1]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["decks"][1] + "" if deckmastered(portfolio["decks"][5]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["decks"][5] + "
" if deckmastered(portfolio["decks"][2]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["decks"][2] + "" if deckmastered(portfolio["decks"][6]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["decks"][6] + "
" if deckmastered(portfolio["decks"][3]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["decks"][3] + "" if deckmastered(portfolio["decks"][7]): portstring += "■" else: portstring += "□" portstring += " " + portfolio["decks"][7] + "
monochrome portfolio " if portnumber < 10: portstring += "0" + str(portnumber) else: portstring += str(portnumber) portstring += "
\n" return portstring