Skip to content

Commit

Permalink
fix: resolve analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Aug 11, 2024
1 parent 0d2f927 commit 2196b2a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/cli/bin/cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Future<void> cliMain(List<String> args) async {
if (agentSymbol == null) {
throw StateError('No agent symbol found in database or environment.');
}
final api;
final Api api;
if (await db.getAuthToken() == null) {
final email = Platform.environment['ST_EMAIL'];
logger.info('No auth token found.');
Expand All @@ -146,7 +146,7 @@ Future<void> cliMain(List<String> args) async {

if (results['selloff'] as bool) {
logger.err('Selling all ships!');
db.setGamePhase(GamePhase.selloff);
await db.setGamePhase(GamePhase.selloff);
}

config = await Config.fromDb(db);
Expand Down
17 changes: 11 additions & 6 deletions packages/cli/lib/central_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,10 @@ class CentralCommand {
await _computeNextShipBuyJob(db, api, caches, shipyardListings, ships);
}

GamePhase _determineGamePhase(ShipSnapshot ships,
{required bool jumpGateComplete}) {
GamePhase _determineGamePhase(
ShipSnapshot ships, {
required bool jumpGateComplete,
}) {
// A hack to advance the global config to the construction phase.
if (jumpGateComplete) {
return GamePhase.exploration;
Expand All @@ -644,10 +646,13 @@ class CentralCommand {
// await caches.updateRoutingCaches();

final ships = await ShipSnapshot.load(db);
final jumpGateComplete = await isJumpgateComplete(
db, caches.systems, caches.agent.headquartersSystemSymbol);
final phase =
_determineGamePhase(ships, jumpGateComplete: jumpGateComplete ?? false);
_isGateComplete = await isJumpgateComplete(
db,
caches.systems,
caches.agent.headquartersSystemSymbol,
) ??
false;
final phase = _determineGamePhase(ships, jumpGateComplete: _isGateComplete);
print(phase);
if (phase != config.gamePhase) {
await db.setGamePhase(phase);
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:types/types.dart';
/// This is used as a default argument and must be const.
const defaultMaxAge = Duration(days: 3);

/// Class to hold our network configuration values.
class NetworkConfig {
/// The number of requests per second allowed by the api.
/// Version 2.1 allows:
Expand Down Expand Up @@ -244,6 +245,7 @@ class Config {
/// Maximum markup we will tolerate when refueling (otherwise we will drift).
final fuelMaxMarkup = 10.0;

/// Loads the Config object from the database.
static Future<Config> fromDb(Database db) async {
final gamePhase = await db.getGamePhase() ?? GamePhase.bootstrap;
return Config(gamePhase);
Expand Down

0 comments on commit 2196b2a

Please sign in to comment.