Movement printing and Results, state, state reset.

This commit is contained in:
Steffen Illium
2023-11-16 17:08:08 +01:00
parent 7f1d99fe18
commit 6c27aa8eaf
11 changed files with 45 additions and 21 deletions

View File

@@ -19,5 +19,5 @@ class DestAction(Action):
state.print(f'{entity.name} just waited at {entity.pos}')
else:
valid = c.NOT_VALID
state.print(f'{entity.name} just tried to do_wait_action do_wait_action at {entity.pos} but failed')
state.print(f'{entity.name} just tried to "do_wait_action" at {entity.pos} but failed')
return self.get_result(valid, entity)

View File

@@ -70,6 +70,10 @@ class Inventory(IsBoundMixin, Collection):
def set_collection(self, collection):
self._collection = collection
def clear_temp_state(self):
# Entites need this, but inventories have no state....
pass
class Inventories(Objects):
_entity = Inventory

View File

@@ -26,16 +26,22 @@ class Maintainer(Entity):
self._last_serviced = 'None'
def tick(self, state):
self.clear_temp_state
if found_objective := h.get_first(state[self.objective].by_pos(self.pos)):
if found_objective.name != self._last_serviced:
self.action.do(self, state)
self._last_serviced = found_objective.name
else:
action = self.get_move_action(state)
return action.do(self, state)
result = action.do(self, state)
else:
action = self.get_move_action(state)
return action.do(self, state)
result = action.do(self, state)
self.set_state(result)
return result
def set_state(self, action_result):
self._status = action_result
def get_move_action(self, state) -> Action:
if self._path is None or not len(self._path):