diff --git a/.gitignore b/.gitignore
index 89bef5c..a44f07e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,5 +12,6 @@ build/assets/misc/
__pycache__/
variables.py
log.py
+trade.py
build/user.css
key.html
\ No newline at end of file
diff --git a/README.org b/README.org
index c866593..45c4d9e 100644
--- a/README.org
+++ b/README.org
@@ -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=
diff --git a/colors.py b/colors.py
index 5f569bd..d530975 100644
--- a/colors.py
+++ b/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
\n- player name: " + variables.name + "
\n- " + str(len(cardlist) + tradepend) + " cards held (" + rank + ")
\n- " + str(tradepend) + " cards pending trade
\n- started
" + firstdate.strftime("%Y-%m-%d") + "
\n- last updated
" + datetime.datetime.now().strftime("%Y-%m-%d") + "
\n- code ")
+ content.write("\n
\n- player name: " + variables.name + "
\n- " + str(len(cardlist) + tradepend) + " cards (" + rank + ")
\n- " + str(tradepend) + " cards held for trades
\n- started
" + firstdate.strftime("%Y-%m-%d") + "
\n- last updated
" + datetime.datetime.now().strftime("%Y-%m-%d") + "
\n- code ")
if variables.name == "Mez":
content.write("under construction")
else:
diff --git a/tools.py b/tools.py
index 9b8cac9..ed24565 100644
--- a/tools.py
+++ b/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

")
+ 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")
diff --git a/trade-template.py b/trade-template.py
new file mode 100644
index 0000000..c09af4a
--- /dev/null
+++ b/trade-template.py
@@ -0,0 +1,2 @@
+theirtradepile = ""
+theirwantlist = ""