Add functions for showing card or deck details, proposing trades; correct priority for scrapbook singles
This commit is contained in:
parent
aee8f5e122
commit
b7f628944d
5 changed files with 184 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,5 +12,6 @@ build/assets/misc/
|
|||
__pycache__/
|
||||
variables.py
|
||||
log.py
|
||||
trade.py
|
||||
build/user.css
|
||||
key.html
|
|
@ -14,6 +14,7 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards
|
|||
cd tcg
|
||||
cp log-template.py log.py
|
||||
cp variables-template.py variables.py
|
||||
cp trade-template.py trade.py
|
||||
#+END_SRC
|
||||
- Edit =variables.py= to set the variables as follows:
|
||||
- =servername=: name set for your remote in =rclone=
|
||||
|
|
18
colors.py
18
colors.py
|
@ -89,16 +89,19 @@ for event in log.log:
|
|||
thecard["name"] = card
|
||||
thecard["received"] = event["date"]
|
||||
thecard["mass"] = []
|
||||
thecard["priority"] = 0
|
||||
if card[0:4] != "sig_":
|
||||
for theme in variables.masscollect:
|
||||
try:
|
||||
if thedeck in variables.masscollect[theme]["decks"]:
|
||||
thecard["mass"].append(theme)
|
||||
thecard["priority"] = 3
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
if card in variables.masscollect[theme]["singles"]:
|
||||
thecard["mass"].append(theme)
|
||||
thecard["priority"] = 2
|
||||
except KeyError:
|
||||
pass
|
||||
if card[0:4] == "sig_":
|
||||
|
@ -119,12 +122,13 @@ for event in log.log:
|
|||
else:
|
||||
thecard["priority"] = 1
|
||||
else:
|
||||
if thedeck in variables.highpriority:
|
||||
thecard["priority"] = 1
|
||||
elif len(thecard["mass"]) > 0:
|
||||
thecard["priority"] = 3
|
||||
else:
|
||||
thecard["priority"] = 4
|
||||
if thecard["priority"] == 0:
|
||||
if thedeck in variables.highpriority:
|
||||
thecard["priority"] = 1
|
||||
elif len(thecard["mass"]) > 0:
|
||||
thecard["priority"] = 3
|
||||
else:
|
||||
thecard["priority"] = 4
|
||||
cardlist.append(thecard)
|
||||
datelist.append(event["date"])
|
||||
receivedcards.append(thecard)
|
||||
|
@ -1148,7 +1152,7 @@ def indexgen():
|
|||
if len(variables.subfolder) > 0:
|
||||
content.write("/" + variables.subfolder)
|
||||
content.write("/assets/banner.png\" loading=\"lazy\">")
|
||||
content.write("\n<ul>\n<li>player name: <span class=\"name\">" + variables.name + "</span></li>\n<li>" + str(len(cardlist) + tradepend) + " cards held <span class=\"rank " + rank + "\">(" + rank + ")</span></li>\n<li>" + str(tradepend) + " cards pending trade</li>\n<li>started <code>" + firstdate.strftime("%Y-%m-%d") + "</code></li>\n<li>last updated <code>" + datetime.datetime.now().strftime("%Y-%m-%d") + "</code></li>\n<li><a href=\"https://git.praze.net/tre/tcg\" target=\"_blank\">code</a> ")
|
||||
content.write("\n<ul>\n<li>player name: <span class=\"name\">" + variables.name + "</span></li>\n<li>" + str(len(cardlist) + tradepend) + " cards <span class=\"rank " + rank + "\">(" + rank + ")</span></li>\n<li>" + str(tradepend) + " cards held for trades</li>\n<li>started <code>" + firstdate.strftime("%Y-%m-%d") + "</code></li>\n<li>last updated <code>" + datetime.datetime.now().strftime("%Y-%m-%d") + "</code></li>\n<li><a href=\"https://git.praze.net/tre/tcg\" target=\"_blank\">code</a> ")
|
||||
if variables.name == "Mez":
|
||||
content.write("under construction")
|
||||
else:
|
||||
|
|
171
tools.py
171
tools.py
|
@ -1,6 +1,6 @@
|
|||
import datetime,random,math
|
||||
from collections import Counter
|
||||
import colors,log,variables
|
||||
import colors,log,trade,variables
|
||||
|
||||
def dupes(mass=True,nonmass=True,characters=True,specials=True):
|
||||
dupeslist = []
|
||||
|
@ -1758,12 +1758,173 @@ def tradecheck():
|
|||
if len(notin) > 0:
|
||||
print("Requested but not in collection: " + ", ".join(notin))
|
||||
|
||||
def cardcheck():
|
||||
thecard = input("Card name: ")
|
||||
print("\n")
|
||||
found = False
|
||||
for card in colors.cardlist:
|
||||
if card["name"] == thecard:
|
||||
print("In collection:")
|
||||
print(card)
|
||||
found = True
|
||||
if found == False:
|
||||
for card in colors.pends:
|
||||
if card == thecard:
|
||||
print("Card on pending list")
|
||||
found = True
|
||||
if found == False:
|
||||
for card in colors.wantedlist:
|
||||
if card["name"] == thecard:
|
||||
print("On wantlist:")
|
||||
print(card)
|
||||
found = True
|
||||
if found == False:
|
||||
print("No matches")
|
||||
|
||||
def deckcheck():
|
||||
thedeck = input("Deck name: ")
|
||||
print("\n")
|
||||
found = False
|
||||
for deck in colors.decklist:
|
||||
if deck["name"] == thedeck:
|
||||
print(deck)
|
||||
found = True
|
||||
if found == False:
|
||||
for theme in variables.masscollect:
|
||||
try:
|
||||
for deck in variables.masscollect[theme]["decks"]:
|
||||
if deck == thedeck:
|
||||
print("On mass deck wantlist: " + theme)
|
||||
found = True
|
||||
except:
|
||||
pass
|
||||
if found == False:
|
||||
print("No matches")
|
||||
|
||||
def maketrade():
|
||||
print("\nMake sure the other player’s tradepile and wantlist are in trade.py")
|
||||
theirname = input("Player with whom you are trading: ")
|
||||
theircards = list(dict.fromkeys(trade.theirtradepile.split(", ")))
|
||||
removetheirs = input("Cards to remove from their tradepile: ").split(", ")
|
||||
for card in removetheirs:
|
||||
if card in theircards:
|
||||
theircards.remove(card)
|
||||
hpwc = []
|
||||
hpws = []
|
||||
mpwc = []
|
||||
mpws = []
|
||||
lpwc = []
|
||||
lpws = []
|
||||
for thecard in theircards:
|
||||
for card in colors.wantedlist:
|
||||
if card["name"] == thecard:
|
||||
if card["colour"] == "special" or card["colour"] == "limited":
|
||||
if card["priority"] == 1:
|
||||
hpws.append(thecard)
|
||||
elif card["priority"] == 2:
|
||||
mpws.append(thecard)
|
||||
elif card["priority"] == 3:
|
||||
lpws.append(thecard)
|
||||
else:
|
||||
if card["priority"] == 1:
|
||||
hpwc.append(thecard)
|
||||
elif card["priority"] == 2:
|
||||
mpwc.append(thecard)
|
||||
elif card["priority"] == 3:
|
||||
lpwc.append(thecard)
|
||||
theirwantlist = list(dict.fromkeys(trade.theirwantlist.split(", ")))
|
||||
lptc = []
|
||||
lpts = []
|
||||
mptc = []
|
||||
mpts = []
|
||||
hptc = []
|
||||
hpts = []
|
||||
for thecard in theirwantlist:
|
||||
found = False
|
||||
for card in reversed(colors.cardlist):
|
||||
if found == False:
|
||||
if card["name"] == thecard:
|
||||
if card["colour"] == "special" or card["colour"] == "limited":
|
||||
if card["priority"] == 4:
|
||||
lpts.append(thecard)
|
||||
found = True
|
||||
elif card["priority"] == 3:
|
||||
mpts.append(thecard)
|
||||
found = True
|
||||
elif variables.trademedium:
|
||||
if card["priority"] == 2:
|
||||
hpts.append(thecard)
|
||||
found = True
|
||||
else:
|
||||
if card["priority"] == 4:
|
||||
lptc.append(thecard)
|
||||
found = True
|
||||
elif card["priority"] == 3:
|
||||
mptc.append(thecard)
|
||||
found = True
|
||||
elif variables.trademedium:
|
||||
if card["priority"] == 2:
|
||||
hptc.append(thecard)
|
||||
found = True
|
||||
inc = []
|
||||
outc = []
|
||||
inc.extend(hpwc)
|
||||
outc.extend(lptc)
|
||||
if len(inc) > len(outc):
|
||||
outc.extend(mptc)
|
||||
if len(inc) > len(outc):
|
||||
outc.extend(hptc)
|
||||
else:
|
||||
inc.extend(mpwc)
|
||||
else:
|
||||
inc.extend(mpwc)
|
||||
if len(inc) > len(outc):
|
||||
outc.extend(mptc)
|
||||
else:
|
||||
inc.extend(lpwc)
|
||||
if len(inc) > len(outc):
|
||||
inc = inc[:len(outc)]
|
||||
elif len(outc) > len(inc):
|
||||
outc = outc[:len(inc)]
|
||||
ins = []
|
||||
outs = []
|
||||
ins.extend(hpws)
|
||||
outs.extend(lpts)
|
||||
if len(ins) > len(outs):
|
||||
outs.extend(mpts)
|
||||
if len(ins) > len(outs):
|
||||
outs.extend(hpts)
|
||||
else:
|
||||
ins.extend(mpws)
|
||||
else:
|
||||
ins.extend(mpws)
|
||||
if len(ins) > len(outs):
|
||||
outs.extend(mpts)
|
||||
else:
|
||||
ins.extend(lpws)
|
||||
if len(ins) > len(outs):
|
||||
ins = ins[:len(outs)]
|
||||
elif len(outs) > len(ins):
|
||||
outs = outs[:len(ins)]
|
||||
thein = sorted(inc + ins)
|
||||
theout = sorted(outc + outs)
|
||||
addsigs = input("Add signatures? [y/N] ")
|
||||
if addsigs == "y":
|
||||
thein.append("sig_" + theirname.lower())
|
||||
theout.append("sig_" + variables.name.lower())
|
||||
if len(thein) > 0:
|
||||
print("\nmy " + ", ".join(theout) + "\n\nfor your " + ", ".join(thein) + "?\n\n<img src=\"https://colors-tcg.eu/cards/" + ".gif\"><img src=\"https://colors-tcg.eu/cards/".join(theout) + ".gif\">")
|
||||
tradeurl = input("\nPaste in comment URL: ")
|
||||
print("\n{\"event\":\"trade with " + theirname + "\",\"date\":datetime.datetime(" + datetime.datetime.now().strftime("%Y,%-m,%-d") + "),\"url\":\"" + tradeurl + "\",\"lost\":[\"" + "\",\"".join(theout) + "\"],\"pend\":[\"" + "\",\"".join(thein) + "\"]}")
|
||||
else:
|
||||
print("Nothing to trade")
|
||||
|
||||
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","Get a list of random cards from tradepile (excluding specials)","Get a list of random cards from tradepile (including specials)","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 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 some statistics about the collection"]
|
||||
for optionName in options:
|
||||
index = index + 1
|
||||
indexValidList.extend([options.index(optionName)])
|
||||
|
@ -1801,5 +1962,11 @@ if __name__ == "__main__":
|
|||
stats()
|
||||
elif chosen == "Check a trade offer":
|
||||
tradecheck()
|
||||
elif chosen == "Check a card in the collection":
|
||||
cardcheck()
|
||||
elif chosen == "Check details of a deck":
|
||||
deckcheck()
|
||||
elif chosen == "Propose a trade":
|
||||
maketrade()
|
||||
print("\n")
|
||||
input("Press Enter to continue or Ctrl-C to exit")
|
||||
|
|
2
trade-template.py
Normal file
2
trade-template.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
theirtradepile = ""
|
||||
theirwantlist = ""
|
Loading…
Add table
Add a link
Reference in a new issue