Add trading page

master
trémeur 3 weeks ago
parent 18422d8b4f
commit fc81853bc1

@ -24,7 +24,8 @@ def collectinggen():
elif deck in variables.medpriority: elif deck in variables.medpriority:
medpriority.append(deck) medpriority.append(deck)
else: else:
lowpriority.append(deck) if tcgcore.collecting(deck):
lowpriority.append(deck)
if len(highpriority) > 0: if len(highpriority) > 0:
content.write("<h2>High priority</h2>\n") content.write("<h2>High priority</h2>\n")
for deck in highpriority: for deck in highpriority:

@ -2,7 +2,7 @@ import variables
def headerwrite(thefile,pagename): def headerwrite(thefile,pagename):
header = open(thefile,"a") header = open(thefile,"a")
header.write("<!DOCTYPE html>\n<html lang=\"en\" style=\"--headbg:" + variables.headerbackground + ";\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <link rel=\"stylesheet\" href=\"/style.css\">\n <meta name=\"theme-color\" content=\"" + variables.headerbackground + "\">\n <title>" + variables.name + "s TCG collection :: " + pagename + "</title>\n </head>\n <body>\n <aside>\n \n </aside>\n <nav>\n <ul>\n <li>") header.write("<!DOCTYPE html>\n<html lang=\"en\" style=\"--headbg:" + variables.headerbackground + ";\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <link rel=\"stylesheet\" href=\"/style.css\">\n <meta name=\"theme-color\" content=\"" + variables.headerbackground + "\">\n <title>" + variables.name + "s card collection :: " + pagename + "</title>\n </head>\n <body>\n <aside>\n \n </aside>\n <nav>\n <ul>\n <li>")
if pagename == "index": if pagename == "index":
header.write("home") header.write("home")
else: else:
@ -18,6 +18,11 @@ def headerwrite(thefile,pagename):
else: else:
header.write("<a href=\"/owned\">owned</a>") header.write("<a href=\"/owned\">owned</a>")
header.write("</li>\n <li>") header.write("</li>\n <li>")
if pagename == "trade":
header.write("trading")
else:
header.write("<a href=\"/trade\">trading</a>")
header.write("</li>\n <li>")
if pagename == "wanted": if pagename == "wanted":
header.write("wanted") header.write("wanted")
else: else:

@ -15,6 +15,26 @@ def ownedcards():
pass pass
return sorted(ownedcards) 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 collecting(deck):
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
def cardtext(card): def cardtext(card):
cardtext = "<span class=\"cardname\">" cardtext = "<span class=\"cardname\">"
if card[0:4] == "sig_": if card[0:4] == "sig_":
@ -61,18 +81,13 @@ def printdeck(deck):
with open("build/decks/" + deck + "/type") as thetype: with open("build/decks/" + deck + "/type") as thetype:
decktype = thetype.read() decktype = thetype.read()
deckstring += decktype + "\">\n<thead>\n <tr>\n <th colspan=\"5\">" + deck + " [" deckstring += decktype + "\">\n<thead>\n <tr>\n <th colspan=\"5\">" + deck + " ["
deckcards = [] deckstring += str(len(deckcards(deck))) + "/20]</th>\n </tr>\n</thead>\n<tbody>\n"
for card in ownedcards():
if card[:-2] == deck:
deckcards.append(int(card[-2:]))
deckcards = sorted(list(dict.fromkeys(deckcards)))
deckstring += str(len(deckcards)) + "/20]</th>\n </tr>\n</thead>\n<tbody>\n"
test = 1 test = 1
while test < 21: while test < 21:
if test % 5 == 1: if test % 5 == 1:
deckstring += " <tr>\n" deckstring += " <tr>\n"
deckstring += " <td><img src=\"/decks/" + deck + "/" deckstring += " <td><img src=\"/decks/" + deck + "/"
if test in deckcards: if test in deckcards(deck):
if test > 9: if test > 9:
deckstring += str(test) deckstring += str(test)
else: else:

@ -0,0 +1,22 @@
import datetime,os
import log,skel,tcgcore
def tradegen():
if not os.path.isdir("build/trade"):
os.mkdir("build/trade")
if os.path.exists("build/trade/index.html"):
os.remove("build/trade/index.html")
thefile = "build/trade/index.html"
skel.headerwrite(thefile,"trade")
content = open(thefile,"a")
content.write("<h1>available for trade</h1>\n<p>")
for card in tcgcore.ownedcards():
if card[0:4] != "sig_":
if not tcgcore.collecting(card[:-2]):
content.write(tcgcore.printcard(card))
content.write("</p>\n")
content.close()
skel.footerwrite(thefile)
if __name__ == "__main__":
tradegen()

@ -5,3 +5,4 @@ tradepost = "URL"
faves = ["favecard01","favecard02"] faves = ["favecard01","favecard02"]
headerbackground = "#000000" headerbackground = "#000000"
british = True british = True
collectthreshold = 2

@ -31,7 +31,8 @@ def wantedgen():
elif card[:-2] in variables.medpriority: elif card[:-2] in variables.medpriority:
medpriority.append(card) medpriority.append(card)
else: else:
lowpriority.append(card) if tcgcore.collecting(card[:-2]):
lowpriority.append(card)
if len(highpriority) > 0: if len(highpriority) > 0:
content.write("<p><b>High priority:</b> ") content.write("<p><b>High priority:</b> ")
for card in highpriority: for card in highpriority:

Loading…
Cancel
Save