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.

69 lines
2.3 KiB
Python

3 weeks ago
import datetime,os
import log,skel,tcgcore,variables
3 weeks ago
def tradegen(colour=False):
3 weeks ago
if not os.path.isdir("build/trade"):
os.mkdir("build/trade")
if colour:
if not os.path.isdir("build/trade/" + colour):
os.mkdir("build/trade/" + colour)
thefile = "build/trade/" + colour + "/index.html"
else:
thefile = "build/trade/index.html"
if os.path.exists(thefile):
os.remove(thefile)
3 weeks ago
skel.headerwrite(thefile,"trade")
content = open(thefile,"a")
content.write("<h1>available for trade</h1>\n")
content.write(tcgcore.filterwrite("trade",colour,True))
if len(variables.tradestatement) > 0:
content.write(variables.tradestatement + " ")
content.write("Trade cards <a href=\"" + variables.tradepost + "\">here</a></p>\n<p>")
tradelist = []
previouscard = ""
3 weeks ago
for card in tcgcore.ownedcards():
if card[0:4] != "sig_":
if card == previouscard:
if colour:
if tcgcore.cardtype(card) == colour:
tradelist.append(card)
else:
tradelist.append(card)
else:
if not tcgcore.deckmastered(card[:-2]):
if not tcgcore.collecting(card[:-2]):
if colour:
if tcgcore.cardtype(card) == colour:
tradelist.append(card)
else:
tradelist.append(card)
previouscard = card
siglist = []
for card in tcgcore.ownedcards():
if card == "sig_" + variables.name.lower():
siglist.append(card)
if variables.keepsig == True:
siglist.remove(siglist[0])
if colour:
if colour == "sig":
for sig in siglist:
tradelist.append(sig)
else:
for sig in siglist:
tradelist.append(sig)
content.write("<textarea readonly>" + ", ".join(tradelist) + "</textarea>\n<p>")
for card in tradelist:
content.write(tcgcore.printcard(card))
content.write("</p>\n")
3 weeks ago
content.close()
skel.footerwrite(thefile)
def tradeall():
3 weeks ago
tradegen()
for type in tcgcore.typelist:
tradegen(type)
tradegen("sig")
if __name__ == "__main__":
tradeall()