Add procurement automation for players.

The allows the players to use the same auto-purchase mechanics that the
AI uses. The behavior is very bad, but it's no worse than what OPFOR
deals with.

There's a lot that needs to be improved before this is really a good
choice for the player:

* Option to adjust budget balance between front lines and airbases.
* Disallow negative budgets (which incidentally will cause more aircraft
  to be purchased, since the armor purchases currently accidentally
  spend the aircraft budget).
* Buy less randomly: https://github.com/Khopa/dcs_liberation/issues/361.
* Obey parking limits.
* Use the delivery events rather than instant delivery (also allows the
  player to cancel orders they don't want).

Fixes https://github.com/Khopa/dcs_liberation/issues/362
This commit is contained in:
Dan Albert 2020-12-05 21:18:23 -08:00
parent 1adee0af17
commit f396ff7f12
3 changed files with 61 additions and 3 deletions

View File

@ -243,9 +243,9 @@ class Game:
self,
for_player=True,
faction=self.player_faction,
manage_runways=False,
manage_front_line=False,
manage_aircraft=False
manage_runways=self.settings.automate_runway_repair,
manage_front_line=self.settings.automate_front_line_reinforcements,
manage_aircraft=self.settings.automate_aircraft_reinforcements
).spend_budget(self.budget)
if not no_action and self.turn > 1:

View File

@ -25,6 +25,11 @@ class Settings:
player_income_multiplier: float = 1.0
enemy_income_multiplier: float = 1.0
# Campaign management
automate_runway_repair: bool = False
automate_front_line_reinforcements: bool = False
automate_aircraft_reinforcements: bool = False
# Performance oriented
perf_red_alert_state: bool = True
perf_smoke_gen: bool = True

View File

@ -55,6 +55,7 @@ class QSettingsWindow(QDialog):
self.game = game
self.pluginsPage = None
self.pluginsOptionsPage = None
self.campaign_management_page = QWidget()
self.setModal(True)
self.setWindowTitle("Settings")
@ -83,6 +84,14 @@ class QSettingsWindow(QDialog):
self.categoryModel.appendRow(difficulty)
self.right_layout.addWidget(self.difficultyPage)
self.init_campaign_management_layout()
campaign_management = QStandardItem("Campaign Management")
campaign_management.setIcon(CONST.ICONS["Money"])
campaign_management.setEditable(False)
campaign_management.setSelectable(True)
self.categoryModel.appendRow(campaign_management)
self.right_layout.addWidget(self.campaign_management_page)
self.initGeneratorLayout()
generator = QStandardItem("Mission Generator")
generator.setIcon(CONST.ICONS["Generator"])
@ -234,6 +243,50 @@ class QSettingsWindow(QDialog):
self.missionRestrictionsSettings.setLayout(self.missionRestrictionsLayout)
self.difficultyLayout.addWidget(self.missionRestrictionsSettings)
def init_campaign_management_layout(self) -> None:
campaign_layout = QVBoxLayout()
campaign_layout.setAlignment(Qt.AlignTop)
self.campaign_management_page.setLayout(campaign_layout)
automation = QGroupBox("HQ Automation (WORK IN PROGRESS)")
campaign_layout.addWidget(automation)
automation_layout = QGridLayout()
automation.setLayout(automation_layout)
def set_runway_automation(value: bool) -> None:
self.game.settings.automate_runway_repair = value
def set_front_line_automation(value: bool) -> None:
self.game.settings.automate_front_line_reinforcements = value
def set_aircraft_automation(value: bool) -> None:
self.game.settings.automate_aircraft_reinforcements = value
runway_repair = QCheckBox()
runway_repair.setChecked(
self.game.settings.automate_runway_repair)
runway_repair.toggled.connect(set_runway_automation)
automation_layout.addWidget(QLabel("Automate runway repairs"), 0, 0)
automation_layout.addWidget(runway_repair, 0, 1, Qt.AlignRight)
front_line = QCheckBox()
front_line.setChecked(
self.game.settings.automate_front_line_reinforcements)
front_line.toggled.connect(set_front_line_automation)
automation_layout.addWidget(
QLabel("Automate front-line purchases"), 1, 0)
automation_layout.addWidget(front_line, 1, 1, Qt.AlignRight)
aircraft = QCheckBox()
aircraft.setChecked(
self.game.settings.automate_aircraft_reinforcements)
aircraft.toggled.connect(set_aircraft_automation)
automation_layout.addWidget(QLabel("Automate aircraft purchases"), 2, 0)
automation_layout.addWidget(aircraft, 2, 1, Qt.AlignRight)
def initGeneratorLayout(self):
self.generatorPage = QWidget()