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,6 +508,7 @@ wantedlist = []
for deck in decklist: for deck in decklist:
if deck["priority"] < 4: if deck["priority"] < 4:
if deck["colour"] != "limited":
for number in numbers: for number in numbers:
if deck[number] == None: if deck[number] == None:
wantedcard = {} wantedcard = {}

View file

@ -1833,7 +1833,11 @@ def maketrade():
randomsp = [] randomsp = []
totalrandomch = 0 totalrandomch = 0
totalrandomsp = 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: for thecard in theirwantlist:
found = False found = False
for card in reversed(colors.cardlist): for card in reversed(colors.cardlist):
@ -1873,56 +1877,69 @@ def maketrade():
outc = [] outc = []
inc.extend(hpwc) inc.extend(hpwc)
outc.extend(lptc) outc.extend(lptc)
medchadded = False
if len(inc) > len(outc): if len(inc) > len(outc):
if randoms: if randoms:
randomch = random.shuffle(randomch) try:
random.shuffle(randomch)
neededrandomch = len(inc) - len(outc) neededrandomch = len(inc) - len(outc)
totalrandomch += neededrandomch totalrandomch += neededrandomch
try:
add = randomch[:neededrandomch] add = randomch[:neededrandomch]
randomch = randomch[neededrandomch:] randomch = randomch[neededrandomch:]
outc.extend(add) outc.extend(add)
trymediumch = True
except: except:
outc.extend(mptc) outc.extend(mptc)
medchadded = True
if len(inc) > len(outc): if len(inc) > len(outc):
trymediumch = False
outc.extend(hptc) outc.extend(hptc)
else: else:
inc.extend(mpwc) trymediumch = True
else: else:
outc.extend(mptc) outc.extend(mptc)
medchadded = True
if len(inc) > len(outc): if len(inc) > len(outc):
trymediumch = False
outc.extend(hptc) outc.extend(hptc)
else: else:
inc.extend(mpwc) trymediumch = True
else: if trymediumch:
inc.extend(mpwc) inc.extend(mpwc)
if len(inc) > len(outc): if len(inc) > len(outc):
if randoms: if randoms:
randomch = random.shuffle(randomch) try:
random.shuffle(randomch)
neededrandomch = len(inc) - len(outc) neededrandomch = len(inc) - len(outc)
totalrandomch += neededrandomch totalrandomch += neededrandomch
try:
add = randomch[:neededrandomch] add = randomch[:neededrandomch]
randomch = randomch[neededrandomch:] randomch = randomch[neededrandomch:]
outc.extend(add) outc.extend(add)
trylowch = True
except: except:
trylowch = False
if not medchadded:
outc.extend(mptc) outc.extend(mptc)
else: else:
trylowch = False
if not medchadded:
outc.extend(mptc) outc.extend(mptc)
else: else:
trylowch = True
if trylowch:
inc.extend(lpwc) inc.extend(lpwc)
if len(inc) > len(outc): if len(inc) > len(outc):
if randoms: if randoms:
randomch = random.shuffle(randomch) try:
random.shuffle(randomch)
neededrandomch = len(inc) - len(outc) neededrandomch = len(inc) - len(outc)
totalrandomch += neededrandomch totalrandomch += neededrandomch
try:
add = randomch[:neededrandomch] add = randomch[:neededrandomch]
randomch = randomch[neededrandomch:] randomch = randomch[neededrandomch:]
outc.extend(add) outc.extend(add)
except: except:
inc = inc[:len(outc)] pass
else: if len(inc) > len(outc):
inc = inc[:len(outc)] inc = inc[:len(outc)]
elif len(outc) > len(inc): elif len(outc) > len(inc):
outc = outc[:len(inc)] outc = outc[:len(inc)]
@ -1930,56 +1947,69 @@ def maketrade():
outs = [] outs = []
ins.extend(hpws) ins.extend(hpws)
outs.extend(lpts) outs.extend(lpts)
medspadded = False
if len(ins) > len(outs): if len(ins) > len(outs):
if randoms: if randoms:
randomsp = random.shuffle(randomsp) try:
random.shuffle(randomsp)
neededrandomsp = len(ins) - len(outs) neededrandomsp = len(ins) - len(outs)
totalrandomsp += neededrandomsp totalrandomsp += neededrandomsp
try:
add = randomsp[:neededrandomsp] add = randomsp[:neededrandomsp]
randomsp = randomsp[neededrandomsp:] randomsp = randomsp[neededrandomsp:]
outs.extend(add) outs.extend(add)
trymediumsp = True
except: except:
outs.extend(mpts) outs.extend(mpts)
medspadded = True
if len(ins) > len(outs): if len(ins) > len(outs):
trymediumsp = False
outs.extend(hpts) outs.extend(hpts)
else: else:
ins.extend(mpws) trymediumsp = True
else: else:
outs.extend(mpts) outs.extend(mpts)
medspadded = True
if len(ins) > len(outs): if len(ins) > len(outs):
trymediumsp = False
outs.extend(hpts) outs.extend(hpts)
else: else:
ins.extend(mpws) trymediumsp = True
else: if trymediumsp:
ins.extend(mpws) ins.extend(mpws)
if len(ins) > len(outs): if len(ins) > len(outs):
if randoms: if randoms:
randomsp = random.shuffle(randomsp) try:
random.shuffle(randomsp)
neededrandomsp = len(ins) - len(outs) neededrandomsp = len(ins) - len(outs)
totalrandomsp += neededrandomsp totalrandomsp += neededrandomsp
try:
add = randomsp[:neededrandomsp] add = randomsp[:neededrandomsp]
randomsp = randomsp[neededrandomsp:] randomsp = randomsp[neededrandomsp:]
outs.extend(add) outs.extend(add)
trylowsp = True
except: except:
trylowsp = False
if not medspadded:
outs.extend(mpts) outs.extend(mpts)
else: else:
trylowsp = False
if not medspadded:
outs.extend(mpts) outs.extend(mpts)
else: else:
trylowsp = True
if trylowsp:
ins.extend(lpws) ins.extend(lpws)
if len(ins) > len(outs): if len(ins) > len(outs):
if randoms: if randoms:
randomsp = random.shuffle(randomsp) try:
random.shuffle(randomsp)
neededrandomsp = len(ins) - len(outs) neededrandomsp = len(ins) - len(outs)
totalrandomsp += neededrandomsp totalrandomsp += neededrandomsp
try:
add = randomsp[:neededrandomsp] add = randomsp[:neededrandomsp]
randomsp = randomsp[neededrandomsp:] randomsp = randomsp[neededrandomsp:]
outs.extend(add) outs.extend(add)
except: except:
ins = ins[:len(outs)] pass
else: if len(ins) > len(outs):
ins = ins[:len(outs)] ins = ins[:len(outs)]
elif len(outs) > len(ins): elif len(outs) > len(ins):
outs = outs[:len(ins)] outs = outs[:len(ins)]
@ -1992,11 +2022,13 @@ def maketrade():
thein.append("sig_" + theirname.lower()) thein.append("sig_" + theirname.lower())
theout.append("sig_" + variables.name.lower()) theout.append("sig_" + variables.name.lower())
if len(thein) > 0: 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 randoms:
if randomstotal > 0: if randomstotal > 0:
tradestring += ", including " + str(randomstotal) + " randoms" tradestring += "\n\n(" + str(len(thein)) + " cards, 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\">" 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) print(tradestring)
tradeurl = input("\nPaste in comment URL: ") 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) + "\"]}") print("\n{\"event\":\"trade with " + theirname + "\",\"date\":datetime.datetime(" + datetime.datetime.now().strftime("%Y,%-m,%-d") + "),\"url\":\"" + tradeurl + "\",\"lost\":[\"" + "\",\"".join(theout) + "\"],\"pend\":[\"" + "\",\"".join(thein) + "\"]}")