major command staff restructure

Heads had to roll
This commit is contained in:
Richard
2024-02-09 15:52:30 +01:00
parent fb3b6162fc
commit 74ce884b05
21 changed files with 446 additions and 319 deletions

View File

@@ -25,8 +25,8 @@ def get_mission_class( mtype):
raise ValueError(f'invalid mission type {mtype}')
return types[mtype]
def create_mission(mtype, ship, store, api):
def create_mission(mtype, ship, c):
typ = get_mission_class(mtype)
m = typ(ship, store, api)
m = typ(ship, c)
return m

View File

@@ -5,7 +5,7 @@ from nullptr.models.contract import Contract
from nullptr.models.system import System
from nullptr.models.survey import Survey
from nullptr.models.ship import Ship
from nullptr.analyzer import Analyzer
from nullptr.analyzer import *
from time import time
from functools import partial
import logging
@@ -48,13 +48,13 @@ class Mission:
}
def __init__(self, ship, store, api):
def __init__(self, ship, context):
self.ship = ship
self.store = store
self.api = api
self.c = context
self.store = context.store
self.api = context.api
self.wait_for = None
self.next_step = 0
self.analyzer = Analyzer(self.store)
self.setup()
def setup(self):
@@ -263,15 +263,15 @@ class BaseMission(Mission):
loc = self.ship.location
loc_sys = loc.system
loc_jg = self.analyzer.get_jumpgate(loc_sys)
loc_jg = get_jumpgate(self.c, loc_sys)
loc_jg_wp = self.store.get(Waypoint, loc_jg.symbol)
dest_sys = dest.system
dest_jg = self.analyzer.get_jumpgate(dest_sys)
dest_jg = get_jumpgate(self.c, dest_sys)
if dest_sys == loc_sys:
result = self.analyzer.find_nav_path(loc, dest, self.ship.range())
result = find_nav_path(self.c, loc, dest, self.ship.range())
self.sts('traject', result)
return 'done' if len(result) == 0 else 'more'
path = self.analyzer.find_path(loc_sys, dest_sys)
path = find_jump_path(self.c, loc_sys, dest_sys)
result = []
if loc.symbol != loc_jg.symbol:
result.append(loc_jg_wp)

View File

@@ -1,5 +1,6 @@
from nullptr.missions.base import BaseMission, MissionParam
from nullptr.models.waypoint import Waypoint
from time import time
class SitMission(BaseMission):
def start_state(self):
@@ -14,10 +15,10 @@ class SitMission(BaseMission):
def steps(self):
return {
**self.travel_steps('to', 'dest', 'sit'),
'sit': (self.step_pass, 'done', self.wait_forever)
'sit': (self.step_sit, 'market'),
'market': (self.step_market, 'sit')
}
def step_sit(self):
self.next_step = time() + 15 * 60
def wait_forever(self):
return 0

View File

@@ -2,6 +2,8 @@ from nullptr.missions.base import BaseMission, MissionParam
from nullptr.models.waypoint import Waypoint
from nullptr.models.survey import Survey
from nullptr.models.contract import Contract
from nullptr.analyzer import find_deal
class TradeMission(BaseMission):
def start_state(self):
return 'travel-to'
@@ -11,7 +13,7 @@ class TradeMission(BaseMission):
cargo_space = self.ship.cargo_capacity - self.ship.cargo_units
smkt = self.store.get('Marketplace', self.st('site'))
dmkt = self.store.get('Marketplace', self.st('dest'))
resource = self.analyzer.find_deal(smkt, dmkt)
resource = find_deal(smkt, dmkt)
if resource is None:
return 'done'
price = smkt.buy_price(resource)