Add trading page

master
trémeur 2 months ago
parent 18422d8b4f
commit fc81853bc1

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

@ -2,7 +2,7 @@ import variables
def headerwrite(thefile,pagename):
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":
header.write("home")
else:
@ -18,6 +18,11 @@ def headerwrite(thefile,pagename):
else:
header.write("<a href=\"/owned\">owned</a>")
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":
header.write("wanted")
else:

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

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

Loading…
Cancel
Save