Add functions for Riku’s Favors and Swap Station
This commit is contained in:
parent
1929ea9af3
commit
26159685ce
2 changed files with 108 additions and 17 deletions
96
tools.py
96
tools.py
|
@ -36,12 +36,6 @@ def dupes(mass=True,nonmass=True,characters=True,specials=True):
|
|||
def activitydupes():
|
||||
print(dupes(False,True,True,False))
|
||||
|
||||
def riku():
|
||||
print("Specials")
|
||||
print(dupes(True,False,False,True))
|
||||
print("Characters")
|
||||
print(dupes(True,False,True,False))
|
||||
|
||||
def nextportfolio(monochrome=False):
|
||||
goodtogo = True
|
||||
useddecks = {}
|
||||
|
@ -2051,12 +2045,96 @@ def masteredtoday():
|
|||
except:
|
||||
pass
|
||||
|
||||
def swapstation():
|
||||
swappablemedium = []
|
||||
swappablelow = []
|
||||
for card in colors.cardlist:
|
||||
if card["priority"] == 4:
|
||||
for deck in colors.decklist:
|
||||
if not deck["mastered"]:
|
||||
if card["name"][:-2] == deck["name"]:
|
||||
if deck["priority"] < 4:
|
||||
thecard = {}
|
||||
thecard["name"] = card["name"]
|
||||
thecard["remaining"] = 20 - deck["count"]
|
||||
thecard["priority"] = deck["priority"]
|
||||
if deck["priority"] < 3:
|
||||
swappablemedium.append(thecard)
|
||||
else:
|
||||
swappablelow.append(thecard)
|
||||
swappablemedium = sorted(swappablemedium, key=lambda d: d["remaining"],reverse=True)
|
||||
swappablelow = sorted(swappablelow, key=lambda d: d["remaining"],reverse=True)
|
||||
swappable = swappablemedium + swappablelow
|
||||
swapquota = 4
|
||||
swapcards = []
|
||||
while swapquota > 0:
|
||||
try:
|
||||
swapcards.append(swappable[swapquota - 1]["name"])
|
||||
except:
|
||||
pass
|
||||
swapquota -= 1
|
||||
swapcards = sorted(list(dict.fromkeys(swapcards)))
|
||||
print("<img src=\"https://colors-tcg.eu/cards/" + ".gif\"><img src=\"https://colors-tcg.eu/cards/".join(swapcards) + ".gif\">\n" + ", ".join(swapcards))
|
||||
swapno = input("\nRound number: ")
|
||||
swapurl = input("Comment URL: ")
|
||||
print("\n{\"event\":\"swap station " + swapno + "\",\"date\":datetime.datetime(" + datetime.datetime.now().strftime("%Y,%-m,%-d") + "),\"url\":\"" + swapurl + "\",\"lost\":[\"" + "\",\"".join(swapcards) + "\"]}")
|
||||
|
||||
def newriku():
|
||||
wantedpri = sorted(colors.wantedlist, key=lambda d: d["priority"])
|
||||
rikuquota = 5
|
||||
potential = colors.cardlist.copy()
|
||||
swapseries = []
|
||||
allswaps = []
|
||||
allin = []
|
||||
allout = []
|
||||
for card in wantedpri:
|
||||
if rikuquota > 0:
|
||||
if card["colour"] == "special":
|
||||
if card["series"] != "Scrapbook":
|
||||
swaps = []
|
||||
for tradecard in potential:
|
||||
if len(swaps) < 2:
|
||||
if tradecard["colour"] == "special":
|
||||
if tradecard["series"] != "Scrapbook":
|
||||
if tradecard["priority"] == 4:
|
||||
if tradecard["series"].lower() == card["series"].lower():
|
||||
swaps.append(tradecard["name"])
|
||||
potential.remove(tradecard)
|
||||
else:
|
||||
swaps = []
|
||||
for tradecard in potential:
|
||||
if len(swaps) < 2:
|
||||
if tradecard["colour"] != "special":
|
||||
if tradecard["priority"] == 4:
|
||||
if tradecard["series"].lower() == card["series"].lower():
|
||||
swaps.append(tradecard["name"])
|
||||
potential.remove(tradecard)
|
||||
if len(swaps) == 2:
|
||||
if card["series"] not in swapseries:
|
||||
swapseries.append(card["series"])
|
||||
swapdict = {}
|
||||
swapdict["in"] = card["name"]
|
||||
swapdict["out"] = swaps
|
||||
allswaps.append(swapdict)
|
||||
allin.append(card["name"])
|
||||
for outcard in swaps:
|
||||
allout.append(outcard)
|
||||
rikuquota -= 1
|
||||
print("\n<b>Series:</b> " + ", ".join(swapseries) + "\n<b>List of cards given:</b> " + ", ".join(allout) + "\n<img src=\"https://colors-tcg.eu/cards/" + ".gif\"><img src=\"https://colors-tcg.eu/cards/".join(allout) + ".gif\">")
|
||||
swapcount = 1
|
||||
for swap in allswaps:
|
||||
print("<i>Swap " + str(swapcount) + ":</i> " + ", ".join(swap["out"]) + " for " + swap["in"])
|
||||
swapcount += 1
|
||||
rikuround = input("\nRound number: ")
|
||||
rikuurl = input("Comment URL: ")
|
||||
print("\n{\"event\":\"riku’s favors " + rikuround + "\",\"date\":datetime.datetime(" + datetime.datetime.now().strftime("%Y,%-m,%-d") + "),\"url\":\"" + rikuurl + "\",\"lost\":[\"" + "\",\"".join(allout) + "\"],\"received\":[\"" + "\",\"".join(allin) + "\"]}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
while True:
|
||||
index = 0 # adapted from https://stackoverflow.com/a/64536882
|
||||
indexValidList = []
|
||||
print("Choose from the list:")
|
||||
options = ["Get a list of potential cards to trade in for Riku’s Favors","Generate next palette portfolio","Generate next monochrome portfolio","Generate Switch It Up request","Generate Go Fish comment","Generate art shop request","Generate art studio request","Check a trade offer","Propose a trade","Get a list of random cards from tradepile (excluding specials)","Get a list of random cards from tradepile (including specials)","Check a card in the collection","Check details of a deck","See decks mastered today","See some statistics about the collection"]
|
||||
options = ["Get a list of potential cards to trade in for Riku’s Favors","Generate next palette portfolio","Generate next monochrome portfolio","Generate Switch It Up request","Generate Swap Station request","Generate Go Fish comment","Generate art shop request","Generate art studio request","Check a trade offer","Propose a trade","Get a list of random cards from tradepile (excluding specials)","Get a list of random cards from tradepile (including specials)","Check a card in the collection","Check details of a deck","See decks mastered today","See some statistics about the collection"]
|
||||
for optionName in options:
|
||||
index = index + 1
|
||||
indexValidList.extend([options.index(optionName)])
|
||||
|
@ -2073,7 +2151,7 @@ if __name__ == "__main__":
|
|||
print("Select a number from the list")
|
||||
chosen = options[selected]
|
||||
if chosen == "Get a list of potential cards to trade in for Riku’s Favors":
|
||||
riku()
|
||||
newriku()
|
||||
elif chosen == "Generate next palette portfolio":
|
||||
nextportfolio()
|
||||
elif chosen == "Generate next monochrome portfolio":
|
||||
|
@ -2102,5 +2180,7 @@ if __name__ == "__main__":
|
|||
masteredtoday()
|
||||
elif chosen == "Propose a trade":
|
||||
maketrade()
|
||||
elif chosen == "Generate Swap Station request":
|
||||
swapstation()
|
||||
print("\n")
|
||||
input("Press Enter to continue or Ctrl-C to exit")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue