me
/
LeekBots
Archived
1
0
Fork 0

Fix selection-mode

This commit is contained in:
sheychen 2018-06-16 12:37:30 +02:00
parent 46de89c0fe
commit c941cdec83
1 changed files with 28 additions and 20 deletions

View File

@ -197,22 +197,24 @@ class Farmers:
if len(opponents) < 1: if len(opponents) < 1:
leek.raiseError('Probably, no more farmer fights') leek.raiseError('Probably, no more farmer fights')
#if options['selection-mode'] == 'random': if options['selection-mode'] == 'random':
opid = random.choice(opponents)['id'] opid = random.choice(opponents)['id']
#else: else:
# opid = None opid = None
# if options['selection-mode'] == 'worst': if options['selection-mode'] == 'worst':
# optalent = 20000000 optalent = 20000000
# else: else:
# optalent = 0 optalent = 0
# for x in opponents: for x in opponents:
# if ( if (
# options['selection-mode'] == 'worst' options['selection-mode'] == 'worst'
# and optalent < x['talent'] and optalent > x['talent']
# ) or (not options['selection-mode'] == 'worst' ) or (
# and optalent > x['talent']): not options['selection-mode'] == 'worst'
# opid = x['id'] and optalent < x['talent']
# optalent = x['talent'] ):
opid = x['id']
optalent = x['talent']
print('https://leekwars.com/fight/{0}'.format( print('https://leekwars.com/fight/{0}'.format(
farmer.fight(opid))) farmer.fight(opid)))
@ -367,7 +369,13 @@ class Pool:
for x in opponents: for x in opponents:
if force or not x['id'] in leeksids: if force or not x['id'] in leeksids:
score = x['level'] * x['talent'] score = x['level'] * x['talent']
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:
@ -645,7 +653,7 @@ class Pool:
if leek.id in cleeks: if leek.id in cleeks:
cid = composition['id'] cid = composition['id']
for _ in range(params[0] for _ in range(params[0]
if type(params[0]) is int else 20): if type(params[0]) is int else 20):
opponents = leek.getCompositionOpponents(cid) opponents = leek.getCompositionOpponents(cid)
if len(opponents) < 1: if len(opponents) < 1:
leek.raiseError('Probably, no more team fights') leek.raiseError('Probably, no more team fights')
@ -661,10 +669,10 @@ class Pool:
for x in opponents: for x in opponents:
if ( if (
options['selection-mode'] == 'worst' options['selection-mode'] == 'worst'
and optalent < x['talent'] and optalent > x['talent']
) or ( ) or (
not options['selection-mode'] == 'worst' not options['selection-mode'] == 'worst'
and optalent > x['talent'] and optalent < x['talent']
): ):
opid = x['id'] opid = x['id']
optalent = x['talent'] optalent = x['talent']