mission step priorities, fixed the store again

This commit is contained in:
Richard
2024-01-27 15:05:33 +01:00
parent f913d23c06
commit 5d47efdbda
10 changed files with 78 additions and 36 deletions

View File

@@ -11,6 +11,7 @@ from functools import partial
import logging
from nullptr.util import *
class MissionError(Exception):
pass
@@ -113,23 +114,24 @@ class Mission:
def step_done(self):
self.ship.log(f'mission {type(self).__name__} finished with balance {self.balance()}', 3)
def is_waiting(self):
def get_prio(self):
if self.next_step > time() or self.ship.cooldown > time() or self.ship.arrival > time():
return True
return 0
if self.wait_for is not None:
if self.wait_for():
p = int(self.wait_for())
if p > 0:
self.wait_for = None
return False
else:
return True
return False
return p
return 3
def is_finished(self):
return self.status() in ['done','error']
def is_ready(self):
return not self.is_waiting() and not self.is_finished()
if self.is_finished():
return 0
return self.get_prio()
def step(self):
steps = self.steps()
@@ -147,7 +149,8 @@ class Mission:
try:
result = handler()
except Exception as e:
logging.error(e, exc_info=True)
self.ship.log(fmtex(e))
self.ship.log(self.api.last_result)
self.status('error')
return
if type(next_step) == str:

View File

@@ -17,14 +17,16 @@ class HaulMission(BaseMission):
continue
if s.mission_status != 'load':
continue
return False
return True
return 0
return 5
def step_load(self):
pass
def cargo_full(self):
return self.ship.cargo_space() == 0
if self.ship.cargo_space() == 0:
return 5
return 0
@classmethod
def params(cls):