Add switch it up function
This commit is contained in:
parent
3d479f1f60
commit
80a825c344
2 changed files with 180 additions and 2 deletions
|
@ -3,7 +3,7 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards
|
||||||
|
|
||||||
** Instructions
|
** Instructions
|
||||||
*** Requirements
|
*** Requirements
|
||||||
- =python3= (needs the following libraries: =bs4, collections, datetime, os, re, requests=)
|
- =python3= (needs the following libraries: =bs4, collections, datetime, os, random, re, requests=)
|
||||||
- server space
|
- server space
|
||||||
- subdomain pointing to your site root on the server
|
- subdomain pointing to your site root on the server
|
||||||
- =rclone= with your server set up as a remote
|
- =rclone= with your server set up as a remote
|
||||||
|
|
180
colors.py
180
colors.py
|
@ -1,4 +1,4 @@
|
||||||
import datetime,os,re,requests
|
import datetime,os,random,re,requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
import log,variables
|
import log,variables
|
||||||
|
@ -1361,6 +1361,184 @@ def nextportfolio(monochrome=False):
|
||||||
porturl = input("\nPaste the comment URL here: ")
|
porturl = input("\nPaste the comment URL here: ")
|
||||||
print("\n{\"event\":\"portfolio\",\"date\":datetime.datetime(" + datetime.datetime.today().strftime("%Y,%-m,%-d") + "),\"url\":\"" + porturl + "\",\"decks\":[\"" + alleight[0] + "\",\"" + alleight[1] + "\",\"" + alleight[2] + "\",\"" + alleight[3] + "\",\"" + alleight[4] + "\",\"" + alleight[5] + "\",\"" + alleight[6] + "\",\"" + alleight[7] + "\"]}")
|
print("\n{\"event\":\"portfolio\",\"date\":datetime.datetime(" + datetime.datetime.today().strftime("%Y,%-m,%-d") + "),\"url\":\"" + porturl + "\",\"decks\":[\"" + alleight[0] + "\",\"" + alleight[1] + "\",\"" + alleight[2] + "\",\"" + alleight[3] + "\",\"" + alleight[4] + "\",\"" + alleight[5] + "\",\"" + alleight[6] + "\",\"" + alleight[7] + "\"]}")
|
||||||
|
|
||||||
|
def switchit():
|
||||||
|
wantedbypriority = sorted(wantedlist, key=lambda d: d["priority"])
|
||||||
|
redtrade = []
|
||||||
|
orangetrade = []
|
||||||
|
yellowtrade = []
|
||||||
|
greentrade = []
|
||||||
|
bluetrade = []
|
||||||
|
purpletrade = []
|
||||||
|
browntrade = []
|
||||||
|
greytrade = []
|
||||||
|
for card in cardlist:
|
||||||
|
if card["priority"] == 4:
|
||||||
|
if card["colour"] == "red":
|
||||||
|
redtrade.append(card["name"])
|
||||||
|
elif card["colour"] == "orange":
|
||||||
|
orangetrade.append(card["name"])
|
||||||
|
elif card["colour"] == "yellow":
|
||||||
|
yellowtrade.append(card["name"])
|
||||||
|
elif card["colour"] == "green":
|
||||||
|
greentrade.append(card["name"])
|
||||||
|
elif card["colour"] == "blue":
|
||||||
|
bluetrade.append(card["name"])
|
||||||
|
elif card["colour"] == "purple":
|
||||||
|
purpletrade.append(card["name"])
|
||||||
|
elif card["colour"] == "brown":
|
||||||
|
browntrade.append(card["name"])
|
||||||
|
elif card["colour"] == "gray":
|
||||||
|
greytrade.append(card["name"])
|
||||||
|
wantednames = []
|
||||||
|
for card in wantedbypriority:
|
||||||
|
wantednames.append(card["name"])
|
||||||
|
wantall = []
|
||||||
|
tradeall = []
|
||||||
|
reds = input("Paste red pile here: ").split(", ")
|
||||||
|
wantreds = []
|
||||||
|
for card in reds:
|
||||||
|
if card in wantednames:
|
||||||
|
wantreds.append(card)
|
||||||
|
if len(wantreds) > 5:
|
||||||
|
wantreds = wantreds[:5]
|
||||||
|
if len(wantreds) > 0:
|
||||||
|
wantall.extend(wantreds)
|
||||||
|
traderedscount = len(wantreds)
|
||||||
|
tradereds = []
|
||||||
|
tradereds.extend(random.sample(redtrade,len(wantreds)))
|
||||||
|
tradeall.extend(tradereds)
|
||||||
|
oranges = input("Paste orange pile here: ").split(", ")
|
||||||
|
wantoranges = []
|
||||||
|
for card in oranges:
|
||||||
|
if card in wantednames:
|
||||||
|
wantoranges.append(card)
|
||||||
|
if len(wantoranges) > 5:
|
||||||
|
wantoranges = wantoranges[:5]
|
||||||
|
if len(wantoranges) > 0:
|
||||||
|
wantall.extend(wantoranges)
|
||||||
|
tradeorangescount = len(wantoranges)
|
||||||
|
tradeoranges = []
|
||||||
|
tradeoranges.extend(random.sample(orangetrade,len(wantoranges)))
|
||||||
|
tradeall.extend(tradeoranges)
|
||||||
|
yellows = input("Paste yellow pile here: ").split(", ")
|
||||||
|
wantyellows = []
|
||||||
|
for card in yellows:
|
||||||
|
if card in wantednames:
|
||||||
|
wantyellows.append(card)
|
||||||
|
if len(wantyellows) > 5:
|
||||||
|
wantyellows = wantyellows[:5]
|
||||||
|
if len(wantyellows) > 0:
|
||||||
|
wantall.extend(wantyellows)
|
||||||
|
tradeyellowscount = len(wantyellows)
|
||||||
|
tradeyellows = []
|
||||||
|
tradeyellows.extend(random.sample(yellowtrade,len(wantyellows)))
|
||||||
|
tradeall.extend(tradeyellows)
|
||||||
|
greens = input("Paste green pile here: ").split(", ")
|
||||||
|
wantgreens = []
|
||||||
|
for card in greens:
|
||||||
|
if card in wantednames:
|
||||||
|
wantgreens.append(card)
|
||||||
|
if len(wantgreens) > 5:
|
||||||
|
wantgreens = wantgreens[:5]
|
||||||
|
if len(wantgreens) > 0:
|
||||||
|
wantall.extend(wantgreens)
|
||||||
|
tradegreenscount = len(wantgreens)
|
||||||
|
tradegreens = []
|
||||||
|
tradegreens.extend(random.sample(greentrade,len(wantgreens)))
|
||||||
|
tradeall.extend(tradegreens)
|
||||||
|
blues = input("Paste blue pile here: ").split(", ")
|
||||||
|
wantblues = []
|
||||||
|
for card in blues:
|
||||||
|
if card in wantednames:
|
||||||
|
wantblues.append(card)
|
||||||
|
if len(wantblues) > 5:
|
||||||
|
wantblues = wantblues[:5]
|
||||||
|
if len(wantblues) > 0:
|
||||||
|
wantall.extend(wantblues)
|
||||||
|
tradebluescount = len(wantblues)
|
||||||
|
tradeblues = []
|
||||||
|
tradeblues.extend(random.sample(bluetrade,len(wantblues)))
|
||||||
|
tradeall.extend(tradeblues)
|
||||||
|
purples = input("Paste purple pile here: ").split(", ")
|
||||||
|
wantpurples = []
|
||||||
|
for card in purples:
|
||||||
|
if card in wantednames:
|
||||||
|
wantpurples.append(card)
|
||||||
|
if len(wantpurples) > 5:
|
||||||
|
wantpurples = wantpurples[:5]
|
||||||
|
if len(wantpurples) > 0:
|
||||||
|
wantall.extend(wantpurples)
|
||||||
|
tradepurplescount = len(wantpurples)
|
||||||
|
tradepurples = []
|
||||||
|
tradepurples.extend(random.sample(purpletrade,len(wantpurples)))
|
||||||
|
tradeall.extend(tradepurples)
|
||||||
|
browns = input("Paste brown pile here: ").split(", ")
|
||||||
|
wantbrowns = []
|
||||||
|
for card in browns:
|
||||||
|
if card in wantednames:
|
||||||
|
wantbrowns.append(card)
|
||||||
|
if len(wantbrowns) > 5:
|
||||||
|
wantbrowns = wantbrowns[:5]
|
||||||
|
if len(wantbrowns) > 0:
|
||||||
|
wantall.extend(wantbrowns)
|
||||||
|
tradebrownscount = len(wantbrowns)
|
||||||
|
tradebrowns = []
|
||||||
|
tradebrowns.extend(random.sample(browntrade,len(wantbrowns)))
|
||||||
|
tradeall.extend(tradebrowns)
|
||||||
|
greys = input("Paste grey pile here: ").split(", ")
|
||||||
|
wantgreys = []
|
||||||
|
for card in greys:
|
||||||
|
if card in wantednames:
|
||||||
|
wantgreys.append(card)
|
||||||
|
if len(wantgreys) > 5:
|
||||||
|
wantgreys = wantgreys[:5]
|
||||||
|
if len(wantgreys) > 0:
|
||||||
|
wantall.extend(wantgreys)
|
||||||
|
tradegreyscount = len(wantgreys)
|
||||||
|
tradegreys = []
|
||||||
|
tradegreys.extend(random.sample(greytrade,len(wantgreys)))
|
||||||
|
tradeall.extend(tradegreys)
|
||||||
|
chaos = input("Paste chaos pile here: ").split(", ")
|
||||||
|
wantchaos = []
|
||||||
|
for card in chaos:
|
||||||
|
if card in wantednames:
|
||||||
|
wantchaos.append(card)
|
||||||
|
if len(wantchaos) > 5:
|
||||||
|
wantchaos = wantchaos[:5]
|
||||||
|
if len(wantchaos) > 0:
|
||||||
|
wantall.extend(wantchaos)
|
||||||
|
tradechaos = input("Provide " + str(len(wantchaos)) + " cards for the chaos pile (for " + ", ".join(tradechaos) + "): ").split(", ")
|
||||||
|
tradeall.extend(tradechaos)
|
||||||
|
print("\n")
|
||||||
|
if len(wantreds) > 0:
|
||||||
|
print("red: " + ", ".join(tradereds) + " for " + ", ".join(wantreds))
|
||||||
|
if len(wantoranges) > 0:
|
||||||
|
print("orange: " + ", ".join(tradeoranges) + " for " + ", ".join(wantoranges))
|
||||||
|
if len(wantyellows) > 0:
|
||||||
|
print("yellow: " + ", ".join(tradeyellows) + " for " + ", ".join(wantyellows))
|
||||||
|
if len(wantgreens) > 0:
|
||||||
|
print("green: " + ", ".join(tradegreens) + " for " + ", ".join(wantgreens))
|
||||||
|
if len(wantblues) > 0:
|
||||||
|
print("blue: " + ", ".join(tradeblues) + " for " + ", ".join(wantblues))
|
||||||
|
if len(wantpurples) > 0:
|
||||||
|
print("purple: " + ", ".join(tradepurples) + " for " + ", ".join(wantpurples))
|
||||||
|
if len(wantbrowns) > 0:
|
||||||
|
print("brown: " + ", ".join(tradebrowns) + " for " + ", ".join(wantbrowns))
|
||||||
|
if len(wantgreys) > 0:
|
||||||
|
if variables.british:
|
||||||
|
print("grey: " + ", ".join(tradegreys) + " for " + ", ".join(wantgreys))
|
||||||
|
else:
|
||||||
|
print("gray: " + ", ".join(tradegreys) + " for " + ", ".join(wantgreys))
|
||||||
|
if len(wantchaos) > 0:
|
||||||
|
print("chaos: " + ", ".join(tradechaos) + " for " + ", ".join(wantchaos))
|
||||||
|
images = ""
|
||||||
|
for card in tradeall:
|
||||||
|
images += "<img src=\"https://colors-tcg.eu/cards/" + card + ".gif\">"
|
||||||
|
print("\n" + images + "\n")
|
||||||
|
switchround = input("Round number: ")
|
||||||
|
switchcomment = input("Comment URL: ")
|
||||||
|
print("\n{\"event\":\"switch it up " + switchround + "\",\"date\":datetime.datetime(" + datetime.datetime.today().strftime("%Y,%-m,%-d") + "),\"url\":\"" + switchcomment + "\",\"pend\":[\"" + "\",\"".join(wantall) + "\"],\"lost\":[\"" + "\",\"".join(tradeall) + "\"]}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("Building index page")
|
print("Building index page")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue