mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Only allow recruiting carrier units in aircraft carrier groups. Generate one group on carrier when possible.
This commit is contained in:
parent
76638b549f
commit
e82db1fecd
13
game/db.py
13
game/db.py
@ -745,7 +745,20 @@ TIME_PERIODS = {
|
|||||||
"Syrian War [2011]": datetime(2011, 8, 7),
|
"Syrian War [2011]": datetime(2011, 8, 7),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CARRIER_CAPABLE = [
|
||||||
|
FA_18C_hornet,
|
||||||
|
F_14B,
|
||||||
|
AV8BNA,
|
||||||
|
|
||||||
|
UH_1H,
|
||||||
|
Mi_8MT,
|
||||||
|
Ka_50,
|
||||||
|
|
||||||
|
SA342L,
|
||||||
|
SA342M,
|
||||||
|
SA342Minigun,
|
||||||
|
SA342Mistral
|
||||||
|
]
|
||||||
|
|
||||||
"""
|
"""
|
||||||
---------- END OF CONFIGURATION SECTION
|
---------- END OF CONFIGURATION SECTION
|
||||||
|
|||||||
@ -339,12 +339,23 @@ class AircraftConflictGenerator:
|
|||||||
client_count=0,
|
client_count=0,
|
||||||
at=cp.position)
|
at=cp.position)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
st = StartType.Runway
|
st = StartType.Runway
|
||||||
if flight.start_type == "Cold":
|
if flight.start_type == "Cold":
|
||||||
st = StartType.Cold
|
st = StartType.Cold
|
||||||
elif flight.start_type == "Warm":
|
elif flight.start_type == "Warm":
|
||||||
st = StartType.Warm
|
st = StartType.Warm
|
||||||
|
|
||||||
|
if cp.cptype in [ControlPointType.AIRCRAFT_CARRIER_GROUP, ControlPointType.LHA_GROUP]:
|
||||||
|
group_name = cp.get_carrier_group_name()
|
||||||
|
group = self._generate_at_group(
|
||||||
|
name=namegen.next_unit_name(country, cp.id, flight.unit_type),
|
||||||
|
side=country,
|
||||||
|
unit_type=flight.unit_type,
|
||||||
|
count=flight.count,
|
||||||
|
client_count=0,
|
||||||
|
at=self.m.find_group(group_name),)
|
||||||
|
else:
|
||||||
group = self._generate_at_airport(
|
group = self._generate_at_airport(
|
||||||
name=namegen.next_unit_name(country, cp.id, flight.unit_type),
|
name=namegen.next_unit_name(country, cp.id, flight.unit_type),
|
||||||
side=country,
|
side=country,
|
||||||
|
|||||||
@ -12,9 +12,11 @@ class CarrierGroupGenerator(GroupGenerator):
|
|||||||
def generate(self):
|
def generate(self):
|
||||||
|
|
||||||
# Add carrier
|
# Add carrier
|
||||||
if self.faction["aircraft_carrier"]:
|
if "aircraft_carrier" in self.faction.keys():
|
||||||
carrier_type = random.choice(self.faction["aircraft_carrier"])
|
carrier_type = random.choice(self.faction["aircraft_carrier"])
|
||||||
self.add_unit(carrier_type, "Carrier", self.position.x, self.position.y, self.heading)
|
self.add_unit(carrier_type, "Carrier", self.position.x, self.position.y, self.heading)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
# Add destroyers escort
|
# Add destroyers escort
|
||||||
dd_type = random.choice(self.faction["destroyer"])
|
dd_type = random.choice(self.faction["destroyer"])
|
||||||
|
|||||||
@ -30,6 +30,7 @@ class QMapControlPoint(QGraphicsRectItem):
|
|||||||
painter.setBrush(self.brush_color)
|
painter.setBrush(self.brush_color)
|
||||||
painter.setPen(self.pen_color)
|
painter.setPen(self.pen_color)
|
||||||
|
|
||||||
|
if self.model.has_runway():
|
||||||
if self.isUnderMouse():
|
if self.isUnderMouse():
|
||||||
painter.setBrush(CONST.COLORS["white"])
|
painter.setBrush(CONST.COLORS["white"])
|
||||||
painter.setPen(self.pen_color)
|
painter.setPen(self.pen_color)
|
||||||
@ -53,6 +54,9 @@ class QMapControlPoint(QGraphicsRectItem):
|
|||||||
|
|
||||||
painter.setBrush(CONST.COLORS["green"])
|
painter.setBrush(CONST.COLORS["green"])
|
||||||
painter.drawRect(gauge2)
|
painter.drawRect(gauge2)
|
||||||
|
else:
|
||||||
|
# TODO : not drawing sunk carriers. Can be improved to display sunk carrier.
|
||||||
|
pass
|
||||||
painter.restore()
|
painter.restore()
|
||||||
|
|
||||||
def hoverEnterEvent(self, event: QGraphicsSceneHoverEvent):
|
def hoverEnterEvent(self, event: QGraphicsSceneHoverEvent):
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from PySide2.QtWidgets import QHBoxLayout, QLabel, QWidget, QDialog, QVBoxLayout
|
|||||||
QGroupBox, QSizePolicy, QSpacerItem
|
QGroupBox, QSizePolicy, QSpacerItem
|
||||||
from dcs.unittype import UnitType
|
from dcs.unittype import UnitType
|
||||||
|
|
||||||
from game.event import UnitsDeliveryEvent
|
from game.event import UnitsDeliveryEvent, ControlPointType
|
||||||
from qt_ui.widgets.QBudgetBox import QBudgetBox
|
from qt_ui.widgets.QBudgetBox import QBudgetBox
|
||||||
from qt_ui.widgets.base.QAirportInformation import QAirportInformation
|
from qt_ui.widgets.base.QAirportInformation import QAirportInformation
|
||||||
from qt_ui.widgets.base.QBaseInformation import QBaseInformation
|
from qt_ui.widgets.base.QBaseInformation import QBaseInformation
|
||||||
@ -23,6 +23,7 @@ class QBaseMenu(QDialog):
|
|||||||
|
|
||||||
self.cp = controlPoint
|
self.cp = controlPoint
|
||||||
self.game = game
|
self.game = game
|
||||||
|
self.is_carrier = self.cp.cptype in [ControlPointType.AIRCRAFT_CARRIER_GROUP, ControlPointType.LHA_GROUP]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.airport = game.theater.terrain.airport_by_id(self.cp.id)
|
self.airport = game.theater.terrain.airport_by_id(self.cp.id)
|
||||||
@ -98,6 +99,9 @@ class QBaseMenu(QDialog):
|
|||||||
|
|
||||||
for task_type in units.keys():
|
for task_type in units.keys():
|
||||||
|
|
||||||
|
if task_type == PinpointStrike and self.is_carrier:
|
||||||
|
continue
|
||||||
|
|
||||||
units_column = list(set(units[task_type]))
|
units_column = list(set(units[task_type]))
|
||||||
if len(units_column) == 0: continue
|
if len(units_column) == 0: continue
|
||||||
units_column.sort(key=lambda x: db.PRICES[x])
|
units_column.sort(key=lambda x: db.PRICES[x])
|
||||||
@ -107,6 +111,8 @@ class QBaseMenu(QDialog):
|
|||||||
task_box.setLayout(task_box_layout)
|
task_box.setLayout(task_box_layout)
|
||||||
row = 0
|
row = 0
|
||||||
for unit_type in units_column:
|
for unit_type in units_column:
|
||||||
|
if self.is_carrier and not unit_type in db.CARRIER_CAPABLE:
|
||||||
|
continue
|
||||||
row = self.add_purchase_row(unit_type, task_box_layout, row)
|
row = self.add_purchase_row(unit_type, task_box_layout, row)
|
||||||
|
|
||||||
stretch = QVBoxLayout()
|
stretch = QVBoxLayout()
|
||||||
|
|||||||
@ -106,6 +106,20 @@ class ControlPoint:
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def get_carrier_group_name(self):
|
||||||
|
"""
|
||||||
|
Get the carrier group name if the airbase is a carrier
|
||||||
|
:return: Carrier group name
|
||||||
|
"""
|
||||||
|
if self.cptype in [ControlPointType.AIRCRAFT_CARRIER_GROUP, ControlPointType.LHA_GROUP] :
|
||||||
|
for g in self.ground_objects:
|
||||||
|
if g.dcs_identifier == "CARRIER":
|
||||||
|
for group in g.groups:
|
||||||
|
for u in group.units:
|
||||||
|
if db.unit_type_from_name(u.type) in [CVN_74_John_C__Stennis, LHA_1_Tarawa, CV_1143_5_Admiral_Kuznetsov]:
|
||||||
|
return group.name
|
||||||
|
return None
|
||||||
|
|
||||||
def is_connected(self, to) -> bool:
|
def is_connected(self, to) -> bool:
|
||||||
return to in self.connected_points
|
return to in self.connected_points
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user