Another big refactoring
This commit is contained in:
parent
61b5c8493e
commit
68c457964a
10 changed files with 79 additions and 83 deletions
16
lib/ships.js
16
lib/ships.js
|
@ -12,12 +12,14 @@ export async function extract(ctx) {
|
|||
default: // yet unhandled error
|
||||
throw response;
|
||||
}
|
||||
} else {
|
||||
await api.sleep(response.data.cooldown.remainingSeconds*1000);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function dock(ctx) {
|
||||
const response = await api.send({endpoint: `/my/ships/${ctx.ship}/dock`, method: 'POST'});
|
||||
const response = await api.send({endpoint: `/my/ships/${ctx.symbol}/dock`, method: 'POST'});
|
||||
if (response.error !== undefined) {
|
||||
switch(response.error.code) {
|
||||
case 4214: // ship is in transit
|
||||
|
@ -48,7 +50,17 @@ export async function negotiate(ctx) {
|
|||
}
|
||||
|
||||
export async function orbit(ctx) {
|
||||
return await api.send({endpoint: `/my/ships/${ctx.ship}/orbit`, method: 'POST'});
|
||||
const response = await api.send({endpoint: `/my/ships/${ctx.symbol}/orbit`, method: 'POST'});
|
||||
if (response.error !== undefined) {
|
||||
switch(response.error.code) {
|
||||
case 4214: // ship is in transit
|
||||
await api.sleep(response.error.data.secondsToArrival * 1000);
|
||||
return orbit(ctx);
|
||||
default: // yet unhandled error
|
||||
throw response;
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function purchase(ctx) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue