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