me
/
LeekBots
Archived
1
0
Fork 0

Fix random with allies

This commit is contained in:
sheychen 2018-02-14 07:28:25 +01:00
parent 86c3b082f6
commit ded189b165
1 changed files with 10 additions and 6 deletions

View File

@ -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)))