Compare commits
3 commits
dcb6597851
...
bfe656a5b4
Author | SHA1 | Date | |
---|---|---|---|
bfe656a5b4 | |||
042d143b04 | |||
95b80881a5 |
4 changed files with 128 additions and 40 deletions
|
@ -46,5 +46,5 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards
|
||||||
- Add level images manually to =build/assets/levels/=
|
- Add level images manually to =build/assets/levels/=
|
||||||
- Add custom CSS to =build/user.css=
|
- Add custom CSS to =build/user.css=
|
||||||
*** Updating and building
|
*** Updating and building
|
||||||
- For each transaction, add a dictionary ={}= to the =log= list like in the example (removing any of ="received"=, ="lost"=, ="crayons"=, ="decks"=, ="coupons">= that aren’t relevant).
|
- For each transaction, add a dictionary ={}= to the =log= list like in the example (removing any of ="received"=, ="lost"=, ="crayons"=, ="decks"=, ="coupons"=, ="pend"=, ="unpend"= that aren’t relevant).
|
||||||
- Run =./build.sh= in this directory to download the relevant card images and then upload everything to the server.
|
- Run =./build.sh= in this directory to download the relevant card images and then upload everything to the server.
|
||||||
|
|
|
@ -563,7 +563,27 @@ span.searchresults {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* coupons */
|
||||||
|
|
||||||
img.coupon.expired {
|
img.coupon.expired {
|
||||||
-webkit-filter: grayscale(100%);
|
-webkit-filter: grayscale(100%);
|
||||||
filter: grayscale(100%);
|
filter: grayscale(100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pending cards */
|
||||||
|
|
||||||
|
td:has(.pending) {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
td:has(.pending) img {
|
||||||
|
filter: hue-rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
td p.pending {
|
||||||
|
position: absolute;
|
||||||
|
font-size: 10px;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -200%);
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ log = [
|
||||||
"crayons":{"red":1,"orange":2,"yellow":-3},
|
"crayons":{"red":1,"orange":2,"yellow":-3},
|
||||||
"coupons":{"01":5},
|
"coupons":{"01":5},
|
||||||
"decks":["deck1","deck2","deck3","deck4","deck5","deck6","deck7","deck8"], # only if "event":"portfolio"
|
"decks":["deck1","deck2","deck3","deck4","deck5","deck6","deck7","deck8"], # only if "event":"portfolio"
|
||||||
"sketch":-1 # for turning in 1 sketchpad
|
"sketch":-1, # for turning in 1 sketchpad
|
||||||
|
"pend":["card05"], # to mark a card as pending
|
||||||
|
"unpend":["card06"] # to remove a card from the pending list if a trade is cancelled
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
142
new.py
142
new.py
|
@ -8,7 +8,7 @@ numbers = ["01","02","03","04","05","06","07","08","09","10","11","12","13","14"
|
||||||
|
|
||||||
print("Getting list of deck colours")
|
print("Getting list of deck colours")
|
||||||
|
|
||||||
deckkey = []
|
deckkey = {}
|
||||||
|
|
||||||
request = requests.get("https://colors-tcg.eu/cards.php?view=alpha")
|
request = requests.get("https://colors-tcg.eu/cards.php?view=alpha")
|
||||||
alldecks = open("key.html","w")
|
alldecks = open("key.html","w")
|
||||||
|
@ -31,10 +31,8 @@ for row in souprows:
|
||||||
soupcells = row.find_all("td")
|
soupcells = row.find_all("td")
|
||||||
deckname = soupcells[2].text.lower().replace(" ","").replace("'","").replace("ç","c").replace(".","").replace("politetness","politeness")
|
deckname = soupcells[2].text.lower().replace(" ","").replace("'","").replace("ç","c").replace(".","").replace("politetness","politeness")
|
||||||
decktype = soupcells[3].text.lower()
|
decktype = soupcells[3].text.lower()
|
||||||
thedeck = {}
|
|
||||||
thedeck[deckname] = decktype
|
|
||||||
if decktype in values:
|
if decktype in values:
|
||||||
deckkey.append(thedeck)
|
deckkey[deckname] = decktype
|
||||||
|
|
||||||
print("Parsing log")
|
print("Parsing log")
|
||||||
|
|
||||||
|
@ -54,6 +52,7 @@ redeemedsketch = 0
|
||||||
coupons = []
|
coupons = []
|
||||||
datelist = []
|
datelist = []
|
||||||
logitems = []
|
logitems = []
|
||||||
|
pends = []
|
||||||
|
|
||||||
for event in log.log:
|
for event in log.log:
|
||||||
logentry = {}
|
logentry = {}
|
||||||
|
@ -66,10 +65,7 @@ for event in log.log:
|
||||||
thedecks = {}
|
thedecks = {}
|
||||||
for spacedeck in event["decks"]:
|
for spacedeck in event["decks"]:
|
||||||
deck = spacedeck.replace(" ","")
|
deck = spacedeck.replace(" ","")
|
||||||
for keydeck in deckkey:
|
thedecks[spacedeck] = deckkey[deck]
|
||||||
if deck in keydeck:
|
|
||||||
thedecks[spacedeck] = keydeck[deck]
|
|
||||||
break
|
|
||||||
portcolours = list(thedecks.values())
|
portcolours = list(thedecks.values())
|
||||||
portcolours = sorted(list(dict.fromkeys(portcolours)))
|
portcolours = sorted(list(dict.fromkeys(portcolours)))
|
||||||
if len(portcolours) < 3:
|
if len(portcolours) < 3:
|
||||||
|
@ -106,10 +102,10 @@ for event in log.log:
|
||||||
if card[0:4] == "sig_":
|
if card[0:4] == "sig_":
|
||||||
thecard["colour"] = "sig"
|
thecard["colour"] = "sig"
|
||||||
else:
|
else:
|
||||||
for deck in deckkey:
|
try:
|
||||||
if thedeck in deck:
|
thecard["colour"] = deckkey[thedeck]
|
||||||
thecard["colour"] = deck[thedeck]
|
except:
|
||||||
break
|
pass
|
||||||
try:
|
try:
|
||||||
if thecard["colour"]:
|
if thecard["colour"]:
|
||||||
pass
|
pass
|
||||||
|
@ -237,6 +233,16 @@ for event in log.log:
|
||||||
coupons.append({newcoupon:event["coupons"][newcoupon]})
|
coupons.append({newcoupon:event["coupons"][newcoupon]})
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
for card in event["pend"]:
|
||||||
|
pends.append(card)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
for card in event["unpend"]:
|
||||||
|
pends.remove(card)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if logit == True:
|
if logit == True:
|
||||||
logitems.append(logentry)
|
logitems.append(logentry)
|
||||||
|
|
||||||
|
@ -268,10 +274,7 @@ decklist = []
|
||||||
for deck in decks:
|
for deck in decks:
|
||||||
thedeck = {}
|
thedeck = {}
|
||||||
thedeck["name"] = deck
|
thedeck["name"] = deck
|
||||||
for keydeck in deckkey:
|
thedeck["colour"] = deckkey[deck]
|
||||||
if deck in keydeck:
|
|
||||||
thedeck["colour"] = keydeck[deck]
|
|
||||||
break
|
|
||||||
thedeck["mass"] = []
|
thedeck["mass"] = []
|
||||||
thedeck["massmaster"] = []
|
thedeck["massmaster"] = []
|
||||||
for theme in variables.masscollect:
|
for theme in variables.masscollect:
|
||||||
|
@ -346,11 +349,50 @@ for deck in decklist:
|
||||||
for number in numbers:
|
for number in numbers:
|
||||||
if deck[number] == None:
|
if deck[number] == None:
|
||||||
wantedcard = {}
|
wantedcard = {}
|
||||||
wantedcard["name"] = deck["name"] + str(number)
|
wantedcard["name"] = deck["name"] + number
|
||||||
wantedcard["colour"] = deck["colour"]
|
wantedcard["colour"] = deck["colour"]
|
||||||
wantedcard["priority"] = deck["priority"]
|
wantedcard["priority"] = deck["priority"]
|
||||||
wantedlist.append(wantedcard)
|
wantedlist.append(wantedcard)
|
||||||
|
|
||||||
|
decknames = []
|
||||||
|
for deck in decklist:
|
||||||
|
decknames.append(deck["name"])
|
||||||
|
|
||||||
|
for theme in variables.masscollect:
|
||||||
|
if variables.masscollect[theme]["full"] == True:
|
||||||
|
try:
|
||||||
|
for deck in variables.masscollect[theme]["decks"]:
|
||||||
|
if deck not in decknames:
|
||||||
|
for number in numbers:
|
||||||
|
wantedcard = {}
|
||||||
|
wantedcard["name"] = deck + number
|
||||||
|
wantedcard["colour"] = deckkey[deck]
|
||||||
|
wantedcard["priority"] = 3
|
||||||
|
wantedlist.append(wantedcard)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
for card in variables.masscollect[theme]["singles"]:
|
||||||
|
if card[:-2] not in decknames:
|
||||||
|
wantedcard = {}
|
||||||
|
wantedcard["name"] = card
|
||||||
|
wantedcard["colour"] = deckkey[card[:-2]]
|
||||||
|
wantedcard["priority"] = 3
|
||||||
|
wantedlist.append(wantedcard)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
wantedlist = sorted(wantedlist, key=lambda d: d["name"])
|
||||||
|
|
||||||
|
removelist = []
|
||||||
|
|
||||||
|
for card in wantedlist:
|
||||||
|
if card["name"] in pends:
|
||||||
|
removelist.append(card)
|
||||||
|
|
||||||
|
for card in removelist:
|
||||||
|
wantedlist.remove(card)
|
||||||
|
|
||||||
print("Adjusting card priorities")
|
print("Adjusting card priorities")
|
||||||
|
|
||||||
for card in cardlist:
|
for card in cardlist:
|
||||||
|
@ -442,12 +484,20 @@ def footerwrite(thefile):
|
||||||
footer.close()
|
footer.close()
|
||||||
|
|
||||||
def printcard(card):
|
def printcard(card):
|
||||||
if card["colour"] == "sig":
|
if type(card) == dict:
|
||||||
return "<img src=\"/decks/sigs/" + card["name"][4:] + ".gif\" title=\"" + card["name"] + "\" loading=\"lazy\">"
|
if card["colour"] == "sig":
|
||||||
else:
|
return "<img src=\"/decks/sigs/" + card["name"][4:] + ".gif\" title=\"" + card["name"] + "\" loading=\"lazy\">"
|
||||||
deck = card["name"][:-2]
|
else:
|
||||||
cardid = card["name"][-2:]
|
deck = card["name"][:-2]
|
||||||
return "<img src=\"/decks/" + deck + "/" + cardid + ".gif\" title=\"" + card["name"] + "\" loading=\"lazy\">"
|
cardid = card["name"][-2:]
|
||||||
|
return "<img src=\"/decks/" + deck + "/" + cardid + ".gif\" title=\"" + card["name"] + "\" loading=\"lazy\">"
|
||||||
|
elif type(card) == str:
|
||||||
|
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 cardtext(card):
|
def cardtext(card):
|
||||||
cardtext = "<span class=\"cardname\">"
|
cardtext = "<span class=\"cardname\">"
|
||||||
|
@ -807,6 +857,8 @@ def printdeck(deck,fold=True):
|
||||||
break
|
break
|
||||||
if found == False:
|
if found == False:
|
||||||
deckstring += "<img src=\"/decks/" + deck["name"] + "/00.gif\" loading=\"lazy\">"
|
deckstring += "<img src=\"/decks/" + deck["name"] + "/00.gif\" loading=\"lazy\">"
|
||||||
|
if deck["name"] + teststring in pends:
|
||||||
|
deckstring += "<p class=\"pending\">pending</p>"
|
||||||
deckstring += "</td>\n"
|
deckstring += "</td>\n"
|
||||||
if test % 5 == 0:
|
if test % 5 == 0:
|
||||||
deckstring += " </tr>\n"
|
deckstring += " </tr>\n"
|
||||||
|
@ -1074,10 +1126,7 @@ def indexgen():
|
||||||
content.write("<h2>faves</h2>\n<p>")
|
content.write("<h2>faves</h2>\n<p>")
|
||||||
faveslist = sorted(variables.faves)
|
faveslist = sorted(variables.faves)
|
||||||
for card in faveslist:
|
for card in faveslist:
|
||||||
for thecard in cardlist:
|
content.write(printcard(card))
|
||||||
if card == thecard["name"]:
|
|
||||||
content.write(printcard(thecard))
|
|
||||||
break
|
|
||||||
content.write("</p>\n")
|
content.write("</p>\n")
|
||||||
if len(coupons) > 0:
|
if len(coupons) > 0:
|
||||||
content.write("<h2>coupons</h2>\n<p>")
|
content.write("<h2>coupons</h2>\n<p>")
|
||||||
|
@ -1092,26 +1141,43 @@ def indexgen():
|
||||||
content.write("</p>\n")
|
content.write("</p>\n")
|
||||||
donations = []
|
donations = []
|
||||||
try:
|
try:
|
||||||
for deck in variables.donations["decks"]:
|
for donatedeck in variables.donations["decks"]:
|
||||||
donations.append(deck + "00")
|
donation = {}
|
||||||
|
donation["name"] = donatedeck
|
||||||
|
for deck in decklist:
|
||||||
|
if deck["name"] == donatedeck:
|
||||||
|
if deck["mastered"]:
|
||||||
|
donation["type"] = "mastered"
|
||||||
|
else:
|
||||||
|
donation["type"] = "deck"
|
||||||
|
break
|
||||||
|
donations.append(donation)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
for card in variables.donations["scrapbook"]:
|
for card in variables.donations["scrapbook"]:
|
||||||
donations.append(card)
|
donation = {}
|
||||||
|
donation["name"] = card
|
||||||
|
donation["type"] = "single"
|
||||||
|
donations.append(donation)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if len(donations) > 0:
|
if len(donations) > 0:
|
||||||
donations = sorted(donations)
|
donations = sorted(donations, key=lambda d: d["name"])
|
||||||
content.write("<h2>donations</h2>\n<p>")
|
content.write("<h2>donations</h2>\n<p>")
|
||||||
for donation in donations:
|
for donation in donations:
|
||||||
if donation[-2:] == "00":
|
if donation["type"] == "deck":
|
||||||
content.write("<img src=\"/decks/" + donation[:-2] + "/00.gif\" loading=\"lazy\">")
|
content.write("<img src=\"/decks/" + donation["name"] + "/00.gif\" loading=\"lazy\">")
|
||||||
else:
|
elif donation["type"] == "mastered":
|
||||||
for thecard in cardlist:
|
content.write("<img src=\"/decks/" + donation["name"] + "/master.gif\" title=\"mastered " + donation["name"])
|
||||||
if donation == thecard["name"]:
|
try:
|
||||||
content.write(printcard(thecard))
|
if donation["name"] in variables.firstmasteries:
|
||||||
break
|
content.write(" (first)\" class=\"first")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
content.write("\">")
|
||||||
|
elif donation["type"] == "single":
|
||||||
|
content.write(printcard(donation["name"]))
|
||||||
content.write("</p>\n")
|
content.write("</p>\n")
|
||||||
content.close()
|
content.close()
|
||||||
footerwrite(thefile)
|
footerwrite(thefile)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue