diff --git a/changelog.md b/changelog.md index 20558db0..9cf83eb7 100644 --- a/changelog.md +++ b/changelog.md @@ -10,11 +10,12 @@ Saves from 2.5 are not compatible with 3.0. * **[UI]** Campaigns generated for an older or newer version of the game will now be marked as incompatible. They can still be played, but bugs may be present. * **[Modding]** Campaigns now choose locations for factories to spawn. * **[Modding]** Can now install custom factions to /Liberation/Factions instead of the Liberation install directory. -* **[Performance Settings]** Added a settings to lower the number of smoke effects generated on frontlines. Lowered default settings for frontline smoke generators, so less smoke should be generated by default. - +* **[Performance Settings]** Added a settings to lower the number of smoke effects generated on frontlines. Lowered default settings for frontline smoke generators, so less smoke should be generated by default. ## Fixes +* **[Campaign AI]** Fixed bug causing AI to over-purchase cheap aircraft. + # 2.5.1 ## Features/Improvements diff --git a/game/procurement.py b/game/procurement.py index 28a5d9bb..d3410a12 100644 --- a/game/procurement.py +++ b/game/procurement.py @@ -192,21 +192,27 @@ class ProcurementAi: aircraft_for_task(request.task_capability), airbase, request.number, budget ) + def fulfill_aircraft_request( + self, request: AircraftProcurementRequest, budget: float + ) -> float: + for airbase in self.best_airbases_for(request): + unit = self.affordable_aircraft_for(request, airbase, budget) + if unit is None: + # Can't afford any aircraft capable of performing the + # required mission that can operate from this airbase. We + # might be able to afford aircraft at other airbases though, + # in the case where the airbase we attempted to use is only + # able to operate expensive aircraft. + continue + + budget -= db.PRICES[unit] * request.number + airbase.pending_unit_deliveries.order({unit: request.number}) + break + return budget + def purchase_aircraft(self, budget: float) -> float: for request in self.game.procurement_requests_for(self.is_player): - for airbase in self.best_airbases_for(request): - unit = self.affordable_aircraft_for(request, airbase, budget) - if unit is None: - # Can't afford any aircraft capable of performing the - # required mission that can operate from this airbase. We - # might be able to afford aircraft at other airbases though, - # in the case where the airbase we attempted to use is only - # able to operate expensive aircraft. - continue - - budget -= db.PRICES[unit] * request.number - airbase.pending_unit_deliveries.order({unit: request.number}) - + budget = self.fulfill_aircraft_request(request, budget) return budget @property