From 23742392383c4af73d6738ccc203b1a326847d35 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sat, 16 Jan 2021 14:01:53 -0800 Subject: [PATCH] Fix doctrine inversion in threat zones. The threat zone is the zone project by the given coaltition, not against it. --- game/threatzones.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/game/threatzones.py b/game/threatzones.py index 9acfa5b9..b8ea85ac 100644 --- a/game/threatzones.py +++ b/game/threatzones.py @@ -13,7 +13,7 @@ from shapely.geometry import ( from shapely.geometry.base import BaseGeometry from shapely.ops import nearest_points, unary_union -from game.utils import Distance, meters, nautical_miles +from game.utils import nautical_miles from gen.flights.flight import Flight if TYPE_CHECKING: @@ -80,7 +80,19 @@ class ThreatZones: @classmethod def for_faction(cls, game: Game, player: bool) -> ThreatZones: - opposing_doctrine = game.faction_for(not player).doctrine + """Generates the threat zones projected by the given coalition. + + Args: + game: The game to generate the threat zone for. + player: True if the coalition projecting the threat zone belongs to + the player. + + Returns: + The threat zones projected by the given coalition. If the threat + zone belongs to the player, it is the zone that will be avoided by + the enemy and vice versa. + """ + doctrine = game.faction_for(player).doctrine airbases = [] air_defenses = [] @@ -90,8 +102,8 @@ class ThreatZones: if control_point.runway_is_operational(): point = ShapelyPoint(control_point.position.x, control_point.position.y) - cap_threat_range = (opposing_doctrine.cap_max_distance_from_cp + - opposing_doctrine.cap_engagement_range) + cap_threat_range = (doctrine.cap_max_distance_from_cp + + doctrine.cap_engagement_range) airbases.append(point.buffer(cap_threat_range.meters)) for tgo in control_point.ground_objects: