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

Commit

Permalink
Revert "feat(farmer): WIP: imp socf_thread"
Browse files Browse the repository at this point in the history
This reverts commit 64520f9.
  • Loading branch information
hldh214 committed Jun 30, 2023
1 parent 64520f9 commit 7d04c36
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions lokbot/farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,39 +757,31 @@ def on_field_enter(data):

self.socf_entered = True

def find_sequences(lst, length, step):
sequences = []
for i in range(0, len(lst) - length + 1, step):
sequence_list = [lst[i + j] for j in range(length)]
sequences.append(sequence_list)
return sequences

sio.connect(url, transports=["websocket"], headers=ws_headers)
logger.debug(f'entering field: {zones}')
sio.emit('/field/enter/v3', self.api.b64xor_enc({'token': self.token}))

while not self.socf_entered:
time.sleep(1)

# TODO: real 3x3 zone array
length = 9
step = 3
seq = find_sequences(zones, length, step)
for zone_ids in seq:
# 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]

if not sio.connected:
logger.warning('socf_thread disconnected, reconnecting')
raise tenacity.TryAgain()

enter_message = {'world': self.socf_world_id, 'zones': json.dumps(zone_ids, separators=(',', ':'))}
leave_message = {'world': self.socf_world_id, 'zones': json.dumps(zone_ids[0:step], separators=(',', ':'))}
encoded_enter_message = self.api.b64xor_enc(enter_message)
message = {'world': self.socf_world_id, 'zones': json.dumps(zone_ids, separators=(',', ':'))}
encoded_message = self.api.b64xor_enc(message)

sio.emit('/zone/enter/list/v4', encoded_enter_message)
sio.emit('/zone/enter/list/v4', encoded_message)
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)
sio.emit('/zone/leave/list/v2', leave_message)
sio.emit('/zone/leave/list/v2', message)
time.sleep(random.randint(4, 8))

logger.info('a loop is finished')
Expand Down

0 comments on commit 7d04c36

Please sign in to comment.