Clean up flight plan code.

Split the oversized file into one per plan type. This also moves the
layout responsibility out of the oversized FlightPlanBuilder and into
each flight plan type file.
This commit is contained in:
Dan Albert
2022-03-09 01:55:29 -08:00
parent c5fd3df235
commit fa8c0d9660
49 changed files with 2732 additions and 2249 deletions

View File

@@ -16,7 +16,8 @@ from PySide2.QtWidgets import (
)
from game.ato.flight import Flight
from game.ato.flightplan import FlightPlanBuilder, PlanningError
from game.ato.flightplans.flightplanbuilder import FlightPlanBuilder
from game.ato.flightplans.planningerror import PlanningError
from game.ato.package import Package
from game.game import Game
from game.server import EventStream

View File

@@ -4,7 +4,8 @@ from PySide2.QtWidgets import QGroupBox, QLabel, QMessageBox, QVBoxLayout
from game import Game
from game.ato.flight import Flight
from game.ato.flightplan import FlightPlanBuilder, PlanningError
from game.ato.flightplans.flightplanbuilder import FlightPlanBuilder
from game.ato.flightplans.planningerror import PlanningError
from game.ato.traveltime import TotEstimator
from qt_ui.models import PackageModel
from qt_ui.widgets.QLabeledWidget import QLabeledWidget

View File

@@ -12,17 +12,15 @@ from PySide2.QtWidgets import (
)
from game import Game
from game.ato.package import Package
from game.ato.flight import Flight
from game.ato.flightplans.custom import CustomFlightPlan
from game.ato.flightplans.flightplanbuilder import FlightPlanBuilder
from game.ato.flightplans.formationattack import FormationAttackFlightPlan
from game.ato.flightplans.planningerror import PlanningError
from game.ato.flighttype import FlightType
from game.ato.flightwaypoint import FlightWaypoint
from game.ato.flight import Flight
from game.ato.flightplan import (
CustomFlightPlan,
FlightPlanBuilder,
PlanningError,
StrikeFlightPlan,
)
from game.ato.loadouts import Loadout
from game.ato.package import Package
from qt_ui.windows.mission.flight.waypoints.QFlightWaypointList import (
QFlightWaypointList,
)
@@ -107,7 +105,7 @@ class QFlightWaypointTab(QFrame):
# Need to degrade to a custom flight plan and remove the waypoint.
# If the waypoint is a target waypoint and is not the last target
# waypoint, we don't need to degrade.
if isinstance(self.flight.flight_plan, StrikeFlightPlan):
if isinstance(self.flight.flight_plan, FormationAttackFlightPlan):
is_target = waypoint in self.flight.flight_plan.targets
if is_target and len(self.flight.flight_plan.targets) > 1:
self.flight.flight_plan.targets.remove(waypoint)
@@ -144,9 +142,8 @@ class QFlightWaypointTab(QFrame):
def degrade_to_custom_flight_plan(self) -> None:
if not isinstance(self.flight.flight_plan, CustomFlightPlan):
self.flight.flight_plan = CustomFlightPlan(
package=self.flight.package,
flight=self.flight,
custom_waypoints=self.flight.flight_plan.waypoints,
waypoints=self.flight.flight_plan.waypoints,
)
def confirm_recreate(self, task: FlightType) -> None: