mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Autoplanner will take number of pilots into account when planning purchases
- Added expected_pilots_next_turn() to Squadron. The procurement AI now correctly compares to it when evaluating if planes should be bought, instead of the maximum possible number of pilots. - Added replenish_rate method to squadron.py to prevent expected_pilots_next_turn from returning an incorrect (too large) number when replenish rate > pilots required. #1837
This commit is contained in:
parent
5cd9af32fa
commit
2af274dc77
@ -185,6 +185,14 @@ class ProcurementAi:
|
||||
) -> Tuple[float, bool]:
|
||||
for squadron in squadrons:
|
||||
price = squadron.aircraft.price * quantity
|
||||
# Final check to make sure the number of aircraft won't exceed the number of available pilots
|
||||
# after fulfilling this aircraft request.
|
||||
if (
|
||||
squadron.pilot_limits_enabled
|
||||
and squadron.expected_size_next_turn + quantity
|
||||
> squadron.expected_pilots_next_turn
|
||||
):
|
||||
continue
|
||||
if price > budget:
|
||||
continue
|
||||
|
||||
|
||||
@ -222,6 +222,17 @@ class Squadron:
|
||||
def max_size(self) -> int:
|
||||
return self.settings.squadron_pilot_limit
|
||||
|
||||
@property
|
||||
def expected_pilots_next_turn(self) -> int:
|
||||
return len(self.active_pilots) + self.replenish_rate
|
||||
|
||||
@property
|
||||
def replenish_rate(self) -> int:
|
||||
return min(
|
||||
self.settings.squadron_replenishment_rate,
|
||||
self._number_of_unfilled_pilot_slots,
|
||||
)
|
||||
|
||||
@property
|
||||
def active_pilots(self) -> list[Pilot]:
|
||||
return self._pilots_with_status(PilotStatus.Active)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user