Allow randoms in trades
This commit is contained in:
parent
2aaf990cdf
commit
256beac9b7
1 changed files with 107 additions and 13 deletions
120
tools.py
120
tools.py
|
@ -1829,6 +1829,11 @@ def maketrade():
|
||||||
mpts = []
|
mpts = []
|
||||||
hptc = []
|
hptc = []
|
||||||
hpts = []
|
hpts = []
|
||||||
|
randomch = []
|
||||||
|
randomsp = []
|
||||||
|
totalrandomch = 0
|
||||||
|
totalrandomsp = 0
|
||||||
|
randoms = input("Do they take randoms? [y/N] ")
|
||||||
for thecard in theirwantlist:
|
for thecard in theirwantlist:
|
||||||
found = False
|
found = False
|
||||||
for card in reversed(colors.cardlist):
|
for card in reversed(colors.cardlist):
|
||||||
|
@ -1856,24 +1861,69 @@ def maketrade():
|
||||||
if card["priority"] == 2:
|
if card["priority"] == 2:
|
||||||
hptc.append(thecard)
|
hptc.append(thecard)
|
||||||
found = True
|
found = True
|
||||||
|
if randoms:
|
||||||
|
for card in colors.cardlist:
|
||||||
|
if card["priority"] == 4:
|
||||||
|
if card not in theirwantlist:
|
||||||
|
if card["colour"] == "special":
|
||||||
|
randomsp.append(card["name"])
|
||||||
|
else:
|
||||||
|
randomch.append(card["name"])
|
||||||
inc = []
|
inc = []
|
||||||
outc = []
|
outc = []
|
||||||
inc.extend(hpwc)
|
inc.extend(hpwc)
|
||||||
outc.extend(lptc)
|
outc.extend(lptc)
|
||||||
if len(inc) > len(outc):
|
if len(inc) > len(outc):
|
||||||
outc.extend(mptc)
|
if randoms:
|
||||||
if len(inc) > len(outc):
|
randomch = random.shuffle(randomch)
|
||||||
outc.extend(hptc)
|
neededrandomch = len(inc) - len(outc)
|
||||||
|
totalrandomch += neededrandomch
|
||||||
|
try:
|
||||||
|
add = randomch[:neededrandomch]
|
||||||
|
randomch = randomch[neededrandomch:]
|
||||||
|
outc.extend(add)
|
||||||
|
except:
|
||||||
|
outc.extend(mptc)
|
||||||
|
if len(inc) > len(outc):
|
||||||
|
outc.extend(hptc)
|
||||||
|
else:
|
||||||
|
inc.extend(mpwc)
|
||||||
else:
|
else:
|
||||||
inc.extend(mpwc)
|
outc.extend(mptc)
|
||||||
|
if len(inc) > len(outc):
|
||||||
|
outc.extend(hptc)
|
||||||
|
else:
|
||||||
|
inc.extend(mpwc)
|
||||||
else:
|
else:
|
||||||
inc.extend(mpwc)
|
inc.extend(mpwc)
|
||||||
if len(inc) > len(outc):
|
if len(inc) > len(outc):
|
||||||
outc.extend(mptc)
|
if randoms:
|
||||||
|
randomch = random.shuffle(randomch)
|
||||||
|
neededrandomch = len(inc) - len(outc)
|
||||||
|
totalrandomch += neededrandomch
|
||||||
|
try:
|
||||||
|
add = randomch[:neededrandomch]
|
||||||
|
randomch = randomch[neededrandomch:]
|
||||||
|
outc.extend(add)
|
||||||
|
except:
|
||||||
|
outc.extend(mptc)
|
||||||
|
else:
|
||||||
|
outc.extend(mptc)
|
||||||
else:
|
else:
|
||||||
inc.extend(lpwc)
|
inc.extend(lpwc)
|
||||||
if len(inc) > len(outc):
|
if len(inc) > len(outc):
|
||||||
inc = 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)]
|
||||||
elif len(outc) > len(inc):
|
elif len(outc) > len(inc):
|
||||||
outc = outc[:len(inc)]
|
outc = outc[:len(inc)]
|
||||||
ins = []
|
ins = []
|
||||||
|
@ -1881,29 +1931,73 @@ def maketrade():
|
||||||
ins.extend(hpws)
|
ins.extend(hpws)
|
||||||
outs.extend(lpts)
|
outs.extend(lpts)
|
||||||
if len(ins) > len(outs):
|
if len(ins) > len(outs):
|
||||||
outs.extend(mpts)
|
if randoms:
|
||||||
if len(ins) > len(outs):
|
randomsp = random.shuffle(randomsp)
|
||||||
outs.extend(hpts)
|
neededrandomsp = len(ins) - len(outs)
|
||||||
|
totalrandomsp += neededrandomsp
|
||||||
|
try:
|
||||||
|
add = randomsp[:neededrandomsp]
|
||||||
|
randomsp = randomsp[neededrandomsp:]
|
||||||
|
outs.extend(add)
|
||||||
|
except:
|
||||||
|
outs.extend(mpts)
|
||||||
|
if len(ins) > len(outs):
|
||||||
|
outs.extend(hpts)
|
||||||
|
else:
|
||||||
|
ins.extend(mpws)
|
||||||
else:
|
else:
|
||||||
ins.extend(mpws)
|
outs.extend(mpts)
|
||||||
|
if len(ins) > len(outs):
|
||||||
|
outs.extend(hpts)
|
||||||
|
else:
|
||||||
|
ins.extend(mpws)
|
||||||
else:
|
else:
|
||||||
ins.extend(mpws)
|
ins.extend(mpws)
|
||||||
if len(ins) > len(outs):
|
if len(ins) > len(outs):
|
||||||
outs.extend(mpts)
|
if randoms:
|
||||||
|
randomsp = random.shuffle(randomsp)
|
||||||
|
neededrandomsp = len(ins) - len(outs)
|
||||||
|
totalrandomsp += neededrandomsp
|
||||||
|
try:
|
||||||
|
add = randomsp[:neededrandomsp]
|
||||||
|
randomsp = randomsp[neededrandomsp:]
|
||||||
|
outs.extend(add)
|
||||||
|
except:
|
||||||
|
outs.extend(mpts)
|
||||||
|
else:
|
||||||
|
outs.extend(mpts)
|
||||||
else:
|
else:
|
||||||
ins.extend(lpws)
|
ins.extend(lpws)
|
||||||
if len(ins) > len(outs):
|
if len(ins) > len(outs):
|
||||||
ins = 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)]
|
||||||
elif len(outs) > len(ins):
|
elif len(outs) > len(ins):
|
||||||
outs = outs[:len(ins)]
|
outs = outs[:len(ins)]
|
||||||
thein = sorted(inc + ins)
|
thein = sorted(inc + ins)
|
||||||
theout = sorted(outc + outs)
|
theout = sorted(outc + outs)
|
||||||
|
if randoms:
|
||||||
|
randomstotal = totalrandomch + totalrandomsp
|
||||||
addsigs = input("Add signatures? [y/N] ")
|
addsigs = input("Add signatures? [y/N] ")
|
||||||
if addsigs == "y":
|
if addsigs == "y":
|
||||||
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:
|
||||||
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\">")
|
tradestring = "\nmy " + ", ".join(theout) + "\n\nfor your " + ", ".join(thein) + "?\n\n(" + str(len(thein)) + " cards"
|
||||||
|
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\">"
|
||||||
|
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) + "\"]}")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue