Disallow selling ground units.

Ground units should be transferred to a new location, not sold and
repurchased.

https://github.com/Khopa/dcs_liberation/issues/823
This commit is contained in:
Dan Albert 2021-04-18 16:32:02 -07:00
parent 3b72c13f9d
commit 5e054cfc77
3 changed files with 12 additions and 6 deletions

View File

@ -5,6 +5,7 @@ Saves from 2.5 are not compatible with 2.6.
## Features/Improvements ## Features/Improvements
* **[Campaign]** Ground units can now be transferred by road. See https://github.com/Khopa/dcs_liberation/wiki/Unit-Transfers for more information. * **[Campaign]** Ground units can now be transferred by road. See https://github.com/Khopa/dcs_liberation/wiki/Unit-Transfers for more information.
* **[Campaign]** Ground units can no longer be sold. To move units to a new location, transfer them.
## Fixes ## Fixes

View File

@ -469,12 +469,15 @@ class UnitsDeliveryEvent:
logging.info(f"Refunding {count} {unit_type.id} at {self.to_cp.name}") logging.info(f"Refunding {count} {unit_type.id} at {self.to_cp.name}")
game.adjust_budget(price * count, player=self.to_cp.captured) game.adjust_budget(price * count, player=self.to_cp.captured)
def available_next_turn(self, unit_type: Type[UnitType]) -> int: def pending_orders(self, unit_type: Type[UnitType]) -> int:
pending_units = self.units.get(unit_type) pending_units = self.units.get(unit_type)
if pending_units is None: if pending_units is None:
pending_units = 0 pending_units = 0
return pending_units
def available_next_turn(self, unit_type: Type[UnitType]) -> int:
current_units = self.to_cp.base.total_units_of_type(unit_type) current_units = self.to_cp.base.total_units_of_type(unit_type)
return pending_units + current_units return self.pending_orders(unit_type) + current_units
def process(self, game: Game) -> None: def process(self, game: Game) -> None:
bought_units: Dict[Type[UnitType], int] = {} bought_units: Dict[Type[UnitType], int] = {}

View File

@ -1,3 +1,5 @@
from typing import Type
from PySide2.QtCore import Qt from PySide2.QtCore import Qt
from PySide2.QtWidgets import ( from PySide2.QtWidgets import (
QFrame, QFrame,
@ -65,13 +67,13 @@ class QArmorRecruitmentMenu(QFrame, QRecruitBehaviour):
main_layout.addWidget(scroll) main_layout.addWidget(scroll)
self.setLayout(main_layout) self.setLayout(main_layout)
def sell(self, unit_type: UnitType): def sell(self, unit_type: Type[UnitType]) -> None:
if self.pending_deliveries.available_next_turn(unit_type) <= 0: if self.pending_deliveries.pending_orders(unit_type) <= 0:
QMessageBox.critical( QMessageBox.critical(
self, self,
"Could not sell ground unit", "Could not sell ground unit",
f"Attempted to sell one {unit_type.id} at {self.cp.name} " f"Attempted to cancel order of one {unit_type.id} at {self.cp.name} "
"but none are available.", "but no orders are pending.",
QMessageBox.Ok, QMessageBox.Ok,
) )
return return