1
0
Fork 0

[node] dependencies update and commit old files

This commit is contained in:
Julien Dessaux 2025-02-18 00:18:16 +01:00
parent 3656b87b86
commit fd06283b8d
Signed by: adyxax
GPG key ID: F92E51B86E07177E
8 changed files with 323 additions and 1135 deletions

View file

@ -17,6 +17,7 @@ enum states {
start_running_contracts_with_the_command_ship = 0,
visit_all_shipyards,
visit_all_markets,
send_probes_to_all_shipyards,
}
export async function run(): Promise<void> {
@ -41,6 +42,8 @@ export async function run(): Promise<void> {
await visit_all_markets();
state++;
continue;
case states.send_probes_to_all_shipyards:
await send_probes_to_all_shipyards();
state++;
continue;
default:
@ -54,6 +57,33 @@ export async function run(): Promise<void> {
}
}
async function send_probes_to_all_shipyards(): Promise<void> {
outer: while(true) {
const shipyardWaypoints = await trait(getShips()[0].nav.systemSymbol, 'SHIPYARD');
let candidates: Array<Waypoint> = [];
for (const w of shipyardWaypoints) {
if (is_there_a_ship_at_this_waypoint(w)) continue;
candidates.push(w);
}
if (candidates.length === 0) return;
// if we do not have enough probes, we buy some
if (candidates.length - 1 >= getShips().length - 2) {
const probe = await purchaseShip('SHIP_PROBE');
const probeWaypoint = await waypoint(probe.nav.waypointSymbol);
await probe.navigate(candidates[0]);
continue outer;
}
// otherwise we find the closest ones from a shipyard
const probes = getShips().slice(2);
let probesWaypoints: Array<Waypoint> = [];
for (const p of probes) {
probesWaypoints.push(await waypoint(p.nav.waypointSymbol));
}
const next = sortByDistanceFrom(candidates[0], probesWaypoints)[0].data;
await probes.filter(p => p.nav.waypointSymbol === next.symbol)[0].navigate(candidates[0]);
}
}
async function visit_all_markets(): Promise<void> {
if (await are_we_done_visiting_all_markets()) return;
// send all our probes except the starting one to map the system's markets