-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: teach a ship how to only survey
We now have a ship which knows how to only survey in a loop (with two mk2 surveyors). Also added -o or --only to the cli.dart args allowing only running a set of ships. Refactored behavior dispatch as part of adding Surveyor. Wired up recording Transactions from Shipyards (both purchasing and mounting).
- Loading branch information
Showing
16 changed files
with
210 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:cli/behavior/central_command.dart'; | ||
import 'package:cli/cache/caches.dart'; | ||
import 'package:cli/logger.dart'; | ||
import 'package:cli/nav/navigation.dart'; | ||
import 'package:cli/net/actions.dart'; | ||
|
||
/// For dedicated survey ships. | ||
Future<DateTime?> advanceSurveyor( | ||
Api api, | ||
CentralCommand centralCommand, | ||
Caches caches, | ||
Ship ship, { | ||
DateTime Function() getNow = defaultGetNow, | ||
}) async { | ||
shipInfo(ship, '🔭 Surveyor'); | ||
final currentWaypoint = await caches.waypoints.waypoint(ship.waypointSymbol); | ||
|
||
final mineSymbol = | ||
centralCommand.mineSymbolForShip(caches.systems, caches.agent, ship); | ||
if (mineSymbol == null) { | ||
centralCommand.disableBehaviorForShip( | ||
ship, | ||
'No desired mine for ship.', | ||
const Duration(hours: 1), | ||
); | ||
return null; | ||
} | ||
if (ship.waypointSymbol != mineSymbol) { | ||
return beingNewRouteAndLog( | ||
api, | ||
ship, | ||
caches.ships, | ||
caches.systems, | ||
caches.routePlanner, | ||
centralCommand, | ||
mineSymbol, | ||
); | ||
} | ||
// TODO(eseidel): Throw exceptions which disable the behavior for a time. | ||
assert(currentWaypoint.canBeMined, 'Must be at a mineable waypoint.'); | ||
assert(ship.hasSurveyor, 'Must have a surveyor.'); | ||
|
||
// Surveying requires being undocked. | ||
await undockIfNeeded(api, caches.ships, ship); | ||
|
||
final outer = await api.fleet.createSurvey(ship.symbol); | ||
final response = outer!.data; | ||
// shipDetail(ship, '🔭 ${ship.waypointSymbol}'); | ||
shipInfo(ship, '🔭 Got ${response.surveys.length} surveys!'); | ||
await caches.surveys.recordSurveys(response.surveys, getNow: getNow); | ||
// Each survey is the whole behavior. | ||
centralCommand.completeBehavior(ship.shipSymbol); | ||
return response.cooldown.expiration; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.