mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Use FrontLine in ConflictTheater.conflicts.
This commit is contained in:
parent
04d3ba4c47
commit
dd2b61edf3
17
game/game.py
17
game/game.py
@ -141,8 +141,10 @@ class Game:
|
||||
self.events.append(event_class(self, player_cp, enemy_cp, enemy_cp.position, self.player_name, self.enemy_name))
|
||||
|
||||
def _generate_events(self):
|
||||
for player_cp, enemy_cp in self.theater.conflicts(True):
|
||||
self._generate_player_event(FrontlineAttackEvent, player_cp, enemy_cp)
|
||||
for front_line in self.theater.conflicts(True):
|
||||
self._generate_player_event(FrontlineAttackEvent,
|
||||
front_line.control_point_a,
|
||||
front_line.control_point_b)
|
||||
|
||||
def commision_unit_types(self, cp: ControlPoint, for_task: Task) -> List[UnitType]:
|
||||
importance_factor = (cp.importance - IMPORTANCE_LOW) / (IMPORTANCE_HIGH - IMPORTANCE_LOW)
|
||||
@ -388,10 +390,13 @@ class Game:
|
||||
points = []
|
||||
|
||||
# By default, use the existing frontline conflict position
|
||||
for conflict in self.theater.conflicts():
|
||||
points.append(Conflict.frontline_position(self.theater, conflict[0], conflict[1])[0])
|
||||
points.append(conflict[0].position)
|
||||
points.append(conflict[1].position)
|
||||
for front_line in self.theater.conflicts():
|
||||
position = Conflict.frontline_position(self.theater,
|
||||
front_line.control_point_a,
|
||||
front_line.control_point_b)
|
||||
points.append(position[0])
|
||||
points.append(front_line.control_point_a.position)
|
||||
points.append(front_line.control_point_b.position)
|
||||
|
||||
# If there is no conflict take the center point between the two nearest opposing bases
|
||||
if len(points) == 0:
|
||||
|
||||
@ -253,7 +253,9 @@ class Operation:
|
||||
|
||||
# Generate ground units on frontline everywhere
|
||||
jtacs: List[JtacInfo] = []
|
||||
for player_cp, enemy_cp in self.game.theater.conflicts(True):
|
||||
for front_line in self.game.theater.conflicts(True):
|
||||
player_cp = front_line.control_point_a
|
||||
enemy_cp = front_line.control_point_b
|
||||
conflict = Conflict.frontline_cas_conflict(self.attacker_name, self.defender_name,
|
||||
self.current_mission.country(self.attacker_country),
|
||||
self.current_mission.country(self.defender_country),
|
||||
|
||||
@ -194,14 +194,10 @@ class BriefingGenerator(MissionInfoGenerator):
|
||||
|
||||
conflict_number = 0
|
||||
|
||||
for c in self.game.theater.conflicts():
|
||||
for front_line in self.game.theater.conflicts(from_player=True):
|
||||
conflict_number = conflict_number + 1
|
||||
if c[0].captured:
|
||||
player_base = c[0]
|
||||
enemy_base = c[1]
|
||||
else:
|
||||
player_base = c[1]
|
||||
enemy_base = c[0]
|
||||
player_base = front_line.control_point_a
|
||||
enemy_base = front_line.control_point_b
|
||||
|
||||
has_numerical_superiority = player_base.base.total_armor > enemy_base.base.total_armor
|
||||
self.description += self.__random_frontline_sentence(player_base.name, enemy_base.name)
|
||||
|
||||
@ -98,7 +98,9 @@ class VisualGenerator:
|
||||
self.game = game
|
||||
|
||||
def _generate_frontline_smokes(self):
|
||||
for from_cp, to_cp in self.game.theater.conflicts():
|
||||
for front_line in self.game.theater.conflicts():
|
||||
from_cp = front_line.control_point_a
|
||||
to_cp = front_line.control_point_b
|
||||
if from_cp.is_global or to_cp.is_global:
|
||||
continue
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, TYPE_CHECKING
|
||||
|
||||
from dcs.mapping import Point
|
||||
from dcs.terrain import (
|
||||
@ -17,6 +16,9 @@ from dcs.terrain.terrain import Terrain
|
||||
from .controlpoint import ControlPoint
|
||||
from .landmap import Landmap, load_landmap, poly_contains
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import FrontLine
|
||||
|
||||
SIZE_TINY = 150
|
||||
SIZE_SMALL = 600
|
||||
SIZE_REGULAR = 1000
|
||||
@ -125,10 +127,11 @@ class ConflictTheater:
|
||||
def player_points(self) -> List[ControlPoint]:
|
||||
return [point for point in self.controlpoints if point.captured]
|
||||
|
||||
def conflicts(self, from_player=True) -> Iterator[Tuple[ControlPoint, ControlPoint]]:
|
||||
def conflicts(self, from_player=True) -> Iterator[FrontLine]:
|
||||
from . import FrontLine # Circular import that needs to be resolved.
|
||||
for cp in [x for x in self.controlpoints if x.captured == from_player]:
|
||||
for connected_point in [x for x in cp.connected_points if x.captured != from_player]:
|
||||
yield cp, connected_point
|
||||
yield FrontLine(cp, connected_point)
|
||||
|
||||
def enemy_points(self) -> List[ControlPoint]:
|
||||
return [point for point in self.controlpoints if not point.captured]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user