Fix sand gather state machine

This commit is contained in:
Tanner Collin 2020-09-21 13:40:33 -06:00
parent 6489984640
commit 320f925fa1
2 changed files with 24 additions and 11 deletions

View File

@ -298,6 +298,7 @@ class Game:
reply = 'ok' reply = 'ok'
if command == 'inv': if command == 'inv':
print(self.g.inv)
inv_list = [] inv_list = []
for i in self.g.inv.values(): for i in self.g.inv.values():
if i.present: if i.present:

34
jobs.py
View File

@ -379,7 +379,7 @@ class CacheItemsStates:
return None return None
def init(self): def init(self):
num_stacks = len(self.g.inv) num_stacks = len([x for x in self.g.inv.values() if x.present])
print('inventory amount:', num_stacks) print('inventory amount:', num_stacks)
if num_stacks >= 27: if num_stacks >= 27:
self.state = self.find_cache_spot self.state = self.find_cache_spot
@ -473,8 +473,8 @@ class CacheItemsStates:
print('moving', slot) print('moving', slot)
inv_slot_num = slot_num - w_info.slot_diff #inv_slot_num = slot_num - w_info.slot_diff
self.g.inv.pop(inv_slot_num, None) #self.g.inv.pop(inv_slot_num, None)
self.g.item_lock = True self.g.item_lock = True
self.g.game.click_window(slot_num, 0, 1, slot) self.g.game.click_window(slot_num, 0, 1, slot)
@ -516,17 +516,29 @@ class JobStates:
return None return None
def gather_sand(self): def gather_sand(self):
s = self.gather_sand_states s1 = self.gather_sand_states
if s.state == s.idle: s2 = self.sleep_with_bed_states
s.state = s.init s3 = self.cache_items_states
elif s.state == s.done:
#s.state = s.init
self.prev_state = self.gather_sand if s1.state == s1.idle:
self.state = self.sleep_with_bed s1.state = s1.init
s2.state = s2.init
s3.state = s3.init
elif s1.state == s1.done:
if s2.state != s2.done:
s2.run()
return return
s.run() if s3.state != s3.done:
s3.run()
return
s1.state = s1.init
s2.state = s2.init
s3.state = s3.init
return
s1.run()
def lumberjack(self): def lumberjack(self):
s1 = self.lumberjack_states s1 = self.lumberjack_states