import datetime,os,re from collections import Counter import log,skel,variables,tcgcore def indexgen(): if os.path.exists("build/index.html"): os.remove("build/index.html") thefile = "build/index.html" skel.headerwrite(thefile,"index") content = open(thefile,"a") firstdate = log.log[0]["date"] if len(tcgcore.ownedcards()) > 14400: rankcode = "rainbow" extra = len(tcgcore.ownedcards()) - 14400 plusranks = int(extra / 300) if plusranks > 0: rank = "rainbow + " + str(plusranks) else: rank = "rainbow" else: if len(tcgcore.ownedcards()) > 14100: rank = "himalayan" elif len(tcgcore.ownedcards()) > 13800: rank = "puma" elif len(tcgcore.ownedcards()) > 13500: rank = "chartreux" elif len(tcgcore.ownedcards()) > 13500: rank = "russian blue" elif len(tcgcore.ownedcards()) > 12900: rank = "panther" elif len(tcgcore.ownedcards()) > 12600: rank = "cheetah" elif len(tcgcore.ownedcards()) > 12300: rank = "tiger" elif len(tcgcore.ownedcards()) > 12000: rank = "lion" elif len(tcgcore.ownedcards()) > 11700: rank = "metal" elif len(tcgcore.ownedcards()) > 11400: rank = "ground" elif len(tcgcore.ownedcards()) > 11100: rank = "darkness" elif len(tcgcore.ownedcards()) > 10800: rank = "water" elif len(tcgcore.ownedcards()) > 10500: rank = "nature" elif len(tcgcore.ownedcards()) > 10200: rank = "light" elif len(tcgcore.ownedcards()) > 9900: rank = "wind" elif len(tcgcore.ownedcards()) > 9600: rank = "fire" elif len(tcgcore.ownedcards()) > 9300: rank = "mercury" elif len(tcgcore.ownedcards()) > 9000: rank = "jupiter" elif len(tcgcore.ownedcards()) > 8700: rank = "uranus" elif len(tcgcore.ownedcards()) > 8400: rank = "neptune" elif len(tcgcore.ownedcards()) > 8100: rank = "earth" elif len(tcgcore.ownedcards()) > 7800: rank = "venus" elif len(tcgcore.ownedcards()) > 7500: rank = "saturn" elif len(tcgcore.ownedcards()) > 7200: rank = "mars" elif len(tcgcore.ownedcards()) > 6900: rank = "magnolia" elif len(tcgcore.ownedcards()) > 6600: rank = "chocolate cosmos" elif len(tcgcore.ownedcards()) > 6300: rank = "lilac" elif len(tcgcore.ownedcards()) > 6000: rank = "hydrangea" elif len(tcgcore.ownedcards()) > 5700: rank = "clover" elif len(tcgcore.ownedcards()) > 5400: rank = "daffodil" elif len(tcgcore.ownedcards()) > 5100: rank = "tiger lily" elif len(tcgcore.ownedcards()) > 4800: rank = "sakura" elif len(tcgcore.ownedcards()) > 4500: rank = "silver" elif len(tcgcore.ownedcards()) > 4200: rank = "bronze" elif len(tcgcore.ownedcards()) > 3900: rank = "amethyst" elif len(tcgcore.ownedcards()) > 3600: rank = "sapphire" elif len(tcgcore.ownedcards()) > 3300: rank = "emerald" elif len(tcgcore.ownedcards()) > 3000: rank = "gold" elif len(tcgcore.ownedcards()) > 2700: rank = "amber" elif len(tcgcore.ownedcards()) > 2400: rank = "ruby" elif len(tcgcore.ownedcards()) > 2200: rank = "dragon fruit" elif len(tcgcore.ownedcards()) > 2000: rank = "apricot" elif len(tcgcore.ownedcards()) > 1800: rank = "grape" elif len(tcgcore.ownedcards()) > 1600: rank = "blueberry" elif len(tcgcore.ownedcards()) > 1400: rank = "lime" elif len(tcgcore.ownedcards()) > 1200: rank = "lemon" elif len(tcgcore.ownedcards()) > 1000: rank = "tangerine" elif len(tcgcore.ownedcards()) > 800: rank = "strawberry" elif len(tcgcore.ownedcards()) > 700: rank = "gray" elif len(tcgcore.ownedcards()) > 600: rank = "brown" elif len(tcgcore.ownedcards()) > 500: rank = "purple" elif len(tcgcore.ownedcards()) > 400: rank = "blue" elif len(tcgcore.ownedcards()) > 300: rank = "green" elif len(tcgcore.ownedcards()) > 200: rank = "yellow" elif len(tcgcore.ownedcards()) > 100: rank = "orange" else: rank = "red" rankcode = re.sub(" ","",rank) content.write("" + tcgcore.printcard("sig_" + variables.name.lower()) + "\n\n") crayred = 0 crayorange = 0 crayyellow = 0 craygreen = 0 crayblue = 0 craypurple = 0 craybrown = 0 craygrey = 0 for event in log.log: try: crayred += event["crayons"]["red"] except: pass try: crayorange += event["crayons"]["orange"] except: pass try: crayyellow += event["crayons"]["yellow"] except: pass try: craygreen += event["crayons"]["green"] except: pass try: crayblue += event["crayons"]["blue"] except: pass try: craypurple += event["crayons"]["purple"] except: pass try: craybrown += event["crayons"]["brown"] except: pass try: craygrey += event["crayons"]["gray"] except: pass if crayred + crayorange + crayyellow + craygreen + crayblue + craypurple + craybrown + craygrey > 0: content.write("\n\n\n") if crayred > 0: content.write("\n") if crayorange > 0: content.write("\n") if crayyellow > 0: content.write("\n") if craygreen > 0: content.write("\n") if crayblue > 0: content.write("\n") if craypurple > 0: content.write("\n") if craybrown > 0: content.write("\n") if craygrey > 0: content.write("\n") content.write("\n\n
× " + str(crayred) + " × " + str(crayorange) + " × " + str(crayyellow) + " × " + str(craygreen) + " × " + str(crayblue) + " × " + str(craypurple) + " × " + str(craybrown) + " × " + str(craygrey) + "
\n") tradeout = [] tradein = [] for event in log.log: if event["event"][0:11] == "trade with ": try: for card in event["lost"]: tradeout.append(event["event"]) except: pass try: for card in event["received"]: tradein.append(event["event"]) except: pass tradecommon = list((Counter(tradeout) & Counter(tradein)).elements()) sketch = len(tradecommon) if sketch > 0: content.write("\n\n\n\n") if sketch > 19: content.write("\n") content.write("\n\n\n") if sketch > 19: content.write("\n") content.write("\n\n
" + str(sketch % 20) + "/20" + str(int(sketch / 20)) + " completed
") if len(tcgcore.getpalettes()) + len(tcgcore.getmonochrome()) > 0: content.write("\n
\n") if len(tcgcore.getpalettes()) > 0: content.write(tcgcore.portfoliogen(tcgcore.getpalettes()[-1],"palette",len(tcgcore.getpalettes()))) if len(tcgcore.getmonochrome()) > 0: content.write(tcgcore.portfoliogen(tcgcore.getmonochrome()[-1],"monochrome",len(tcgcore.getmonochrome()))) content.write("
\n
\n") decksofinterest = [] for card in tcgcore.ownedcards(): if card[0:4] != "sig_": decksofinterest.append(card[:-2]) decksofinterest = sorted(list(dict.fromkeys(decksofinterest))) mastereddecks = [] for deck in decksofinterest: if tcgcore.deckmastered(deck): mastereddecks.append({"name":deck,"date":tcgcore.datemastered(deck)}) mastereddecks = sorted(mastereddecks,key=lambda d: d["date"],reverse=True) if len(mastereddecks) > 0: content.write("

mastered decks

\n

") masteredcount = 0 for deck in mastereddecks: if masteredcount < variables.maxmastered: content.write("") masteredcount += 1 if len(mastereddecks) > variables.maxmastered: content.write(" see all") content.write("

\n") sigs = [] for card in tcgcore.ownedcards(): if card[0:4] == "sig_": sigs.append(card) if len(sigs) > 0: content.write("

signatures

\n

") for card in sigs: content.write(tcgcore.printcard(card)) content.write("

\n") if len(variables.faves) > 0: content.write("

faves

\n

") faveslist = sorted(variables.faves) for card in faveslist: content.write(tcgcore.printcard(card)) content.write("

\n") content.close() skel.footerwrite(thefile) if __name__ == "__main__": indexgen()