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

Commit

Permalink
feat(farmer): add grace for socf_thread
Browse files Browse the repository at this point in the history
Signed-off-by: hldh214 <[email protected]>
  • Loading branch information
hldh214 committed Jul 3, 2023
1 parent 7d04c36 commit d990303
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lokbot/farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,14 @@ def on_field_enter(data):
while not self.socf_entered:
time.sleep(1)

# TODO: change this to 9zones for enter and 3zones for leave
step = 9
for i in range(0, len(zones), step):
zone_ids = zones[i:i + step]
grace = 7 # 9 times enter-leave action will cause ban
for key, value in enumerate(range(0, len(zones), step)):
if key >= grace:
logger.info('socf_thread grace exceeded, break')
break

zone_ids = zones[value:value + step]

if not sio.connected:
logger.warning('socf_thread disconnected, reconnecting')
Expand All @@ -780,9 +784,8 @@ def on_field_enter(data):
self.field_object_processed = False
logger.debug(f'entering zone: {zone_ids} and waiting for processing')
while not self.field_object_processed:
time.sleep(4)
time.sleep(1)
sio.emit('/zone/leave/list/v2', message)
time.sleep(random.randint(4, 8))

logger.info('a loop is finished')
sio.disconnect()
Expand Down Expand Up @@ -1196,6 +1199,7 @@ def wall_repair(self):
durability = wall_info.get('wall', {}).get('durability')
last_repair_date = wall_info.get('wall', {}).get('lastRepairDate')

# todo: seems `lastRepairDate` disappeared, need to check
if not last_repair_date:
return

Expand Down

0 comments on commit d990303

Please sign in to comment.