Skip to content

Commit

Permalink
feat(farmer): imp socf_thread
Browse files Browse the repository at this point in the history
  • Loading branch information
hldh214 committed Mar 30, 2022
1 parent 130e7d4 commit e67ee73
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lokbot/farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ def _calc_distance(from_loc, to_loc):
return math.ceil(math.sqrt(math.pow(from_loc[1] - to_loc[1], 2) + math.pow(from_loc[2] - to_loc[2], 2)))

def _start_march(self, to_loc, march_troops, march_type=MARCH_TYPE_GATHER):
if not self.march_start_lock.acquire(blocking=False):
return

res = self.api.field_march_start({
'fromId': self.kingdom_enter.get('kingdom').get('fieldObjectId'),
'marchType': march_type,
Expand Down Expand Up @@ -532,18 +535,15 @@ def on_field_objects(data):
if self._is_march_limit_exceeded():
continue

if not self.march_start_lock.acquire(blocking=False):
return

code = each_obj.get('code')

try:
if code in (
OBJECT_CODE_CRYSTAL_MINE,
OBJECT_CODE_FARM,
OBJECT_CODE_LUMBER_CAMP,
OBJECT_CODE_QUARRY,
OBJECT_CODE_GOLD_MINE,
# OBJECT_CODE_FARM,
# OBJECT_CODE_LUMBER_CAMP,
# OBJECT_CODE_QUARRY,
# OBJECT_CODE_GOLD_MINE,
):
self._on_field_objects_gather(each_obj)

Expand Down

0 comments on commit e67ee73

Please sign in to comment.