-
Notifications
You must be signed in to change notification settings - Fork 0
/
mining-drone.ts
29 lines (28 loc) · 1.15 KB
/
mining-drone.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { TradeSymbol } from '../../../api'
import { log } from '../../logging/configure-logging'
import { ShipEntity } from '../ship/ship.entity'
import { IWaypoint } from '../status/actions/IWaypoint'
import { getActor } from '../status/actions/getActor'
import { AgentEntity } from '../status/agent.entity'
import { decisionMaker } from '../status/decisionMaker'
import { WaypointEntity } from '../status/waypoint.entity'
export const miningDroneActorFactory = (
miningDrone: ShipEntity,
agent: AgentEntity,
act: Awaited<ReturnType<typeof getActor>>,
waypoints: WaypointEntity[],
miningLocation: IWaypoint,
keep: TradeSymbol[],
) =>
decisionMaker(miningDrone, false, agent, act, async (ship: ShipEntity, agent: AgentEntity) => {
await act.refuelShip(ship)
await act.jettisonUnwanted(miningDrone, keep)
if (ship.nav.waypointSymbol !== miningLocation.symbol) {
await act.navigateShip(ship, miningLocation, waypoints)
} else if (ship.cargo.units < ship.cargo.capacity) {
await act.beginMining(ship, keep)
} else {
log.info('ship', `${ship.label} will wait 1 minutes, cargo hold full`)
await act.wait(1000 * 60)
}
})