Remove anniversary decks from wantlist, fix trade function

This commit is contained in:
mez 2025-06-02 22:42:59 +01:00
parent 695146cac1
commit 44b2c1c05e
2 changed files with 96 additions and 63 deletions

View file

@ -508,13 +508,14 @@ wantedlist = []
for deck in decklist:
if deck["priority"] < 4:
for number in numbers:
if deck[number] == None:
wantedcard = {}
wantedcard["name"] = deck["name"] + number
wantedcard["colour"] = deck["colour"]
wantedcard["priority"] = deck["priority"]
wantedlist.append(wantedcard)
if deck["colour"] != "limited":
for number in numbers:
if deck[number] == None:
wantedcard = {}
wantedcard["name"] = deck["name"] + number
wantedcard["colour"] = deck["colour"]
wantedcard["priority"] = deck["priority"]
wantedlist.append(wantedcard)
decknames = []
for deck in decklist:

144
tools.py
View file

@ -1833,7 +1833,11 @@ def maketrade():
randomsp = []
totalrandomch = 0
totalrandomsp = 0
randoms = input("Do they take randoms? [y/N] ")
ifrandoms = input("Do they take randoms? [y/N] ")
if ifrandoms == "y":
randoms = True
else:
randoms = False
for thecard in theirwantlist:
found = False
for card in reversed(colors.cardlist):
@ -1873,114 +1877,140 @@ def maketrade():
outc = []
inc.extend(hpwc)
outc.extend(lptc)
medchadded = False
if len(inc) > len(outc):
if randoms:
randomch = random.shuffle(randomch)
neededrandomch = len(inc) - len(outc)
totalrandomch += neededrandomch
try:
random.shuffle(randomch)
neededrandomch = len(inc) - len(outc)
totalrandomch += neededrandomch
add = randomch[:neededrandomch]
randomch = randomch[neededrandomch:]
outc.extend(add)
trymediumch = True
except:
outc.extend(mptc)
medchadded = True
if len(inc) > len(outc):
trymediumch = False
outc.extend(hptc)
else:
inc.extend(mpwc)
trymediumch = True
else:
outc.extend(mptc)
medchadded = True
if len(inc) > len(outc):
trymediumch = False
outc.extend(hptc)
else:
inc.extend(mpwc)
else:
trymediumch = True
if trymediumch:
inc.extend(mpwc)
if len(inc) > len(outc):
if randoms:
randomch = random.shuffle(randomch)
neededrandomch = len(inc) - len(outc)
totalrandomch += neededrandomch
try:
random.shuffle(randomch)
neededrandomch = len(inc) - len(outc)
totalrandomch += neededrandomch
add = randomch[:neededrandomch]
randomch = randomch[neededrandomch:]
outc.extend(add)
trylowch = True
except:
trylowch = False
if not medchadded:
outc.extend(mptc)
else:
trylowch = False
if not medchadded:
outc.extend(mptc)
else:
trylowch = True
if trylowch:
inc.extend(lpwc)
if len(inc) > len(outc):
if randoms:
try:
random.shuffle(randomch)
neededrandomch = len(inc) - len(outc)
totalrandomch += neededrandomch
add = randomch[:neededrandomch]
randomch = randomch[neededrandomch:]
outc.extend(add)
except:
outc.extend(mptc)
else:
outc.extend(mptc)
else:
inc.extend(lpwc)
pass
if len(inc) > len(outc):
if randoms:
randomch = random.shuffle(randomch)
neededrandomch = len(inc) - len(outc)
totalrandomch += neededrandomch
try:
add = randomch[:neededrandomch]
randomch = randomch[neededrandomch:]
outc.extend(add)
except:
inc = inc[:len(outc)]
else:
inc = inc[:len(outc)]
inc = inc[:len(outc)]
elif len(outc) > len(inc):
outc = outc[:len(inc)]
ins = []
outs = []
ins.extend(hpws)
outs.extend(lpts)
medspadded = False
if len(ins) > len(outs):
if randoms:
randomsp = random.shuffle(randomsp)
neededrandomsp = len(ins) - len(outs)
totalrandomsp += neededrandomsp
try:
random.shuffle(randomsp)
neededrandomsp = len(ins) - len(outs)
totalrandomsp += neededrandomsp
add = randomsp[:neededrandomsp]
randomsp = randomsp[neededrandomsp:]
outs.extend(add)
trymediumsp = True
except:
outs.extend(mpts)
medspadded = True
if len(ins) > len(outs):
trymediumsp = False
outs.extend(hpts)
else:
ins.extend(mpws)
trymediumsp = True
else:
outs.extend(mpts)
medspadded = True
if len(ins) > len(outs):
trymediumsp = False
outs.extend(hpts)
else:
ins.extend(mpws)
else:
trymediumsp = True
if trymediumsp:
ins.extend(mpws)
if len(ins) > len(outs):
if randoms:
randomsp = random.shuffle(randomsp)
neededrandomsp = len(ins) - len(outs)
totalrandomsp += neededrandomsp
try:
random.shuffle(randomsp)
neededrandomsp = len(ins) - len(outs)
totalrandomsp += neededrandomsp
add = randomsp[:neededrandomsp]
randomsp = randomsp[neededrandomsp:]
outs.extend(add)
trylowsp = True
except:
trylowsp = False
if not medspadded:
outs.extend(mpts)
else:
trylowsp = False
if not medspadded:
outs.extend(mpts)
else:
trylowsp = True
if trylowsp:
ins.extend(lpws)
if len(ins) > len(outs):
if randoms:
try:
random.shuffle(randomsp)
neededrandomsp = len(ins) - len(outs)
totalrandomsp += neededrandomsp
add = randomsp[:neededrandomsp]
randomsp = randomsp[neededrandomsp:]
outs.extend(add)
except:
outs.extend(mpts)
else:
outs.extend(mpts)
else:
ins.extend(lpws)
pass
if len(ins) > len(outs):
if randoms:
randomsp = random.shuffle(randomsp)
neededrandomsp = len(ins) - len(outs)
totalrandomsp += neededrandomsp
try:
add = randomsp[:neededrandomsp]
randomsp = randomsp[neededrandomsp:]
outs.extend(add)
except:
ins = ins[:len(outs)]
else:
ins = ins[:len(outs)]
ins = ins[:len(outs)]
elif len(outs) > len(ins):
outs = outs[:len(ins)]
thein = sorted(inc + ins)
@ -1992,11 +2022,13 @@ def maketrade():
thein.append("sig_" + theirname.lower())
theout.append("sig_" + variables.name.lower())
if len(thein) > 0:
tradestring = "\nmy " + ", ".join(theout) + "\n\nfor your " + ", ".join(thein) + "?\n\n(" + str(len(thein)) + " cards"
tradestring = "\nmy " + ", ".join(theout) + "\n\nfor your " + ", ".join(thein) + "?"
if randoms:
if randomstotal > 0:
tradestring += ", including " + str(randomstotal) + " randoms"
tradestring += ")\n\n<img src=\"https://colors-tcg.eu/cards/" + ".gif\"><img src=\"https://colors-tcg.eu/cards/".join(theout) + ".gif\">"
tradestring += "\n\n(" + str(len(thein)) + " cards, including " + str(randomstotal) + " randoms)"
elif len(thein) > 19:
tradestring += "\n\n(" + str(len(thein)) + " cards)"
tradestring += "\n\n<img src=\"https://colors-tcg.eu/cards/" + ".gif\"><img src=\"https://colors-tcg.eu/cards/".join(theout) + ".gif\">"
print(tradestring)
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) + "\"]}")