from nullptr.missions.base import BaseMission, MissionParam from nullptr.models.waypoint import Waypoint class HaulMission(BaseMission): def start_state(self): return 'travel-to' def step_turn(self): self.ship.log('starting haul load') def wait_turn(self): for s in self.store.all('Ship'): if s.mission != 'haul': continue if s.location != self.ship.location: continue if s.mission_state['dest'] != self.st('dest'): continue if s.mission_status != 'load': continue return 0 return 5 def step_load(self): pass def cargo_full(self): if self.ship.cargo_space() == 0: return 5 return 0 @classmethod def params(cls): return { 'site': MissionParam(Waypoint, True), 'dest': MissionParam(Waypoint, True), 'resources': MissionParam(list, True) } def steps(self): return { **self.travel_steps('to', 'site', 'wait-turn'), 'wait-turn': (self.step_turn, 'load', self.wait_turn), 'load': (self.step_load, 'travel-back', self.cargo_full), **self.travel_steps('back', 'dest', 'dock-dest'), 'dock-dest': (self.step_dock, 'unload'), 'unload': (self.step_sell, { 'more': 'unload', 'done': 'market-dest' }), 'market-dest': (self.step_market, 'report'), 'report': (self.step_done, 'done') }