Skip to content

Commit

Permalink
fix: ships can buy mounts when < 10M credits
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Sep 30, 2023
1 parent 1805309 commit 0dc2866
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/cli/lib/behavior/central_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class CentralCommand {
// We'll always upgrade a ship as our best option.
if (shouldBuyMount(ship, credits)) {
final request = _takeMountRequest(ship);
shipInfo(ship, 'Starting buy mount ${request.mountSymbol}');
return BehaviorState(ship.shipSymbol, Behavior.mountFromBuy)
..buyJob = request.buyJob
..mountJob = request.mountJob;
Expand Down Expand Up @@ -488,15 +489,17 @@ class CentralCommand {

/// Returns true if [ship] should start the mountFromBuy behavior.
bool shouldBuyMount(Ship ship, int credits) {
// Are there any other ships actively buying mounts?
final otherShipsAreBuyingMounts = _behaviorCache.states.any(
(s) => s.behavior == Behavior.mountFromBuy,
);
// Only enforce the "one at a time" when we have less than 10M credits.
// The 10M is mostly a hack to allow deploying changes to mounts quickly
// late game.
if (credits < 10000000 || otherShipsAreBuyingMounts) {
return false;
if (credits < 10000000) {
// Are there any other ships actively buying mounts?
final otherShipsAreBuyingMounts = _behaviorCache.states.any(
(s) => s.behavior == Behavior.mountFromBuy,
);
if (otherShipsAreBuyingMounts) {
return false;
}
}
// Does this ship have a mount it needs?
final mountRequest =
Expand Down

0 comments on commit 0dc2866

Please sign in to comment.