Skip to content

Commit

Permalink
feat: make game phase dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Mar 11, 2024
1 parent bbc5050 commit c05cc14
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions packages/cli/lib/central_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,11 @@ class CentralCommand {
final shipyardListings = await ShipyardListingSnapshot.load(db);
final charting = await ChartingSnapshot.load(db);

// A hack to advance the global config to the construction phase.
if (ships.countOfFrame(ShipFrameSymbolEnum.LIGHT_FREIGHTER) > 10) {
config = Config(GamePhase.construction);
}

_assignedSystemsForSatellites
..clear()
..addAll(
Expand Down
22 changes: 11 additions & 11 deletions packages/cli/lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@ enum GamePhase with EnumIndexOrdering {
exploration,
}

/// Which phase are we in.
// TODO(eseidel): Make this dynamic.
GamePhase gamePhase = GamePhase.bootstrap;

/// Class for holding our hard-coded configuration values.
class Config {
/// Create a new Config object.
Config(this.gamePhase);

/// Which phase are we in.
final GamePhase gamePhase;

// TODO(eseidel): This should be configured at runtime.
/// The symbol of the agent we are controlling.
final String agentSymbol = 'ESEIDEL2';

/// Whether or not we should enable mining behaviors.
final bool enableMining = gamePhase < GamePhase.exploration;
bool get enableMining => gamePhase < GamePhase.exploration;

/// Whether or not we engage in construction behaviors.
final bool enableConstruction = gamePhase == GamePhase.construction;
bool get enableConstruction => gamePhase == GamePhase.construction;

/// Whether or not we engage in contract behaviors.
final bool enableContracts = true;
Expand Down Expand Up @@ -97,10 +99,8 @@ class Config {

/// Our ship buy plan for computeNextShipToBuy.
List<ShipType> get buyPlan {
final ships = <ShipType>[];
if (gamePhase == GamePhase.bootstrap) {
ships.addAll(_boostrapShips);
} else if (gamePhase >= GamePhase.exploration) {
final ships = <ShipType>[..._boostrapShips];
if (gamePhase >= GamePhase.exploration) {
ships.addAll(_explorationShips);
}
return ships;
Expand Down Expand Up @@ -226,4 +226,4 @@ class Config {
}

/// Our global configuration object.
final config = Config();
Config config = Config(GamePhase.bootstrap);

0 comments on commit c05cc14

Please sign in to comment.