mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Dan'ts notes
commit 35ab9103cebf823bab85fbb1c9ff4bc2b9c5701a
Author: walterroach <37820425+walterroach@users.noreply.github.com>
Date: Fri Oct 30 22:25:42 2020 -0500
more cleanup
commit d3d008bc6b29f328ad48063bd4b0520e1b819d68
Author: walterroach <37820425+walterroach@users.noreply.github.com>
Date: Fri Oct 30 22:17:59 2020 -0500
More briefinggen cleanup
commit b2033f091d7191aecefb86fecb5cb060c074706e
Author: walterroach <37820425+walterroach@users.noreply.github.com>
Date: Fri Oct 30 22:08:48 2020 -0500
briefinggen cleanup
commit 72ea0196c22d9493df078765800f3fafb9c054dc
Author: walterroach <37820425+walterroach@users.noreply.github.com>
Date: Fri Oct 30 21:57:52 2020 -0500
Add notifier method back to Operation
commit efd39a9e03d02b9d581637d0d1c289af68e749c3
Author: walterroach <37820425+walterroach@users.noreply.github.com>
Date: Fri Oct 30 21:34:37 2020 -0500
Revert "Move kneeboard and briefing gen to unified"
Removes properties added to Operation
This reverts commit 941f2af77074d79b992ae859a0108b67aac5460c.
This commit is contained in:
parent
6a6133e5cd
commit
3dc7dc3d1a
@ -35,7 +35,4 @@ class FrontlineAttackOperation(Operation):
|
|||||||
conflict=conflict)
|
conflict=conflict)
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
## TODO: What are these for?
|
|
||||||
# self.briefinggen.title = "Frontline CAS"
|
|
||||||
# self.briefinggen.description = "Provide CAS for the ground forces attacking enemy lines. Operation will be considered successful if total number of enemy units will be lower than your own by a factor of 1.5 (i.e. with 12 units from both sides, enemy forces need to be reduced to at least 8), meaning that you (and, probably, your wingmans) should concentrate on destroying the enemy units. Target base strength will be lowered as a result. Be advised that your flight will not attack anything until you explicitly tell them so by comms menu."
|
|
||||||
super(FrontlineAttackOperation, self).generate()
|
super(FrontlineAttackOperation, self).generate()
|
||||||
|
|||||||
@ -47,6 +47,7 @@ class Operation:
|
|||||||
airsupportgen = None # type: AirSupportConflictGenerator
|
airsupportgen = None # type: AirSupportConflictGenerator
|
||||||
visualgen = None # type: VisualGenerator
|
visualgen = None # type: VisualGenerator
|
||||||
groundobjectgen = None # type: GroundObjectsGenerator
|
groundobjectgen = None # type: GroundObjectsGenerator
|
||||||
|
briefinggen = None # type: BriefingGenerator
|
||||||
forcedoptionsgen = None # type: ForcedOptionsGenerator
|
forcedoptionsgen = None # type: ForcedOptionsGenerator
|
||||||
radio_registry: Optional[RadioRegistry] = None
|
radio_registry: Optional[RadioRegistry] = None
|
||||||
tacan_registry: Optional[TacanRegistry] = None
|
tacan_registry: Optional[TacanRegistry] = None
|
||||||
@ -75,7 +76,6 @@ class Operation:
|
|||||||
self.to_cp = to_cp
|
self.to_cp = to_cp
|
||||||
self.is_quick = False
|
self.is_quick = False
|
||||||
self.plugin_scripts: List[str] = []
|
self.plugin_scripts: List[str] = []
|
||||||
self.subscribed_generators = [KneeboardGenerator, BriefingGenerator]
|
|
||||||
|
|
||||||
def units_of(self, country_name: str) -> List[UnitType]:
|
def units_of(self, country_name: str) -> List[UnitType]:
|
||||||
return []
|
return []
|
||||||
@ -90,6 +90,7 @@ class Operation:
|
|||||||
def initialize(self, mission: Mission, conflict: Conflict):
|
def initialize(self, mission: Mission, conflict: Conflict):
|
||||||
self.current_mission = mission
|
self.current_mission = mission
|
||||||
self.conflict = conflict
|
self.conflict = conflict
|
||||||
|
# self.briefinggen = BriefingGenerator(self.current_mission, self.game) Is it safe to remove this, or does it also break save compat?
|
||||||
|
|
||||||
def prepare(self, terrain: Terrain, is_quick: bool):
|
def prepare(self, terrain: Terrain, is_quick: bool):
|
||||||
with open("resources/default_options.lua", "r") as f:
|
with open("resources/default_options.lua", "r") as f:
|
||||||
@ -164,25 +165,34 @@ class Operation:
|
|||||||
trigger.add_action(DoScriptFile(fileref))
|
trigger.add_action(DoScriptFile(fileref))
|
||||||
self.current_mission.triggerrules.triggers.append(trigger)
|
self.current_mission.triggerrules.triggers.append(trigger)
|
||||||
|
|
||||||
def notify_subscribed_generators(self):
|
def notify_info_generators(
|
||||||
'''Generates subscribed MissionInfoGenerator objects (currently kneeboards and briefings)
|
self,
|
||||||
'''
|
groundobjectgen: GroundObjectsGenerator,
|
||||||
gens: List[MissionInfoGenerator] = [gen(self.current_mission, game=self.game) for gen in self.subscribed_generators]
|
airsupportgen: AirSupportConflictGenerator,
|
||||||
|
jtacs: List[JtacInfo],
|
||||||
|
airgen: AircraftConflictGenerator,
|
||||||
|
):
|
||||||
|
"""Generates subscribed MissionInfoGenerator objects (currently kneeboards and briefings)
|
||||||
|
"""
|
||||||
|
gens: List[MissionInfoGenerator] = [
|
||||||
|
KneeboardGenerator(self.current_mission, self.game),
|
||||||
|
BriefingGenerator(self.current_mission, self.game)
|
||||||
|
]
|
||||||
for gen in gens:
|
for gen in gens:
|
||||||
for dynamic_runway in self.groundobjectgen.runways.values():
|
for dynamic_runway in groundobjectgen.runways.values():
|
||||||
gen.add_dynamic_runway(dynamic_runway)
|
gen.add_dynamic_runway(dynamic_runway)
|
||||||
|
|
||||||
for tanker in self.airsupportgen.air_support.tankers:
|
for tanker in airsupportgen.air_support.tankers:
|
||||||
gen.add_tanker(tanker)
|
gen.add_tanker(tanker)
|
||||||
|
|
||||||
if self.is_awacs_enabled:
|
if self.is_awacs_enabled:
|
||||||
for awacs in self.airsupportgen.air_support.awacs:
|
for awacs in airsupportgen.air_support.awacs:
|
||||||
gen.add_awacs(awacs)
|
gen.add_awacs(awacs)
|
||||||
|
|
||||||
for jtac in self.jtacs:
|
for jtac in jtacs:
|
||||||
gen.add_jtac(jtac)
|
gen.add_jtac(jtac)
|
||||||
|
|
||||||
for flight in self.airgen.flights:
|
for flight in airgen.flights:
|
||||||
gen.add_flight(flight)
|
gen.add_flight(flight)
|
||||||
gen.generate()
|
gen.generate()
|
||||||
|
|
||||||
@ -221,14 +231,14 @@ class Operation:
|
|||||||
|
|
||||||
# Generate ground object first
|
# Generate ground object first
|
||||||
|
|
||||||
self.groundobjectgen = GroundObjectsGenerator(
|
groundobjectgen = GroundObjectsGenerator(
|
||||||
self.current_mission,
|
self.current_mission,
|
||||||
self.conflict,
|
self.conflict,
|
||||||
self.game,
|
self.game,
|
||||||
radio_registry,
|
radio_registry,
|
||||||
tacan_registry
|
tacan_registry
|
||||||
)
|
)
|
||||||
self.groundobjectgen.generate()
|
groundobjectgen.generate()
|
||||||
|
|
||||||
# Generate destroyed units
|
# Generate destroyed units
|
||||||
for d in self.game.get_destroyed_units():
|
for d in self.game.get_destroyed_units():
|
||||||
@ -250,29 +260,29 @@ class Operation:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Air Support (Tanker & Awacs)
|
# Air Support (Tanker & Awacs)
|
||||||
self.airsupportgen = AirSupportConflictGenerator(
|
airsupportgen = AirSupportConflictGenerator(
|
||||||
self.current_mission, self.conflict, self.game, radio_registry,
|
self.current_mission, self.conflict, self.game, radio_registry,
|
||||||
tacan_registry)
|
tacan_registry)
|
||||||
self.airsupportgen.generate(self.is_awacs_enabled)
|
airsupportgen.generate(self.is_awacs_enabled)
|
||||||
|
|
||||||
# Generate Activity on the map
|
# Generate Activity on the map
|
||||||
self.airgen = AircraftConflictGenerator(
|
airgen = AircraftConflictGenerator(
|
||||||
self.current_mission, self.conflict, self.game.settings, self.game,
|
self.current_mission, self.conflict, self.game.settings, self.game,
|
||||||
radio_registry)
|
radio_registry)
|
||||||
|
|
||||||
self.airgen.generate_flights(
|
airgen.generate_flights(
|
||||||
self.current_mission.country(self.game.player_country),
|
self.current_mission.country(self.game.player_country),
|
||||||
self.game.blue_ato,
|
self.game.blue_ato,
|
||||||
self.groundobjectgen.runways
|
groundobjectgen.runways
|
||||||
)
|
)
|
||||||
self.airgen.generate_flights(
|
airgen.generate_flights(
|
||||||
self.current_mission.country(self.game.enemy_country),
|
self.current_mission.country(self.game.enemy_country),
|
||||||
self.game.red_ato,
|
self.game.red_ato,
|
||||||
self.groundobjectgen.runways
|
groundobjectgen.runways
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generate ground units on frontline everywhere
|
# Generate ground units on frontline everywhere
|
||||||
self.jtacs: List[JtacInfo] = []
|
jtacs: List[JtacInfo] = []
|
||||||
for front_line in self.game.theater.conflicts(True):
|
for front_line in self.game.theater.conflicts(True):
|
||||||
player_cp = front_line.control_point_a
|
player_cp = front_line.control_point_a
|
||||||
enemy_cp = front_line.control_point_b
|
enemy_cp = front_line.control_point_b
|
||||||
@ -285,7 +295,7 @@ class Operation:
|
|||||||
enemy_gp = self.game.ground_planners[enemy_cp.id].units_per_cp[player_cp.id]
|
enemy_gp = self.game.ground_planners[enemy_cp.id].units_per_cp[player_cp.id]
|
||||||
groundConflictGen = GroundConflictGenerator(self.current_mission, conflict, self.game, player_gp, enemy_gp, player_cp.stances[enemy_cp.id])
|
groundConflictGen = GroundConflictGenerator(self.current_mission, conflict, self.game, player_gp, enemy_gp, player_cp.stances[enemy_cp.id])
|
||||||
groundConflictGen.generate()
|
groundConflictGen.generate()
|
||||||
self.jtacs.extend(groundConflictGen.jtacs)
|
jtacs.extend(groundConflictGen.jtacs)
|
||||||
|
|
||||||
# Setup combined arms parameters
|
# Setup combined arms parameters
|
||||||
self.current_mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0
|
self.current_mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0
|
||||||
@ -317,10 +327,10 @@ class Operation:
|
|||||||
luaData["JTACs"] = {}
|
luaData["JTACs"] = {}
|
||||||
luaData["TargetPoints"] = {}
|
luaData["TargetPoints"] = {}
|
||||||
|
|
||||||
self.assign_channels_to_flights(self.airgen.flights,
|
self.assign_channels_to_flights(airgen.flights,
|
||||||
self.airsupportgen.air_support)
|
airsupportgen.air_support)
|
||||||
|
|
||||||
for tanker in self.airsupportgen.air_support.tankers:
|
for tanker in airsupportgen.air_support.tankers:
|
||||||
luaData["Tankers"][tanker.callsign] = {
|
luaData["Tankers"][tanker.callsign] = {
|
||||||
"dcsGroupName": tanker.dcsGroupName,
|
"dcsGroupName": tanker.dcsGroupName,
|
||||||
"callsign": tanker.callsign,
|
"callsign": tanker.callsign,
|
||||||
@ -330,14 +340,14 @@ class Operation:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.is_awacs_enabled:
|
if self.is_awacs_enabled:
|
||||||
for awacs in self.airsupportgen.air_support.awacs:
|
for awacs in airsupportgen.air_support.awacs:
|
||||||
luaData["AWACs"][awacs.callsign] = {
|
luaData["AWACs"][awacs.callsign] = {
|
||||||
"dcsGroupName": awacs.dcsGroupName,
|
"dcsGroupName": awacs.dcsGroupName,
|
||||||
"callsign": awacs.callsign,
|
"callsign": awacs.callsign,
|
||||||
"radio": awacs.freq.mhz
|
"radio": awacs.freq.mhz
|
||||||
}
|
}
|
||||||
|
|
||||||
for jtac in self.jtacs:
|
for jtac in jtacs:
|
||||||
luaData["JTACs"][jtac.callsign] = {
|
luaData["JTACs"][jtac.callsign] = {
|
||||||
"dcsGroupName": jtac.dcsGroupName,
|
"dcsGroupName": jtac.dcsGroupName,
|
||||||
"callsign": jtac.callsign,
|
"callsign": jtac.callsign,
|
||||||
@ -346,7 +356,7 @@ class Operation:
|
|||||||
"laserCode": jtac.code
|
"laserCode": jtac.code
|
||||||
}
|
}
|
||||||
|
|
||||||
for flight in self.airgen.flights:
|
for flight in airgen.flights:
|
||||||
if flight.friendly and flight.flight_type in [FlightType.ANTISHIP, FlightType.DEAD, FlightType.SEAD, FlightType.STRIKE]:
|
if flight.friendly and flight.flight_type in [FlightType.ANTISHIP, FlightType.DEAD, FlightType.SEAD, FlightType.STRIKE]:
|
||||||
flightType = flight.flight_type.name
|
flightType = flight.flight_type.name
|
||||||
flightTarget = flight.package.target
|
flightTarget = flight.package.target
|
||||||
@ -467,11 +477,8 @@ dcsLiberation.TargetPoints = {
|
|||||||
plugin.injectScripts(self)
|
plugin.injectScripts(self)
|
||||||
plugin.injectConfiguration(self)
|
plugin.injectConfiguration(self)
|
||||||
|
|
||||||
self.assign_channels_to_flights(self.airgen.flights,
|
self.assign_channels_to_flights(airgen.flights,
|
||||||
self.airsupportgen.air_support)
|
airsupportgen.air_support)
|
||||||
|
|
||||||
# Generate kneeboard and briefing
|
|
||||||
self.notify_subscribed_generators()
|
|
||||||
|
|
||||||
def assign_channels_to_flights(self, flights: List[FlightData],
|
def assign_channels_to_flights(self, flights: List[FlightData],
|
||||||
air_support: AirSupport) -> None:
|
air_support: AirSupport) -> None:
|
||||||
|
|||||||
@ -1,20 +1,19 @@
|
|||||||
'''
|
"""
|
||||||
Briefing generation logic
|
Briefing generation logic
|
||||||
'''
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import logging
|
import logging
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from theater.frontline import FrontLine
|
from theater.frontline import FrontLine
|
||||||
from typing import List, Dict, TYPE_CHECKING, Optional
|
from typing import List, Dict, TYPE_CHECKING
|
||||||
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||||
|
|
||||||
from dcs.mission import Mission
|
from dcs.mission import Mission
|
||||||
|
|
||||||
from .aircraft import FlightData
|
from .aircraft import FlightData
|
||||||
from .airsupportgen import AwacsInfo, TankerInfo
|
from .airsupportgen import AwacsInfo, TankerInfo
|
||||||
from .armor import JtacInfo
|
from .armor import JtacInfo
|
||||||
# from .conflictgen import Conflict
|
|
||||||
from theater import ControlPoint
|
from theater import ControlPoint
|
||||||
from .ground_forces.combat_stance import CombatStance
|
from .ground_forces.combat_stance import CombatStance
|
||||||
from .radios import RadioFrequency
|
from .radios import RadioFrequency
|
||||||
@ -23,7 +22,6 @@ from .runways import RunwayData
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from game import Game
|
from game import Game
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class CommInfo:
|
class CommInfo:
|
||||||
"""Communications information for the kneeboard."""
|
"""Communications information for the kneeboard."""
|
||||||
@ -43,7 +41,7 @@ class FrontLineInfo:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def _random_frontline_sentence(self) -> str:
|
def _random_frontline_sentence(self) -> str:
|
||||||
'''Random sentences for start of situation briefing'''
|
"""Random sentences for start of situation briefing"""
|
||||||
templates = [
|
templates = [
|
||||||
f"There are combats between {self.player_base.name} and {self.enemy_base.name}. ",
|
f"There are combats between {self.player_base.name} and {self.enemy_base.name}. ",
|
||||||
f"The war on the ground is still going on between {self.player_base.name} and {self.enemy_base.name}. ",
|
f"The war on the ground is still going on between {self.player_base.name} and {self.enemy_base.name}. ",
|
||||||
@ -55,22 +53,22 @@ class FrontLineInfo:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def _zero_units_sentence(self) -> str:
|
def _zero_units_sentence(self) -> str:
|
||||||
'''Situation description if either side has zero units on a frontline'''
|
"""Situation description if either side has zero units on a frontline"""
|
||||||
if self.player_zero:
|
if self.player_zero:
|
||||||
return ("We do not have a single vehicle available to hold our position. The situation is critical, "
|
return ("We do not have a single vehicle available to hold our position. The situation is critical, "
|
||||||
f"and we will lose ground inevitably betweeen {self.player_base.name} and {self.enemy_base.name}")
|
f"and we will lose ground inevitably betweeen {self.player_base.name} and {self.enemy_base.name}")
|
||||||
elif self.enemy_zero:
|
elif self.enemy_zero:
|
||||||
return ("The enemy forces have been crushed, we will be able to make significant progress"
|
return ("The enemy forces have been crushed, we will be able to make significant progress"
|
||||||
f" toward {self.enemy_base.name}.")
|
f" toward {self.enemy_base.name}.")
|
||||||
return ''
|
return ""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _advantage_description(self) -> str:
|
def _advantage_description(self) -> str:
|
||||||
'''Situation description for when player has a numerical advantage
|
"""Situation description for when player has a numerical advantage
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str
|
str
|
||||||
'''
|
"""
|
||||||
if self.stance == CombatStance.AGGRESSIVE:
|
if self.stance == CombatStance.AGGRESSIVE:
|
||||||
return (
|
return (
|
||||||
"On this location, our ground forces will try to make "
|
"On this location, our ground forces will try to make "
|
||||||
@ -95,18 +93,18 @@ class FrontLineInfo:
|
|||||||
)
|
)
|
||||||
# TODO: Write a situation description for player RETREAT stance
|
# TODO: Write a situation description for player RETREAT stance
|
||||||
elif self.stance == CombatStance.RETREAT:
|
elif self.stance == CombatStance.RETREAT:
|
||||||
return ''
|
return ""
|
||||||
else:
|
else:
|
||||||
logging.warning('Briefing did not receive a known CombatStance')
|
logging.warning("Briefing did not receive a known CombatStance")
|
||||||
return ''
|
return ""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _disadvantage_description(self) -> str:
|
def _disadvantage_description(self) -> str:
|
||||||
'''Situation description for when player has a numerical disadvantage
|
"""Situation description for when player has a numerical disadvantage
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str
|
str
|
||||||
'''
|
"""
|
||||||
if self.stance == CombatStance.AGGRESSIVE:
|
if self.stance == CombatStance.AGGRESSIVE:
|
||||||
return (
|
return (
|
||||||
"On this location, our ground forces will try an audacious "
|
"On this location, our ground forces will try an audacious "
|
||||||
@ -131,18 +129,18 @@ class FrontLineInfo:
|
|||||||
)
|
)
|
||||||
# TODO: Write a situation description for player RETREAT stance
|
# TODO: Write a situation description for player RETREAT stance
|
||||||
elif self.stance == CombatStance.RETREAT:
|
elif self.stance == CombatStance.RETREAT:
|
||||||
return ''
|
return ""
|
||||||
else:
|
else:
|
||||||
logging.warning('Briefing did not receive a known CombatStance')
|
logging.warning("Briefing did not receive a known CombatStance")
|
||||||
return ''
|
return ""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brief(self) -> str:
|
def brief(self) -> str:
|
||||||
'''Situation briefing string
|
"""Situation briefing string
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str
|
str
|
||||||
'''
|
"""
|
||||||
if self._zero_units_sentence:
|
if self._zero_units_sentence:
|
||||||
return self._zero_units_sentence
|
return self._zero_units_sentence
|
||||||
situation = self._random_frontline_sentence
|
situation = self._random_frontline_sentence
|
||||||
@ -159,7 +157,7 @@ class MissionInfoGenerator:
|
|||||||
Examples of subtypes include briefing generators, kneeboard generators, etc.
|
Examples of subtypes include briefing generators, kneeboard generators, etc.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, mission: Mission, game: 'Game') -> None:
|
def __init__(self, mission: Mission, game: Game) -> None:
|
||||||
self.mission = mission
|
self.mission = mission
|
||||||
self.game = game
|
self.game = game
|
||||||
self.awacs: List[AwacsInfo] = []
|
self.awacs: List[AwacsInfo] = []
|
||||||
@ -212,11 +210,11 @@ class MissionInfoGenerator:
|
|||||||
self.tankers.append(tanker)
|
self.tankers.append(tanker)
|
||||||
|
|
||||||
def add_frontline(self, frontline: FrontLineInfo) -> None:
|
def add_frontline(self, frontline: FrontLineInfo) -> None:
|
||||||
'''Adds a frontline to the briefing
|
"""Adds a frontline to the briefing
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
frontline {FrontLineInfo} -- [description]
|
frontline: Frontline conflict information
|
||||||
'''
|
"""
|
||||||
self.frontlines.append(frontline)
|
self.frontlines.append(frontline)
|
||||||
|
|
||||||
def add_dynamic_runway(self, runway: RunwayData) -> None:
|
def add_dynamic_runway(self, runway: RunwayData) -> None:
|
||||||
@ -234,25 +232,24 @@ class MissionInfoGenerator:
|
|||||||
|
|
||||||
class BriefingGenerator(MissionInfoGenerator):
|
class BriefingGenerator(MissionInfoGenerator):
|
||||||
|
|
||||||
def __init__(self, mission: Mission, game: 'Game'):
|
def __init__(self, mission: Mission, game: "Game"):
|
||||||
super().__init__(mission, game)
|
super().__init__(mission, game)
|
||||||
# self.conflict = conflict
|
|
||||||
self.title = ""
|
self.title = ""
|
||||||
self.description = ""
|
self.description = ""
|
||||||
self.allied_flights_by_departure: Dict[str, List[FlightData]] = {}
|
self.allied_flights_by_departure: Dict[str, List[FlightData]] = {}
|
||||||
env = Environment(
|
env = Environment(
|
||||||
loader=FileSystemLoader('resources/briefing/templates'),
|
loader=FileSystemLoader("resources/briefing/templates"),
|
||||||
autoescape=select_autoescape(
|
autoescape=select_autoescape(
|
||||||
disabled_extensions=('txt'),
|
disabled_extensions=("txt"),
|
||||||
default_for_string=True,
|
default_for_string=True,
|
||||||
default=True,
|
default=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.template = env.get_template('briefingtemplate_EN.j2')
|
self.template = env.get_template("briefingtemplate_EN.j2")
|
||||||
|
|
||||||
def generate(self) -> None:
|
def generate(self) -> None:
|
||||||
'''Generate the mission briefing
|
"""Generate the mission briefing
|
||||||
'''
|
"""
|
||||||
self._generate_frontline_info()
|
self._generate_frontline_info()
|
||||||
self.generate_allied_flights_by_departure()
|
self.generate_allied_flights_by_departure()
|
||||||
self.mission.set_description_text(self.template.render(vars(self)))
|
self.mission.set_description_text(self.template.render(vars(self)))
|
||||||
@ -260,15 +257,15 @@ class BriefingGenerator(MissionInfoGenerator):
|
|||||||
"./resources/ui/splash_screen.png"))
|
"./resources/ui/splash_screen.png"))
|
||||||
|
|
||||||
def _generate_frontline_info(self) -> None:
|
def _generate_frontline_info(self) -> None:
|
||||||
'''Build FrontLineInfo objects from FrontLine type and append to briefing.
|
"""Build FrontLineInfo objects from FrontLine type and append to briefing.
|
||||||
'''
|
"""
|
||||||
for front_line in self.game.theater.conflicts(from_player=True):
|
for front_line in self.game.theater.conflicts(from_player=True):
|
||||||
self.add_frontline(FrontLineInfo(front_line))
|
self.add_frontline(FrontLineInfo(front_line))
|
||||||
|
|
||||||
# TODO: This should determine if runway is friendly through a method more robust than the existing string match
|
# TODO: This should determine if runway is friendly through a method more robust than the existing string match
|
||||||
def generate_allied_flights_by_departure(self) -> None:
|
def generate_allied_flights_by_departure(self) -> None:
|
||||||
'''Create iterable to display allied flights grouped by departure airfield.
|
"""Create iterable to display allied flights grouped by departure airfield.
|
||||||
'''
|
"""
|
||||||
for flight in self.flights:
|
for flight in self.flights:
|
||||||
if not flight.client_units and flight.friendly:
|
if not flight.client_units and flight.friendly:
|
||||||
name = flight.departure.airfield_name
|
name = flight.departure.airfield_name
|
||||||
|
|||||||
@ -311,7 +311,7 @@ class BriefingPage(KneeboardPage):
|
|||||||
class KneeboardGenerator(MissionInfoGenerator):
|
class KneeboardGenerator(MissionInfoGenerator):
|
||||||
"""Creates kneeboard pages for each client flight in the mission."""
|
"""Creates kneeboard pages for each client flight in the mission."""
|
||||||
|
|
||||||
def __init__(self, mission: Mission, game: 'Game') -> None:
|
def __init__(self, mission: Mission, game: "Game") -> None:
|
||||||
super().__init__(mission, game)
|
super().__init__(mission, game)
|
||||||
|
|
||||||
def generate(self) -> None:
|
def generate(self) -> None:
|
||||||
|
|||||||
@ -14,8 +14,8 @@ class QGroundForcesStrategySelector(QComboBox):
|
|||||||
self.cp.stances[enemy_cp.id] = CombatStance.DEFENSIVE
|
self.cp.stances[enemy_cp.id] = CombatStance.DEFENSIVE
|
||||||
|
|
||||||
for i, stance in enumerate(CombatStance):
|
for i, stance in enumerate(CombatStance):
|
||||||
self.addItem(stance.name, userData=CombatStance(i))
|
self.addItem(stance.name, userData=stance)
|
||||||
if self.cp.stances[enemy_cp.id] == CombatStance(i):
|
if self.cp.stances[enemy_cp.id] == stance:
|
||||||
self.setCurrentIndex(i)
|
self.setCurrentIndex(i)
|
||||||
|
|
||||||
self.currentTextChanged.connect(self.on_change)
|
self.currentTextChanged.connect(self.on_change)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user