Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
feat(farmer): imp on_field_objects()
Browse files Browse the repository at this point in the history
Signed-off-by: hldh214 <[email protected]>
  • Loading branch information
hldh214 committed Aug 22, 2023
1 parent e8fa9e5 commit 8f78d5c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lokbot/farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def __init__(self, token, captcha_solver_config):
self.kingdom_tasks = []
self.zones = []
self.available_dragos = self._get_available_dragos()
self.drago_action_point = self.kingdom_enter.get('kingdom').get('dragoActionPoint', {}).get('value', 0)

@staticmethod
def calc_time_diff_in_seconds(expected_ended):
Expand Down Expand Up @@ -605,10 +606,6 @@ def _on_field_objects_gather(self, each_obj):
return

if each_obj.get('code') == OBJECT_CODE_DRAGON_SOUL_CAVERN:
if not self.available_dragos:
logger.warning('No available dragos')
return

self._start_march(to_loc, march_troops, MARCH_TYPE_GATHER, self.available_dragos[0]['_id'])
return

Expand Down Expand Up @@ -780,9 +777,17 @@ def on_field_objects(data):
for chat_channel in share_to.get('chat_channels'):
self.api.chat_new(chat_channel, CHAT_TYPE_LOC, f'Lv.{level}?fo_{code}', {'loc': loc})

if code == OBJECT_CODE_DRAGON_SOUL_CAVERN:
if self.drago_action_point < 1:
logger.info(f'no_drago_action_point, ignore: {each_obj}')
continue
if not self.available_dragos:
logger.info(f'not_available_drago, ignore: {each_obj}')
continue

level_whitelist = level_whitelist[0]
if level_whitelist and level not in level_whitelist:
logger.info(f'ignore: {each_obj}, level not in whitelist: {level_whitelist}')
logger.info(f'level not in whitelist, ignore: {each_obj}')
continue

try:
Expand Down

0 comments on commit 8f78d5c

Please sign in to comment.