Refactor front line code to make sides explicit.

A was intended to be the blue point and B was intended to be the red
point. Make this a part of the name so that's clear, and clean up
related code to keep that reliable.
This commit is contained in:
Dan Albert
2021-05-07 20:56:39 -07:00
parent 12f474ecbe
commit b0c24f6e51
13 changed files with 125 additions and 154 deletions

View File

@@ -63,26 +63,19 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
return i + 1
if self.include_frontlines:
for cp in self.game.theater.controlpoints:
if cp.captured:
enemy_cp = [
ecp
for ecp in cp.connected_points
if ecp.captured != cp.captured
]
for ecp in enemy_cp:
pos = Conflict.frontline_position(cp, ecp, self.game.theater)[0]
wpt = FlightWaypoint(
FlightWaypointType.CUSTOM,
pos.x,
pos.y,
Distance.from_meters(800),
)
wpt.name = "Frontline " + cp.name + "/" + ecp.name + " [CAS]"
wpt.alt_type = "RADIO"
wpt.pretty_name = wpt.name
wpt.description = "Frontline"
i = add_model_item(i, model, wpt.pretty_name, wpt)
for front_line in self.game.theater.conflicts():
pos = Conflict.frontline_position(front_line, self.game.theater)[0]
wpt = FlightWaypoint(
FlightWaypointType.CUSTOM,
pos.x,
pos.y,
Distance.from_meters(800),
)
wpt.name = f"Frontline {front_line.name} [CAS]"
wpt.alt_type = "RADIO"
wpt.pretty_name = wpt.name
wpt.description = "Frontline"
i = add_model_item(i, model, wpt.pretty_name, wpt)
if self.include_targets:
for cp in self.game.theater.controlpoints:

View File

@@ -101,16 +101,16 @@ class QFrontLine(QGraphicsLineItem):
Dialog.open_new_package_dialog(self.mission_target)
def cheat_forward(self) -> None:
self.mission_target.control_point_a.base.affect_strength(0.1)
self.mission_target.control_point_b.base.affect_strength(-0.1)
self.mission_target.blue_cp.base.affect_strength(0.1)
self.mission_target.red_cp.base.affect_strength(-0.1)
# Clear the ATO to replan missions affected by the front line.
self.game_model.game.reset_ato()
self.game_model.game.initialize_turn()
GameUpdateSignal.get_instance().updateGame(self.game_model.game)
def cheat_backward(self) -> None:
self.mission_target.control_point_a.base.affect_strength(-0.1)
self.mission_target.control_point_b.base.affect_strength(0.1)
self.mission_target.blue_cp.base.affect_strength(-0.1)
self.mission_target.red_cp.base.affect_strength(0.1)
# Clear the ATO to replan missions affected by the front line.
self.game_model.game.reset_ato()
self.game_model.game.initialize_turn()

View File

@@ -865,8 +865,8 @@ class QLiberationMap(QGraphicsView):
a[1],
b[0],
b[1],
frontline.control_point_a,
frontline.control_point_b,
frontline.blue_cp,
frontline.red_cp,
convoys,
)
)
@@ -914,7 +914,10 @@ class QLiberationMap(QGraphicsView):
if convoy is not None:
convoys.append(convoy)
frontline = FrontLine(a, b, self.game.theater)
if a.captured:
frontline = FrontLine(a, b, self.game.theater)
else:
frontline = FrontLine(b, a, self.game.theater)
if a.front_is_active(b):
if DisplayOptions.actual_frontline_pos:
self.draw_actual_frontline(scene, frontline, convoys)
@@ -947,7 +950,7 @@ class QLiberationMap(QGraphicsView):
) -> None:
self.draw_bezier_frontline(scene, frontline, convoys)
vector = Conflict.frontline_vector(
frontline.control_point_a, frontline.control_point_b, self.game.theater
frontline.blue_cp, frontline.red_cp, self.game.theater
)
left_pos = self._transform_point(vector[0])
right_pos = self._transform_point(