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 = []
|
||||
hptc = []
|
||||
hpts = []
|
||||
randomch = []
|
||||
randomsp = []
|
||||
totalrandomch = 0
|
||||
totalrandomsp = 0
|
||||
randoms = input("Do they take randoms? [y/N] ")
|
||||
for thecard in theirwantlist:
|
||||
found = False
|
||||
for card in reversed(colors.cardlist):
|
||||
|
@ -1856,24 +1861,69 @@ def maketrade():
|
|||
if card["priority"] == 2:
|
||||
hptc.append(thecard)
|
||||
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 = []
|
||||
outc = []
|
||||
inc.extend(hpwc)
|
||||
outc.extend(lptc)
|
||||
if len(inc) > len(outc):
|
||||
outc.extend(mptc)
|
||||
if len(inc) > len(outc):
|
||||
outc.extend(hptc)
|
||||
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)
|
||||
if len(inc) > len(outc):
|
||||
outc.extend(hptc)
|
||||
else:
|
||||
inc.extend(mpwc)
|
||||
else:
|
||||
inc.extend(mpwc)
|
||||
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)
|
||||
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:
|
||||
inc.extend(lpwc)
|
||||
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):
|
||||
outc = outc[:len(inc)]
|
||||
ins = []
|
||||
|
@ -1881,29 +1931,73 @@ def maketrade():
|
|||
ins.extend(hpws)
|
||||
outs.extend(lpts)
|
||||
if len(ins) > len(outs):
|
||||
outs.extend(mpts)
|
||||
if len(ins) > len(outs):
|
||||
outs.extend(hpts)
|
||||
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)
|
||||
if len(ins) > len(outs):
|
||||
outs.extend(hpts)
|
||||
else:
|
||||
ins.extend(mpws)
|
||||
else:
|
||||
ins.extend(mpws)
|
||||
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)
|
||||
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:
|
||||
ins.extend(lpws)
|
||||
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):
|
||||
outs = outs[:len(ins)]
|
||||
thein = sorted(inc + ins)
|
||||
theout = sorted(outc + outs)
|
||||
if randoms:
|
||||
randomstotal = totalrandomch + totalrandomsp
|
||||
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\">")
|
||||
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: ")
|
||||
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue