Refactor tradegen

master
trémeur 4 weeks ago
parent e7ffeb0fdd
commit 6d437dd8cc

@ -1,33 +1,11 @@
import datetime,os import datetime,os
import log,skel,tcgcore,variables import log,skel,tcgcore,variables
def tradegen(colour=False):
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)
skel.headerwrite(thefile,"trade")
content = open(thefile,"a")
content.write("<h1>available for trade</h1>\n")
content.write(tcgcore.filterwrite("trade",colour,True) + "<p class=\"tradeterms\">")
if len(variables.tradestatement) > 0:
content.write(variables.tradestatement + " ")
content.write("Trade cards <a href=\"" + variables.tradepost + "\">here</a></p>\n<p>")
tradelist = [] tradelist = []
previouscard = "" previouscard = ""
for card in tcgcore.ownedcards(): for card in tcgcore.ownedcards():
if card[0:4] != "sig_": if card[0:4] != "sig_":
if card == previouscard: if card == previouscard:
if colour:
if tcgcore.cardtype(card) == colour:
tradelist.append(card)
else:
tradelist.append(card) tradelist.append(card)
else: else:
if not tcgcore.deckmastered(card[:-2]): if not tcgcore.deckmastered(card[:-2]):
@ -40,10 +18,6 @@ def tradegen(colour=False):
except: except:
pass pass
if mass == False: if mass == False:
if colour:
if tcgcore.cardtype(card) == colour:
tradelist.append(card)
else:
tradelist.append(card) tradelist.append(card)
previouscard = card previouscard = card
siglist = [] siglist = []
@ -51,16 +25,43 @@ def tradegen(colour=False):
if card == "sig_" + variables.name.lower(): if card == "sig_" + variables.name.lower():
siglist.append(card) siglist.append(card)
if variables.keepsig == True: if variables.keepsig == True:
if len(siglist) > 0:
siglist.remove(siglist[0]) siglist.remove(siglist[0])
def tradegen(colour=False):
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)
skel.headerwrite(thefile,"trade")
content = open(thefile,"a")
content.write("<h1>available for trade</h1>\n")
content.write(tcgcore.filterwrite("trade",colour,True) + "<p class=\"tradeterms\">")
if len(variables.tradestatement) > 0:
content.write(variables.tradestatement + " ")
content.write("Trade cards <a href=\"" + variables.tradepost + "\">here</a></p>\n<p>")
thetradelist = []
if colour: if colour:
if colour == "sig": if colour == "sig":
for sig in siglist: for sig in siglist:
tradelist.append(sig) thetradelist.append(sig)
else:
for card in tradelist:
if tcgcore.cardtype(card) == colour:
thetradelist.append(card)
else: else:
for sig in siglist:
tradelist.append(sig)
content.write("<textarea readonly>" + ", ".join(tradelist) + "</textarea>\n<p>")
for card in tradelist: for card in tradelist:
thetradelist.append(card)
for sig in siglist:
thetradelist.append(sig)
content.write("<textarea readonly>" + ", ".join(thetradelist) + "</textarea>\n<p>")
for card in thetradelist:
content.write(tcgcore.printcard(card)) content.write(tcgcore.printcard(card))
content.write("</p>\n") content.write("</p>\n")
content.close() content.close()

Loading…
Cancel
Save