You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
8.4 KiB
Python

import datetime,os,re
import log,skel,variables,tcgcore
3 weeks ago
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("<a href=\"/levels\"><img src=\"/assets/levels/" + rankcode + ".gif\"></a>" + tcgcore.printcard("sig_" + variables.name.lower()) + "\n<ul>\n<li>player name: " + variables.name + "</li>\n<li>" + str(len(tcgcore.ownedcards())) + " cards held (" + rank + ")</li>\n<li>started <code>" + firstdate.strftime("%Y-%m-%d") + "</code></li>\n<li>last updated <code>" + datetime.datetime.today().strftime("%Y-%m-%d") + "</code></li>\n<li><a href=\"https://git.praze.net/tre/tcg\">code</a> under construction</li>\n</ul>\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("<table id=\"crayontable\">\n<tbody>\n<tr>\n")
if crayred > 0:
content.write("<td><img src=\"/assets/crayons/crayon1.gif\" class=\"crayon\" title=\"red\"> × " + str(crayred) + "</td>\n")
if crayorange > 0:
content.write("<td><img src=\"/assets/crayons/crayon2.gif\" class=\"crayon\" title=\"orange\"> × " + str(crayorange) + "</td>\n")
if crayyellow > 0:
content.write("<td><img src=\"/assets/crayons/crayon3.gif\" class=\"crayon\" title=\"yellow\"> × " + str(crayyellow) + "</td>\n")
if craygreen > 0:
content.write("<td><img src=\"/assets/crayons/crayon4.gif\" class=\"crayon\" title=\"green\"> × " + str(craygreen) + "</td>\n")
if crayblue > 0:
content.write("<td><img src=\"/assets/crayons/crayon5.gif\" class=\"crayon\" title=\"blue\"> × " + str(crayblue) + "</td>\n")
if craypurple > 0:
content.write("<td><img src=\"/assets/crayons/crayon6.gif\" class=\"crayon\" title=\"purple\"> × " + str(craypurple) + "</td>\n")
if craybrown > 0:
content.write("<td><img src=\"/assets/crayons/crayon7.gif\" class=\"crayon\" title=\"brown\"> × " + str(craybrown) + "</td>\n")
if craygrey > 0:
content.write("<td><img src=\"/assets/crayons/crayon8.gif\" class=\"crayon\" title=\"")
if variables.british:
content.write("grey")
else:
content.write("gray")
content.write("\"> × " + str(craygrey) + "</td>\n")
content.write("</tr>\n</tbody>\n</table>\n")
3 weeks ago
sigs = []
for card in tcgcore.ownedcards():
if card[0:4] == "sig_":
sigs.append(card)
if len(sigs) > 0:
content.write("<h2>signatures</h2>\n<p>")
for card in sigs:
content.write(tcgcore.printcard(card))
content.write("</p>\n")
if len(variables.faves) > 0:
content.write("<h2>faves</h2>\n<p>")
for card in variables.faves:
content.write(tcgcore.printcard(card))
3 weeks ago
content.write("</p>\n")
3 weeks ago
content.close()
skel.footerwrite(thefile)
if __name__ == "__main__":
indexgen()