From c5159f8a87c85a1c388952af3a6d78062003da4b Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Tue, 18 May 2021 19:54:39 -0700 Subject: [PATCH] Fix swapped list order for purchase priorities. We were accidentally iterating over the faction list and checking it against the priority list rather than the other way around, so the faction's aircraft list was being used for purchase priority rather than the actual priority list in the game. --- changelog.md | 1 + game/procurement.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 06455ca5..cc88f99a 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,7 @@ Saves from 2.5 are not compatible with 3.0. * **[Campaign]** Ground units must now be recruited at a base with a factory and transferred to their destination. When buying units in the UI, the purchase will automatically be fulfilled at the closest factory, and a transfer will be created on the next turn. * **[Campaign AI]** Every 30 minutes the AI will plan a CAP, so players can customize their mission better. * **[Campaign AI]** AI now considers Ju-88s for CAS, strike, and DEAD missions. +* **[Campaign AI]** Fix purchase of aircraft by priority (the faction's list was being used as the priority list rather than the game's). * **[UI]** Added new web based map UI. This is mostly functional but many of the old display options are a WIP. Revert to the old map with --old-map. * **[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. * **[UI]** DCS loadouts are now selectable in the loadout setup menu. diff --git a/game/procurement.py b/game/procurement.py index f8346bf1..a65879a8 100644 --- a/game/procurement.py +++ b/game/procurement.py @@ -171,7 +171,7 @@ class ProcurementAi: max_price: float, ) -> Optional[Type[FlyingType]]: best_choice: Optional[Type[FlyingType]] = None - for unit in [u for u in self.faction.aircrafts if u in types]: + for unit in [u for u in types if u in self.faction.aircrafts]: if db.PRICES[unit] * number > max_price: continue if not airbase.can_operate(unit):