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.
378 lines
14 KiB
Python
378 lines
14 KiB
Python
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
|
|
|
|
def collecting(deck):
|
|
if len (deckcards(deck)) < 20:
|
|
if deck in variables.highpriority:
|
|
return True
|
|
else:
|
|
if deck in variables.medpriority:
|
|
return True
|
|
else:
|
|
if len(deckcards(deck)) < variables.collectthreshold:
|
|
return False
|
|
else:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
def cardtype(card):
|
|
with open("build/decks/" + card[:-2] + "/type") as thetype:
|
|
cardtype = thetype.read()
|
|
return(cardtype)
|
|
|
|
def cardtext(card):
|
|
cardtext = "<span class=\"cardname\">"
|
|
if card[0:4] == "sig_":
|
|
cardtext += "<span title=\"signature\">✍</span>" + card + "</span>"
|
|
else:
|
|
if cardtype(card) == "red":
|
|
cardtext += "<span title=\"red\">🔴</span>"
|
|
elif cardtype(card) == "orange":
|
|
cardtext += "<span title=\"orange\">🟠</span>"
|
|
elif cardtype(card) == "yellow":
|
|
cardtext += "<span title=\"yellow\">🟡</span>"
|
|
elif cardtype(card) == "green":
|
|
cardtext += "<span title=\"green\">🟢</span>"
|
|
elif cardtype(card) == "blue":
|
|
cardtext += "<span title=\"blue\">🔵</span>"
|
|
elif cardtype(card) == "purple":
|
|
cardtext += "<span title=\"purple\">🟣</span>"
|
|
elif cardtype(card) == "brown":
|
|
cardtext += "<span title=\"brown\">🟤</span>"
|
|
elif cardtype(card) == "gray":
|
|
cardtext += "<span title=\""
|
|
if variables.british:
|
|
cardtext += "grey"
|
|
else:
|
|
cardtext += "gray"
|
|
cardtext += "\">⚪</span>"
|
|
elif cardtype(card) == "special":
|
|
cardtext += "<span title=\"special\">✨</span>"
|
|
cardtext += card + "</span>"
|
|
return cardtext
|
|
|
|
def printcard(card):
|
|
if card[0:4] == "sig_":
|
|
return "<img src=\"/decks/sigs/" + card[4:] + ".gif\" title=\"" + card + "\" loading=\"lazy\">"
|
|
else:
|
|
deck = card[:-2]
|
|
cardid = card[-2:]
|
|
return "<img src=\"/decks/" + deck + "/" + cardid + ".gif\" title=\"" + card + "\" loading=\"lazy\">"
|
|
|
|
def printdeck(deck,fold=True):
|
|
if fold:
|
|
deckstring = "<details class=\"deckwrap\">\n<summary>" + deck + " ["
|
|
if deckmastered(deck):
|
|
deckstring += datemastered(deck).strftime("%Y-%m-%d")
|
|
else:
|
|
deckstring += str(len(deckcards(deck))) + "/20"
|
|
deckstring += "]</summary>\n"
|
|
else:
|
|
deckstring = ""
|
|
deckstring += "<table class=\"decktable "
|
|
with open("build/decks/" + deck + "/type") as thetype:
|
|
decktype = thetype.read()
|
|
deckstring += decktype + "\">\n"
|
|
if not fold:
|
|
deckstring += "<thead>\n <tr>\n <th colspan=\"5\">" + deck + " ["
|
|
if deckmastered(deck):
|
|
deckstring += datemastered(deck).strftime("%Y-%m-%d")
|
|
else:
|
|
deckstring += str(len(deckcards(deck))) + "/20"
|
|
deckstring += "]</th>\n </tr>\n</thead>\n"
|
|
deckstring += "<tbody>\n"
|
|
test = 1
|
|
while test < 21:
|
|
if test % 5 == 1:
|
|
deckstring += " <tr>\n"
|
|
deckstring += " <td>"
|
|
if test in deckcards(deck):
|
|
if test > 9:
|
|
deckstring += printcard(deck + str(test))
|
|
else:
|
|
deckstring += printcard(deck + "0" + str(test))
|
|
else:
|
|
deckstring += "<img src=\"/decks/" + deck + "/00.gif\" loading=\"lazy\">"
|
|
deckstring += "</td>\n"
|
|
if test % 5 == 0:
|
|
deckstring += " </tr>\n"
|
|
test += 1
|
|
if deckmastered(deck):
|
|
deckstring += " <tr>\n <td colspan=\"5\" align=\"center\"><img src=\"/decks/" + deck + "/master.gif\" title=\"mastered " + deck + "\"><td>\n</tr>\n"
|
|
deckstring += "</tbody>\n</table>\n"
|
|
if fold:
|
|
deckstring += "</details>\n"
|
|
return deckstring
|
|
|
|
def filterwrite(page,colour=False,sigs=False):
|
|
filterstring = "<p class=\"typefilter\">"
|
|
if colour:
|
|
filterstring += "Filtered to <b>"
|
|
if colour == "gray":
|
|
if variables.british:
|
|
filterstring += "grey"
|
|
else:
|
|
filterstring += "gray"
|
|
else:
|
|
filterstring += colour
|
|
filterstring += "</b>. <a href=\"/" + page + "\">Show all</a>"
|
|
else:
|
|
filterstring += "Filter: <a href=\"/" + page + "/red\" title=\"red\">🔴</a> <a href=\"/" + page + "/orange\" title=\"orange\">🟠</a> <a href=\"/" + page + "/yellow\" title=\"yellow\">🟡</a> <a href=\"/" + page + "/green\" title=\"green\">🟢</a> <a href=\"/" + page + "/blue\" title=\"blue\">🔵</a> <a href=\"/" + page + "/purple\" title=\"purple\">🟣</a> <a href=\"/" + page + "/brown\" title=\"brown\">🟤</a> <a href=\"/" + page + "/gray\" title=\""
|
|
if variables.british:
|
|
filterstring += "grey"
|
|
else:
|
|
filterstring += "gray"
|
|
filterstring += "\">⚪</a> <a href=\"/" + page + "/special\" title=\"special\">✨</a>"
|
|
if sigs:
|
|
filterstring += " <a href=\"/" + page + "/sig\" title=\"sig\">✍</a>"
|
|
filterstring += "</p>\n"
|
|
return filterstring
|
|
|
|
def getpalettes():
|
|
palette = []
|
|
if len(variables.portfolios) > 0:
|
|
for portfolio in variables.portfolios:
|
|
if portfolio["type"] == "palette":
|
|
thepalette = {}
|
|
for deck in portfolio["decks"]:
|
|
thepalette[cardtype(deck + "01")] = deck
|
|
palette.append(thepalette)
|
|
return palette
|
|
|
|
def getmonochrome():
|
|
monochrome = []
|
|
if len(variables.portfolios) > 0:
|
|
for portfolio in variables.portfolios:
|
|
if portfolio["type"] == "monochrome":
|
|
themonochrome = {}
|
|
colourdecks = []
|
|
for deck in portfolio["decks"]:
|
|
colourdecks.append(deck)
|
|
colourdecks = sorted(colourdecks)
|
|
themonochrome["colour"] = cardtype(colourdecks[0] + "01")
|
|
themonochrome["decks"] = colourdecks
|
|
monochrome.append(themonochrome)
|
|
return monochrome
|
|
|
|
def portfoliogen(portfolio,thetype,portnumber):
|
|
if thetype == "palette":
|
|
portstring = "<table class=\"palette portfolio\">\n<tbody>\n<tr>\n<td colspan=\"2\">" + variables.name.lower() + "</td>\n</tr>\n<tr>\n<td class=\"deck1\">"
|
|
try:
|
|
if deckmastered(portfolio["red"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["red"]
|
|
except:
|
|
if deckmastered(portfolio["special"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["special"]
|
|
portstring += "</td>\n<td class=\"deck5\">"
|
|
try:
|
|
if deckmastered(portfolio["blue"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["blue"]
|
|
except:
|
|
if deckmastered(portfolio["special"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["special"]
|
|
portstring += "</td>\n</tr>\n<tr>\n<td class=\"deck2\">"
|
|
try:
|
|
if deckmastered(portfolio["orange"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["orange"]
|
|
except:
|
|
if deckmastered(portfolio["special"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["special"]
|
|
portstring += "</td>\n<td class=\"deck6\">"
|
|
try:
|
|
if deckmastered(portfolio["purple"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["purple"]
|
|
except:
|
|
if deckmastered(portfolio["special"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["special"]
|
|
portstring += "</td>\n</tr>\n<tr>\n<td class=\"deck3\">"
|
|
try:
|
|
if deckmastered(portfolio["yellow"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["yellow"]
|
|
except:
|
|
if deckmastered(portfolio["special"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["special"]
|
|
portstring += "</td>\n<td class=\"deck7\">"
|
|
try:
|
|
if deckmastered(portfolio["brown"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["brown"]
|
|
except:
|
|
if deckmastered(portfolio["special"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["special"]
|
|
portstring += "</td>\n</tr>\n<tr>\n<td class=\"deck4\">"
|
|
try:
|
|
if deckmastered(portfolio["green"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["green"]
|
|
except:
|
|
if deckmastered(portfolio["special"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["special"]
|
|
portstring += "</td>\n<td class=\"deck8\">"
|
|
try:
|
|
if deckmastered(portfolio["gray"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["gray"]
|
|
except:
|
|
if deckmastered(portfolio["special"]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["special"]
|
|
portstring += "</td>\n</tr>\n<tr>\n<td colspan=\"2\">palette portfolio "
|
|
if portnumber < 10:
|
|
portstring += "0" + str(portnumber)
|
|
else:
|
|
portstring += str(portnumber)
|
|
portstring += "</td>\n</tr>\n</tbody>\n</table>\n"
|
|
elif thetype == "monochrome":
|
|
portstring = "<table class=\"" + portfolio["colour"] + " portfolio\">\n<tbody>\n<tr>\n<td colspan=\"2\">" + variables.name.lower() + "</td>\n</tr>\n<tr>\n<td class=\"deck1\">"
|
|
if deckmastered(portfolio["decks"][0]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["decks"][0] + "</td>\n<td class=\"deck5\">"
|
|
if deckmastered(portfolio["decks"][4]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["decks"][4] + "</td>\n</tr>\n<tr>\n<td class=\"deck2\">"
|
|
if deckmastered(portfolio["decks"][1]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["decks"][1] + "</td>\n<td class=\"deck6\">"
|
|
if deckmastered(portfolio["decks"][5]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["decks"][5] + "</td>\n</tr>\n<tr>\n<td class=\"deck3\">"
|
|
if deckmastered(portfolio["decks"][2]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["decks"][2] + "</td>\n<td class=\"deck7\">"
|
|
if deckmastered(portfolio["decks"][6]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["decks"][6] + "</td>\n</tr>\n<tr>\n<td class=\"deck4\">"
|
|
if deckmastered(portfolio["decks"][3]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["decks"][3] + "</td>\n<td class=\"deck8\">"
|
|
if deckmastered(portfolio["decks"][7]):
|
|
portstring += "■"
|
|
else:
|
|
portstring += "□"
|
|
portstring += " " + portfolio["decks"][7] + "</td>\n</tr>\n<tr>\n<td colspan=\"2\">monochrome portfolio "
|
|
if portnumber < 10:
|
|
portstring += "0" + str(portnumber)
|
|
else:
|
|
portstring += str(portnumber)
|
|
portstring += "</td>\n</tr>\n</tbody>\n</table>\n"
|
|
return portstring
|