from nullptr.util import AppError from nullptr.analyzer import best_sell_market from random import choice def assign_hauler(c, s): if s.crew is None: raise AppError('ship has no crew') w = s.crew.site resources = s.crew.resources resource = choice(resources) m = best_sell_market(c,s.location.system, resource) s.log(f'assigning haul mission from {w} to {m}') c.captain.init_mission(s, 'haul') c.captain.smipa(s, 'site', w) c.captain.smipa(s, 'dest', m) c.captain.smipa(s, 'resources', resources)