Add a wrapper type for ground unit info.

This commit is contained in:
Dan Albert
2021-06-17 21:48:02 -07:00
parent 8a0824880e
commit 09704b6f37
32 changed files with 469 additions and 1145 deletions

View File

@@ -10,7 +10,8 @@ from dcs.unit import Unit
from dcs.vehicles import vehicle_map
from shapely.geometry import LineString, Point as ShapelyPoint, Polygon, MultiPolygon
from game import Game, db
from game import Game
from game.dcs.groundunittype import GroundUnitType
from game.navmesh import NavMesh
from game.profiling import logged_duration
from game.theater import (
@@ -191,12 +192,6 @@ class GroundObjectJs(QObject):
self.game = game
self.theater = game.theater
self.buildings = self.theater.find_ground_objects_by_obj_name(self.tgo.obj_name)
if self.tgo.is_friendly(to_player=True):
self.country = game.player_country
else:
self.country = game.enemy_country
self.dialog: Optional[QGroundObjectMenu] = None
@Slot()
@@ -223,14 +218,15 @@ class GroundObjectJs(QObject):
def category(self) -> str:
return self.tgo.category
def make_unit_name(self, unit: Unit, dead: bool) -> str:
@staticmethod
def make_unit_name(unit: Unit, dead: bool) -> str:
dead_label = " [DEAD]" if dead else ""
unit_display_name = unit.type
unit_type = vehicle_map.get(unit.type)
if unit_type is not None:
unit_display_name = db.unit_get_expanded_info(
self.country, unit_type, "name"
)
dcs_unit_type = vehicle_map.get(unit.type)
if dcs_unit_type is not None:
# TODO: Make the TGO contain GroundUnitType instead of the pydcs Group.
# This is a hack because we can't know which variant was used.
unit_display_name = next(GroundUnitType.for_dcs_type(dcs_unit_type)).name
return f"Unit #{unit.id} - {unit_display_name}{dead_label}"
@Property(list, notify=unitsChanged)

View File

@@ -11,7 +11,6 @@ from PySide2.QtWidgets import (
QVBoxLayout,
)
from game import db
from game.debriefing import Debriefing
@@ -24,25 +23,19 @@ class LossGrid(QGridLayout):
self.add_loss_rows(debriefing.air_losses.by_type(player), lambda u: u.name)
self.add_loss_rows(
debriefing.front_line_losses_by_type(player),
lambda u: db.unit_type_name(u),
debriefing.front_line_losses_by_type(player), lambda u: str(u)
)
self.add_loss_rows(
debriefing.convoy_losses_by_type(player),
lambda u: f"{db.unit_type_name(u)} from convoy",
debriefing.convoy_losses_by_type(player), lambda u: f"{u} from convoy"
)
self.add_loss_rows(
debriefing.cargo_ship_losses_by_type(player),
lambda u: f"{db.unit_type_name(u)} from cargo ship",
lambda u: f"{u} from cargo ship",
)
self.add_loss_rows(
debriefing.airlift_losses_by_type(player),
lambda u: f"{db.unit_type_name(u)} from airlift",
)
self.add_loss_rows(
debriefing.building_losses_by_type(player),
lambda u: u,
debriefing.airlift_losses_by_type(player), lambda u: f"{u} from airlift"
)
self.add_loss_rows(debriefing.building_losses_by_type(player), lambda u: u)
# TODO: Display dead ground object units and runways.

View File

@@ -1,9 +1,5 @@
from __future__ import annotations
from dataclasses import dataclass
from typing import Type, Union
import dcs
from PySide2.QtCore import Qt
from PySide2.QtGui import QIcon
from PySide2.QtWidgets import (
@@ -13,79 +9,23 @@ from PySide2.QtWidgets import (
QTextBrowser,
QFrame,
)
from dcs.unittype import VehicleType
import gen.flights.ai_flight_planner_db
from game import db
from game.dcs.aircrafttype import AircraftType
from game.dcs.groundunittype import GroundUnitType
from game.dcs.unittype import UnitType
from game.game import Game
from gen.flights.flight import FlightType
from qt_ui.uiconstants import AIRCRAFT_BANNERS, VEHICLE_BANNERS
@dataclass(frozen=True)
class UnitInfo:
name: str
description: str
introduction_year: str
origin: str
manufacturer: str
role: str
@classmethod
def from_unit_type(
cls, country: str, unit_type: Union[AircraftType, Type[VehicleType]]
) -> UnitInfo:
if isinstance(unit_type, AircraftType):
return cls.from_aircraft(unit_type)
else:
return cls.from_vehicle_type(country, unit_type)
@classmethod
def from_aircraft(cls, aircraft: AircraftType) -> UnitInfo:
return UnitInfo(
aircraft.name,
aircraft.description,
aircraft.year_introduced,
aircraft.country_of_origin,
aircraft.manufacturer,
aircraft.role,
)
@classmethod
def from_vehicle_type(cls, country: str, unit_type: Type[VehicleType]) -> UnitInfo:
name = db.unit_get_expanded_info(country, unit_type, "name")
manufacturer = db.unit_get_expanded_info(country, unit_type, "manufacturer")
origin = db.unit_get_expanded_info(country, unit_type, "country-of-origin")
role = db.unit_get_expanded_info(country, unit_type, "role")
introduction = db.unit_get_expanded_info(
country, unit_type, "year-of-variant-introduction"
)
description = db.unit_get_expanded_info(country, unit_type, "text")
return UnitInfo(
name,
description,
introduction,
origin,
manufacturer,
role,
)
class QUnitInfoWindow(QDialog):
def __init__(
self, game: Game, unit_type: Union[AircraftType, Type[VehicleType]]
) -> None:
def __init__(self, game: Game, unit_type: UnitType) -> None:
super().__init__()
self.setModal(True)
self.game = game
self.unit_type = unit_type
if isinstance(unit_type, AircraftType):
self.name = unit_type.name
else:
self.name = db.unit_get_expanded_info(
self.game.player_country, self.unit_type, "name"
)
self.name = unit_type.name
self.setWindowTitle(f"Unit Info: {self.name}")
self.setWindowIcon(QIcon("./resources/icon.png"))
self.setMinimumHeight(570)
@@ -101,8 +41,8 @@ class QUnitInfoWindow(QDialog):
if isinstance(self.unit_type, AircraftType):
pixmap = AIRCRAFT_BANNERS.get(self.unit_type.dcs_id)
elif dcs.vehicles.vehicle_map.get(self.unit_type.id) is not None:
pixmap = VEHICLE_BANNERS.get(self.unit_type.id)
elif isinstance(self.unit_type, GroundUnitType):
pixmap = VEHICLE_BANNERS.get(self.unit_type.dcs_id)
if pixmap is None:
pixmap = AIRCRAFT_BANNERS.get("Missing")
header.setPixmap(pixmap.scaled(header.width(), header.height()))
@@ -115,20 +55,21 @@ class QUnitInfoWindow(QDialog):
self.details_grid_layout = QGridLayout()
self.details_grid_layout.setMargin(0)
unit_info = UnitInfo.from_unit_type(self.game.player_country, self.unit_type)
self.name_box = QLabel(
f"<b>Name:</b> {unit_info.manufacturer} {unit_info.name}"
f"<b>Name:</b> {unit_type.manufacturer} {unit_type.name}"
)
self.name_box.setProperty("style", "info-element")
self.country_box = QLabel(f"<b>Country of Origin:</b> {unit_info.origin}")
self.country_box = QLabel(
f"<b>Country of Origin:</b> {unit_type.country_of_origin}"
)
self.country_box.setProperty("style", "info-element")
self.role_box = QLabel(f"<b>Role:</b> {unit_info.role}")
self.role_box = QLabel(f"<b>Role:</b> {unit_type.role}")
self.role_box.setProperty("style", "info-element")
self.year_box = QLabel(
f"<b>Variant Introduction:</b> {unit_info.introduction_year}"
f"<b>Variant Introduction:</b> {unit_type.year_introduced}"
)
self.year_box.setProperty("style", "info-element")
@@ -152,7 +93,7 @@ class QUnitInfoWindow(QDialog):
# Finally, add the description box.
self.details_text = QTextBrowser()
self.details_text.setProperty("style", "info-desc")
self.details_text.setText(unit_info.description)
self.details_text.setText(unit_type.description)
self.gridLayout.addWidget(self.details_text, 3, 0)
self.layout.addLayout(self.gridLayout, 1, 0)

View File

@@ -10,7 +10,6 @@ from PySide2.QtWidgets import (
QWidget,
)
from game import db
from game.theater import ControlPoint
from game.transfers import MultiGroupTransport
from qt_ui.dialogs import Dialog
@@ -19,7 +18,7 @@ from qt_ui.uiconstants import VEHICLES_ICONS
class DepartingConvoyInfo(QGroupBox):
def __init__(self, convoy: MultiGroupTransport, game_model: GameModel) -> None:
def __init__(self, convoy: MultiGroupTransport) -> None:
super().__init__(f"{convoy.name} to {convoy.destination}")
self.convoy = convoy
@@ -31,17 +30,14 @@ class DepartingConvoyInfo(QGroupBox):
for idx, (unit_type, count) in enumerate(convoy.units.items()):
icon = QLabel()
if unit_type.id in VEHICLES_ICONS.keys():
icon.setPixmap(VEHICLES_ICONS[unit_type.id])
if unit_type.dcs_id in VEHICLES_ICONS.keys():
icon.setPixmap(VEHICLES_ICONS[unit_type.dcs_id])
else:
icon.setText("<b>" + unit_type.id[:8] + "</b>")
icon.setProperty("style", "icon-armor")
unit_layout.addWidget(icon, idx, 0)
unit_display_name = db.unit_get_expanded_info(
game_model.game.enemy_country, unit_type, "name"
)
unit_layout.addWidget(
QLabel(f"{count} x <strong>{unit_display_name}</strong>"),
QLabel(f"{count} x <strong>{unit_type.name}</strong>"),
idx,
1,
)
@@ -68,7 +64,6 @@ class DepartingConvoysList(QFrame):
def __init__(self, cp: ControlPoint, game_model: GameModel):
super().__init__()
self.cp = cp
self.game_model = game_model
self.setMinimumWidth(500)
layout = QVBoxLayout()
@@ -79,11 +74,11 @@ class DepartingConvoysList(QFrame):
scroll_content.setLayout(task_box_layout)
for convoy in game_model.game.transfers.convoys.departing_from(cp):
group_info = DepartingConvoyInfo(convoy, game_model)
group_info = DepartingConvoyInfo(convoy)
task_box_layout.addWidget(group_info)
for cargo_ship in game_model.game.transfers.cargo_ships.departing_from(cp):
group_info = DepartingConvoyInfo(cargo_ship, game_model)
group_info = DepartingConvoyInfo(cargo_ship)
task_box_layout.addWidget(group_info)
scroll_content.setLayout(task_box_layout)

View File

@@ -20,10 +20,10 @@ from PySide2.QtWidgets import (
QVBoxLayout,
QWidget,
)
from dcs.task import PinpointStrike
from dcs.unittype import UnitType
from game import Game, db
from game import Game
from game.dcs.groundunittype import GroundUnitType
from game.theater import ControlPoint
from game.transfers import TransferOrder
from qt_ui.models import GameModel
@@ -63,12 +63,7 @@ class UnitTransferList(QFrame):
task_box_layout = QGridLayout()
scroll_content.setLayout(task_box_layout)
units_column = sorted(
cp.base.armor,
key=lambda u: db.unit_get_expanded_info(
self.game_model.game.player_country, u, "name"
),
)
units_column = sorted(cp.base.armor, key=lambda u: u.name)
count = 0
for count, unit_type in enumerate(units_column):
@@ -169,9 +164,7 @@ class ScrollingUnitTransferGrid(QFrame):
unit_types = set(self.game_model.game.faction_for(player=True).ground_units)
sorted_units = sorted(
{u for u in unit_types if self.cp.base.total_units_of_type(u)},
key=lambda u: db.unit_get_expanded_info(
self.game_model.game.player_country, u, "name"
),
key=lambda u: u.name,
)
for row, unit_type in enumerate(sorted_units):
self.add_unit_row(unit_type, task_box_layout, row)
@@ -190,7 +183,7 @@ class ScrollingUnitTransferGrid(QFrame):
def add_unit_row(
self,
unit_type: Type[UnitType],
unit_type: GroundUnitType,
layout: QGridLayout,
row: int,
) -> None:
@@ -203,13 +196,7 @@ class ScrollingUnitTransferGrid(QFrame):
origin_inventory = self.cp.base.total_units_of_type(unit_type)
unit_name = QLabel(
"<b>"
+ db.unit_get_expanded_info(
self.game_model.game.player_country, unit_type, "name"
)
+ "</b>"
)
unit_name = QLabel(f"<b>{unit_type.name}</b>")
unit_name.setSizePolicy(
QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
)

View File

@@ -1,5 +1,4 @@
import logging
from typing import Type, Union
from PySide2.QtWidgets import (
QGroupBox,
@@ -10,9 +9,8 @@ from PySide2.QtWidgets import (
QSizePolicy,
QSpacerItem,
)
from dcs.unittype import VehicleType
from game.dcs.aircrafttype import AircraftType
from game.dcs.unittype import UnitType
from game.theater import ControlPoint
from game.unitdelivery import PendingUnitDeliveries
from qt_ui.models import GameModel
@@ -38,7 +36,7 @@ class QRecruitBehaviour:
return self.cp.pending_unit_deliveries
@property
def budget(self) -> int:
def budget(self) -> float:
return self.game_model.game.budget
@budget.setter
@@ -47,7 +45,7 @@ class QRecruitBehaviour:
def add_purchase_row(
self,
unit_type: Union[AircraftType, Type[VehicleType]],
unit_type: UnitType,
layout: QLayout,
row: int,
) -> int:
@@ -61,7 +59,7 @@ class QRecruitBehaviour:
existing_units = self.cp.base.total_units_of_type(unit_type)
scheduled_units = self.pending_deliveries.units.get(unit_type, 0)
unitName = QLabel(f"<b>{self.name_of(unit_type)}</b>")
unitName = QLabel(f"<b>{unit_type.name}</b>")
unitName.setSizePolicy(
QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
)
@@ -75,7 +73,7 @@ class QRecruitBehaviour:
self.existing_units_labels[unit_type] = existing_units
self.bought_amount_labels[unit_type] = amount_bought
price = QLabel(f"<b>$ {self.price_of(unit_type)}</b> M")
price = QLabel(f"<b>$ {unit_type.price}</b> M")
price.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
buysell = QGroupBox()
@@ -149,8 +147,7 @@ class QRecruitBehaviour:
return row + 1
def _update_count_label(self, unit_type: Union[AircraftType, Type[VehicleType]]):
def _update_count_label(self, unit_type: UnitType) -> None:
self.bought_amount_labels[unit_type].setText(
"<b>{}</b>".format(
unit_type in self.pending_deliveries.units
@@ -166,34 +163,32 @@ class QRecruitBehaviour:
def update_available_budget(self) -> None:
GameUpdateSignal.get_instance().updateBudget(self.game_model.game)
def buy(self, unit_type: Union[AircraftType, Type[VehicleType]]):
def buy(self, unit_type: UnitType) -> None:
if not self.enable_purchase(unit_type):
logging.error(f"Purchase of {unit_type.id} not allowed at {self.cp.name}")
logging.error(f"Purchase of {unit_type} not allowed at {self.cp.name}")
return
self.pending_deliveries.order({unit_type: 1})
self.budget -= self.price_of(unit_type)
self.budget -= unit_type.price
self._update_count_label(unit_type)
self.update_available_budget()
def sell(self, unit_type):
def sell(self, unit_type: UnitType) -> None:
if self.pending_deliveries.available_next_turn(unit_type) > 0:
self.budget += self.price_of(unit_type)
self.budget += unit_type.price
self.pending_deliveries.sell({unit_type: 1})
if self.pending_deliveries.units[unit_type] == 0:
del self.pending_deliveries.units[unit_type]
self._update_count_label(unit_type)
self.update_available_budget()
def enable_purchase(
self, unit_type: Union[AircraftType, Type[VehicleType]]
) -> bool:
return self.budget >= self.price_of(unit_type)
def enable_purchase(self, unit_type: UnitType) -> bool:
return self.budget >= unit_type.price
def enable_sale(self, unit_type: Union[AircraftType, Type[VehicleType]]) -> bool:
def enable_sale(self, unit_type: UnitType) -> bool:
return True
def info(self, unit_type):
def info(self, unit_type: UnitType) -> None:
self.info_window = QUnitInfoWindow(self.game_model.game, unit_type)
self.info_window.show()
@@ -202,9 +197,3 @@ class QRecruitBehaviour:
Set the maximum number of units that can be bought
"""
self.maximum_units = maximum_units
def name_of(self, unit_type: Union[AircraftType, Type[VehicleType]]) -> str:
raise NotImplementedError
def price_of(self, unit_type: Union[AircraftType, Type[VehicleType]]) -> int:
raise NotImplementedError

View File

@@ -92,12 +92,6 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour):
return False
return True
def name_of(self, unit_type: AircraftType) -> str:
return unit_type.name
def price_of(self, unit_type: AircraftType) -> int:
return unit_type.price
def buy(self, unit_type: AircraftType) -> None:
if self.maximum_units > 0:
if self.cp.unclaimed_parking(self.game_model.game) <= 0:

View File

@@ -1,5 +1,3 @@
from typing import Type
from PySide2.QtCore import Qt
from PySide2.QtWidgets import (
QFrame,
@@ -8,10 +6,8 @@ from PySide2.QtWidgets import (
QVBoxLayout,
QWidget,
)
from dcs.unittype import UnitType, VehicleType
from game import db
from game.db import PRICES
from game.dcs.groundunittype import GroundUnitType
from game.theater import ControlPoint
from qt_ui.models import GameModel
from qt_ui.windows.basemenu.QRecruitBehaviour import QRecruitBehaviour
@@ -39,11 +35,7 @@ class QArmorRecruitmentMenu(QFrame, QRecruitBehaviour):
unit_types = list(
set(self.game_model.game.faction_for(player=True).ground_units)
)
unit_types.sort(
key=lambda u: db.unit_get_expanded_info(
self.game_model.game.player_country, u, "name"
)
)
unit_types.sort(key=lambda u: u.name)
for unit_type in unit_types:
row = self.add_purchase_row(unit_type, task_box_layout, row)
stretch = QVBoxLayout()
@@ -59,18 +51,10 @@ class QArmorRecruitmentMenu(QFrame, QRecruitBehaviour):
main_layout.addWidget(scroll)
self.setLayout(main_layout)
def enable_purchase(self, unit_type: Type[UnitType]) -> bool:
def enable_purchase(self, unit_type: GroundUnitType) -> bool:
if not super().enable_purchase(unit_type):
return False
return self.cp.has_ground_unit_source(self.game_model.game)
def enable_sale(self, unit_type: Type[UnitType]) -> bool:
def enable_sale(self, unit_type: GroundUnitType) -> bool:
return self.pending_deliveries.pending_orders(unit_type) > 0
def name_of(self, unit_type: Type[VehicleType]) -> str:
return db.unit_get_expanded_info(
self.game_model.game.player_country, unit_type, "name"
)
def price_of(self, unit_type: Type[VehicleType]) -> int:
return PRICES[unit_type]

View File

@@ -11,7 +11,7 @@ from PySide2.QtWidgets import (
QWidget,
)
from game import Game, db
from game import Game
from game.theater import ControlPoint
@@ -38,10 +38,7 @@ class QIntelInfo(QFrame):
front_line_units = defaultdict(int)
for unit_type, count in self.cp.base.armor.items():
if count:
name = db.unit_get_expanded_info(
self.game.enemy_country, unit_type, "name"
)
front_line_units[name] += count
front_line_units[unit_type.name] += count
units_by_task["Front line units"] = front_line_units
for task, unit_types in units_by_task.items():

View File

@@ -20,7 +20,8 @@ from dcs import vehicles
from game import Game, db
from game.data.building_data import FORTIFICATION_BUILDINGS
from game.db import PRICES, REWARDS, unit_type_of
from game.db import REWARDS
from game.dcs.groundunittype import GroundUnitType
from game.theater import ControlPoint, TheaterGroundObject
from game.theater.theatergroundobject import (
VehicleGroupGroundObject,
@@ -108,17 +109,18 @@ class QGroundObjectMenu(QDialog):
for g in self.ground_object.groups:
if not hasattr(g, "units_losts"):
g.units_losts = []
for u in g.units:
unit_display_name = u.type
unit_type = vehicles.vehicle_map.get(u.type)
if unit_type is not None:
unit_display_name = db.unit_get_expanded_info(
self.game.enemy_country, unit_type, "name"
)
for unit in g.units:
unit_display_name = unit.type
dcs_unit_type = vehicles.vehicle_map.get(unit.type)
if dcs_unit_type is not None:
# Hack: Don't know which variant is used.
unit_display_name = next(
GroundUnitType.for_dcs_type(dcs_unit_type)
).name
self.intelLayout.addWidget(
QLabel(
"<b>Unit #"
+ str(u.id)
+ str(unit.id)
+ " - "
+ str(unit_display_name)
+ "</b>"
@@ -128,26 +130,30 @@ class QGroundObjectMenu(QDialog):
)
i = i + 1
for u in g.units_losts:
for unit in g.units_losts:
dcs_unit_type = vehicles.vehicle_map.get(unit.type)
if dcs_unit_type is None:
continue
utype = unit_type_of(u)
if utype in PRICES:
price = PRICES[utype]
else:
price = 6
# Hack: Don't know which variant is used.
unit_type = next(GroundUnitType.for_dcs_type(dcs_unit_type))
self.intelLayout.addWidget(
QLabel(
"<b>Unit #" + str(u.id) + " - " + str(u.type) + "</b> [DEAD]"
"<b>Unit #"
+ str(unit.id)
+ " - "
+ str(unit_type)
+ "</b> [DEAD]"
),
i,
0,
)
if self.cp.captured:
repair = QPushButton("Repair [" + str(price) + "M]")
repair = QPushButton(f"Repair [{unit_type.price}M]")
repair.setProperty("style", "btn-success")
repair.clicked.connect(
lambda u=u, g=g, p=price: self.repair_unit(g, u, p)
lambda u=unit, g=g, p=unit_type.price: self.repair_unit(g, u, p)
)
self.intelLayout.addWidget(repair, i, 1)
i = i + 1
@@ -217,13 +223,12 @@ class QGroundObjectMenu(QDialog):
def update_total_value(self):
total_value = 0
for group in self.ground_object.groups:
for u in group.units:
utype = unit_type_of(u)
if utype in PRICES:
total_value = total_value + PRICES[utype]
else:
total_value = total_value + 1
if not self.ground_object.purchasable:
return
for u in self.ground_object.units:
# Hack: Unknown variant.
unit_type = next(GroundUnitType.for_dcs_type(vehicles.vehicle_map[u.type]))
total_value += unit_type.price
if self.sell_all_button is not None:
self.sell_all_button.setText("Disband (+$" + str(self.total_value) + "M)")
self.total_value = total_value
@@ -340,10 +345,7 @@ class QBuyGroupForGroundObjectDialog(QDialog):
# Armored units
for unit in set(faction.ground_units):
self.buyArmorCombo.addItem(
db.unit_type_name_2(unit) + " [$" + str(db.PRICES[unit]) + "M]",
userData=unit,
)
self.buyArmorCombo.addItem(f"{unit} [${unit.price}M]", userData=unit)
self.buyArmorCombo.currentIndexChanged.connect(self.armorComboChanged)
self.amount.setMinimum(2)
@@ -404,33 +406,19 @@ class QBuyGroupForGroundObjectDialog(QDialog):
)
def armorComboChanged(self, index):
self.buyArmorButton.setText(
"Buy [$"
+ str(db.PRICES[self.buyArmorCombo.itemData(index)] * self.amount.value())
+ "M][-$"
+ str(self.current_group_value)
+ "M]"
)
unit_type = self.buyArmorCombo.itemData(self.buyArmorCombo.currentIndex())
price = unit_type.price * self.amount.value()
self.buyArmorButton.setText(f"Buy [${price}M][-${self.current_group_value}M]")
def amountComboChanged(self):
self.buyArmorButton.setText(
"Buy [$"
+ str(
db.PRICES[
self.buyArmorCombo.itemData(self.buyArmorCombo.currentIndex())
]
* self.amount.value()
)
+ "M][-$"
+ str(self.current_group_value)
+ "M]"
)
unit_type = self.buyArmorCombo.itemData(self.buyArmorCombo.currentIndex())
price = unit_type.price * self.amount.value()
self.buyArmorButton.setText(f"Buy [${price}M][-${self.current_group_value}M]")
def buyArmor(self):
logging.info("Buying Armor ")
utype = self.buyArmorCombo.itemData(self.buyArmorCombo.currentIndex())
logging.info(utype)
price = db.PRICES[utype] * self.amount.value() - self.current_group_value
price = utype.price * self.amount.value() - self.current_group_value
if price > self.game.budget:
self.error_money()
self.close()

View File

@@ -15,7 +15,7 @@ from PySide2.QtWidgets import (
QWidget,
)
from game.game import Game, db
from game.game import Game
from qt_ui.uiconstants import ICONS
from qt_ui.windows.finances.QFinancesMenu import FinancesLayout
@@ -111,7 +111,7 @@ class ArmyIntelLayout(IntelTableLayout):
for vehicle, count in base.armor.items():
if not count:
continue
self.add_row(vehicle.id, count)
self.add_row(vehicle.name, count)
self.add_spacer()
self.add_row("<b>Total</b>", total)