Fix random with allies
This commit is contained in:
parent
86c3b082f6
commit
ded189b165
16
LeekBots.py
16
LeekBots.py
|
@ -300,10 +300,15 @@ class Pool:
|
||||||
leek.raiseError('Probably, no more fights')
|
leek.raiseError('Probably, no more fights')
|
||||||
|
|
||||||
if options['selection-mode'] == 'random':
|
if options['selection-mode'] == 'random':
|
||||||
opid = random.choice([
|
oplist = [
|
||||||
x['id'] for x in opponents
|
x['id'] for x in opponents
|
||||||
if force or not x['id'] in leeksids
|
if force or not x['id'] in leeksids
|
||||||
])
|
]
|
||||||
|
|
||||||
|
if len(oplist) < 1:
|
||||||
|
leek.raiseError(
|
||||||
|
'Really? All your opponnents are allies')
|
||||||
|
opid = random.choice(oplist)
|
||||||
else:
|
else:
|
||||||
opid = None
|
opid = None
|
||||||
if options['selection-mode'] == 'worst':
|
if options['selection-mode'] == 'worst':
|
||||||
|
@ -316,10 +321,9 @@ class Pool:
|
||||||
if (options['selection-mode'] == 'worst' and score < opscore) or (not options['selection-mode'] == 'worst' and score > opscore):
|
if (options['selection-mode'] == 'worst' and score < opscore) or (not options['selection-mode'] == 'worst' and score > opscore):
|
||||||
opid = x['id']
|
opid = x['id']
|
||||||
opscore = score
|
opscore = score
|
||||||
|
if opid is None:
|
||||||
if opid is None:
|
leek.raiseError(
|
||||||
leek.raiseError(
|
'Really? All your opponnents are allies')
|
||||||
'Really? All your opponnents are allies')
|
|
||||||
|
|
||||||
print('https://leekwars.com/fight/{0}'.format(
|
print('https://leekwars.com/fight/{0}'.format(
|
||||||
leek.fight(opid)))
|
leek.fight(opid)))
|
||||||
|
|
Reference in New Issue