Fix sand gather state machine
This commit is contained in:
parent
6489984640
commit
320f925fa1
1
game.py
1
game.py
|
@ -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
34
jobs.py
|
@ -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
|
||||
|
||||
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):
|
||||
s1 = self.lumberjack_states
|
||||
|
|
Loading…
Reference in New Issue
Block a user