major command staff restructure
Heads had to roll
This commit is contained in:
20
nullptr/roles/__init__.py
Normal file
20
nullptr/roles/__init__.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from nullptr.roles.trader import assign_trader
|
||||
from nullptr.roles.probe import assign_probe
|
||||
from nullptr.roles.siphon import assign_siphon
|
||||
from nullptr.roles.hauler import assign_hauler
|
||||
from nullptr.roles.surveyor import assign_surveyor
|
||||
from nullptr.roles.miner import assign_miner
|
||||
|
||||
def assign_mission(c, s):
|
||||
if s.role == 'trader':
|
||||
assign_trader(c, s)
|
||||
elif s.role == 'probe':
|
||||
assign_probe(c, s)
|
||||
elif s.role == 'siphon':
|
||||
assign_siphon(c, s)
|
||||
elif s.role == 'hauler':
|
||||
assign_hauler(c, s)
|
||||
elif s.role == 'surveyor':
|
||||
assign_surveyor(c, s)
|
||||
elif s.role == 'miner':
|
||||
assign_miner(c, s)
|
||||
16
nullptr/roles/hauler.py
Normal file
16
nullptr/roles/hauler.py
Normal file
@@ -0,0 +1,16 @@
|
||||
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)
|
||||
11
nullptr/roles/miner.py
Normal file
11
nullptr/roles/miner.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from nullptr.util import AppError
|
||||
|
||||
def assign_miner(c, s):
|
||||
if s.crew is None:
|
||||
raise AppError('ship has no crew')
|
||||
w = s.crew.site
|
||||
resources = s.crew.resources
|
||||
c.captain.init_mission(s, 'mine')
|
||||
c.captain.smipa(s, 'site', w)
|
||||
c.captain.smipa(s, 'resources', resources)
|
||||
|
||||
15
nullptr/roles/probe.py
Normal file
15
nullptr/roles/probe.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from nullptr.analyzer import solve_tsp
|
||||
from random import randrange
|
||||
|
||||
def assign_probe(c, s):
|
||||
system = s.location.system
|
||||
m = [m.waypoint for m in c.store.all_members(system, 'Marketplace')]
|
||||
m = solve_tsp(c, m)
|
||||
hops = [w.symbol for w in m]
|
||||
start_hop = randrange(0, len(hops))
|
||||
s.log(f'Assigning {s} to probe {len(hops)} starting at {hops[start_hop]}')
|
||||
|
||||
c.captain.init_mission(s, 'probe')
|
||||
c.captain.smipa(s, 'hops', hops)
|
||||
c.captain.smipa(s, 'next-hop', start_hop)
|
||||
|
||||
8
nullptr/roles/siphon.py
Normal file
8
nullptr/roles/siphon.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from nullptr.util import AppError
|
||||
|
||||
def assign_siphon(c, s):
|
||||
if s.crew is None:
|
||||
raise AppError('ship has no crew')
|
||||
w = s.crew.site
|
||||
c.captain.init_mission(s, 'siphon')
|
||||
c.captain.smipa(s, 'site', w)
|
||||
10
nullptr/roles/surveyor.py
Normal file
10
nullptr/roles/surveyor.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from nullptr.util import AppError
|
||||
|
||||
|
||||
def assign_surveyor(c, s):
|
||||
if s.crew is None:
|
||||
raise AppError('ship has no crew')
|
||||
w = s.crew.site
|
||||
c.init_mission(s, 'survey')
|
||||
c.smipa(s, 'site', w)
|
||||
|
||||
14
nullptr/roles/trader.py
Normal file
14
nullptr/roles/trader.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from nullptr.analyzer import find_trade
|
||||
|
||||
|
||||
def assign_trader(c, s):
|
||||
t = find_trade(c, s.location.system)
|
||||
if t is None:
|
||||
print(f"No trade for {s} found. Idling")
|
||||
c.captain.init_mission(s,'idle')
|
||||
c.captain.smipa(s, 'seconds', 600)
|
||||
return
|
||||
s.log(f'assigning {s} to deliver {t.resource} from {t.source} to {t.dest} at a margin of {t.margin}')
|
||||
c.captain.init_mission(s, 'trade')
|
||||
c.captain.smipa(s, 'site', t.source)
|
||||
c.captain.smipa(s, 'dest', t.dest)
|
||||
Reference in New Issue
Block a user