from nullptr.util import * from nullptr.analyzer import find_gas, find_metal class GeneralError(AppError): pass class General: def __init__(self, context): self.store = context.store self.api = context.api self.c = context agents = self.store.all('Agent') self.agent = next(agents, None) self.phases = { 'init': self.phase_startup, 'probes': self.phase_probes, 'trade': self.phase_trade, 'mine': self.phase_mine, 'siphon': self.phase_siphon, 'rampup': self.phase_rampup, 'gate': self.phase_gate } def setup(self): self.create_default_crews() def find_shipyard(self, stype): for shipyard in self.store.all('Shipyard'): if stype in shipyard.types: return stype return None def tick(self): phase = self.agent.phase if phase not in self.phases: raise GeneralError('Invalid phase') hdl = self.phases[phase] new_phase = hdl() if new_phase: self.agent.phase = new_phase def phase_startup(self): # * first pricing info # * probe at shipyard that sells probes ag = self.agent.symbol command = self.store.get('Ship', f'{ag}-1') probe = self.store.get('Ship', f'{ag}-2') command.role = 'probe' probe.role = 'sitter' def phase_probes(self): # * probes on all markets pass def phase_trade(self): # 20? traders pass def phase_mine(self): # metal mining crew pass def phase_siphon(self): # siphon crew pass def phase_rampup(self): # stimulate markets for gate building pass def phase_gate(self): # build the gate pass def create_default_crews(self): system = self.api.agent.headquarters.system gas_w = find_gas(self.c, system) metal_w = find_metal(self.c, system) metal = self.store.get('Crew', 'METAL', create=True) metal.site = metal_w metal.resources = ['COPPER_ORE','IRON_ORE','ALUMINUM_ORE'] gas = self.store.get('Crew', 'GAS', create=True) gas.site = gas_w gas.resources = ['HYDROCARBON','LIQUID_HYDROGEN','LIQUID_NITROGEN'] return [gas, metal]