-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfind_mounts.dart
More file actions
50 lines (46 loc) · 1.45 KB
/
Copy pathfind_mounts.dart
File metadata and controls
50 lines (46 loc) · 1.45 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import 'package:cli/caches.dart';
import 'package:cli/cli.dart';
import 'package:cli/plan/trading.dart';
Future<void> command(Database db, ArgResults argResults) async {
final marketPrices = await MarketPriceSnapshot.loadAll(db);
final systemsCache = await db.systems.snapshotAllSystems();
final systemConnectivity = await loadSystemConnectivity(db);
final routePlanner = RoutePlanner.fromSystemsSnapshot(
systemsCache,
systemConnectivity,
sellsFuel: (_) => false,
);
// TODO(eseidel): Just use hq and command ship spec.
final ships = await ShipSnapshot.load(db);
final ship = ships.ships.first;
final mounts = [
TradeSymbol.MOUNT_SURVEYOR_I,
TradeSymbol.MOUNT_SURVEYOR_II,
TradeSymbol.MOUNT_MINING_LASER_I,
TradeSymbol.MOUNT_MINING_LASER_II,
];
for (final tradeSymbol in mounts) {
final best = findBestMarketToBuy(
marketPrices,
routePlanner,
tradeSymbol,
expectedCreditsPerSecond: 7,
start: ship.waypointSymbol,
shipSpec: ship.shipSpec,
);
if (best == null) {
logger.info('No market to buy $tradeSymbol');
continue;
}
logger.info(
'Best value for $tradeSymbol is '
'${approximateDuration(best.route.duration)} away '
'for ${creditsString(best.price.purchasePrice)}'
' at ${best.price.waypointSymbol}'
' (${best.price.tradeVolume} at a time)',
);
}
}
void main(List<String> args) async {
await runOffline(args, command);
}