Add selection-mode in fights
This commit is contained in:
parent
a11883eb26
commit
86c3b082f6
27
LeekBots.py
27
LeekBots.py
|
@ -299,12 +299,21 @@ class Pool:
|
||||||
if len(opponents) < 1:
|
if len(opponents) < 1:
|
||||||
leek.raiseError('Probably, no more fights')
|
leek.raiseError('Probably, no more fights')
|
||||||
|
|
||||||
|
if options['selection-mode'] == 'random':
|
||||||
|
opid = random.choice([
|
||||||
|
x['id'] for x in opponents
|
||||||
|
if force or not x['id'] in leeksids
|
||||||
|
])
|
||||||
|
else:
|
||||||
opid = None
|
opid = None
|
||||||
|
if options['selection-mode'] == 'worst':
|
||||||
opscore = 20000000
|
opscore = 20000000
|
||||||
|
else:
|
||||||
|
opscore = 0
|
||||||
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 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
|
||||||
|
|
||||||
|
@ -563,6 +572,7 @@ class Pool:
|
||||||
|
|
||||||
def teamFight(params, options):
|
def teamFight(params, options):
|
||||||
try:
|
try:
|
||||||
|
random.seed()
|
||||||
leek = Pool.get(Settings(options), Pool.parse(options))[0]
|
leek = Pool.get(Settings(options), Pool.parse(options))[0]
|
||||||
team = leek.farmer.data['team']['id']
|
team = leek.farmer.data['team']['id']
|
||||||
for composition in leek.farmer.getTeam(team)['compositions']:
|
for composition in leek.farmer.getTeam(team)['compositions']:
|
||||||
|
@ -575,10 +585,22 @@ class Pool:
|
||||||
if len(opponents) < 1:
|
if len(opponents) < 1:
|
||||||
leek.raiseError('Probably, no more team fights')
|
leek.raiseError('Probably, no more team fights')
|
||||||
|
|
||||||
|
if options['selection-mode'] == 'random':
|
||||||
|
opid = random.choice(opponents)['id']
|
||||||
|
else:
|
||||||
opid = None
|
opid = None
|
||||||
|
if options['selection-mode'] == 'worst':
|
||||||
optalent = 20000000
|
optalent = 20000000
|
||||||
|
else:
|
||||||
|
optalent = 0
|
||||||
for x in opponents:
|
for x in opponents:
|
||||||
if x['talent'] < optalent:
|
if (
|
||||||
|
options['selection-mode'] == 'worst'
|
||||||
|
and optalent < x['talent']
|
||||||
|
) or (
|
||||||
|
not options['selection-mode'] == 'worst'
|
||||||
|
and optalent > x['talent']
|
||||||
|
):
|
||||||
opid = x['id']
|
opid = x['id']
|
||||||
optalent = x['talent']
|
optalent = x['talent']
|
||||||
|
|
||||||
|
@ -781,6 +803,7 @@ class Leek:
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
CommandTree()\
|
CommandTree()\
|
||||||
.addOption('pool', ['p', '-pool'], {'name': 'pool', 'optional': True, 'default': 'main'})\
|
.addOption('pool', ['p', '-pool'], {'name': 'pool', 'optional': True, 'default': 'main'})\
|
||||||
|
.addOption('selection-mode', ['sm', '-selection-mode'], {'name': 'selection mode', 'optional': True, 'list': ['random', 'best', 'worst'], 'default': 'worst'})\
|
||||||
.addOption('sleep', ['s', '-sleep'], {'name': 'sleep time', 'optional': True, 'type': int, 'min': 0, 'default': 1})\
|
.addOption('sleep', ['s', '-sleep'], {'name': 'sleep time', 'optional': True, 'type': int, 'min': 0, 'default': 1})\
|
||||||
.addOption('path', ['-path'], {'name': 'config path', 'optional': True, 'default': '*/LeekBots.json'})\
|
.addOption('path', ['-path'], {'name': 'config path', 'optional': True, 'default': '*/LeekBots.json'})\
|
||||||
.addCommand('farmers list', 'list all farmers', Farmers.list, [{'name': 'mode', 'optional': True, 'list': [None, 'infos', 'ais', 'stuff', 'leeks']}])\
|
.addCommand('farmers list', 'list all farmers', Farmers.list, [{'name': 'mode', 'optional': True, 'list': [None, 'infos', 'ais', 'stuff', 'leeks']}])\
|
||||||
|
|
Reference in New Issue