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'
if command == 'inv':
print(self.g.inv)
inv_list = []
for i in self.g.inv.values():
if i.present:

34
jobs.py
View File

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