Fixes #1449 and updates another area where the Heading class can apply (#1451)

This commit is contained in:
bgreman 2021-07-22 15:30:46 -04:00 committed by GitHub
parent edbd3de4a4
commit 1094085872
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -12,7 +12,7 @@ from dcs.weather import CloudPreset, Weather as PydcsWeather, Wind
from game.savecompat import has_save_compat_for from game.savecompat import has_save_compat_for
from game.settings import Settings from game.settings import Settings
from game.utils import Distance, meters, interpolate, Pressure, inches_hg from game.utils import Distance, Heading, meters, interpolate, Pressure, inches_hg
if TYPE_CHECKING: if TYPE_CHECKING:
from game.theater import ConflictTheater from game.theater import ConflictTheater
@ -149,7 +149,7 @@ class Weather:
@staticmethod @staticmethod
def random_wind(minimum: int, maximum: int) -> WindConditions: def random_wind(minimum: int, maximum: int) -> WindConditions:
wind_direction = random.randint(0, 360) wind_direction = Heading.random()
at_0m_factor = 1 at_0m_factor = 1
at_2000m_factor = 2 at_2000m_factor = 2
at_8000m_factor = 3 at_8000m_factor = 3
@ -157,9 +157,9 @@ class Weather:
return WindConditions( return WindConditions(
# Always some wind to make the smoke move a bit. # Always some wind to make the smoke move a bit.
at_0m=Wind(wind_direction, max(1, base_wind * at_0m_factor)), at_0m=Wind(wind_direction.degrees, max(1, base_wind * at_0m_factor)),
at_2000m=Wind(wind_direction, base_wind * at_2000m_factor), at_2000m=Wind(wind_direction.degrees, base_wind * at_2000m_factor),
at_8000m=Wind(wind_direction, base_wind * at_8000m_factor), at_8000m=Wind(wind_direction.degrees, base_wind * at_8000m_factor),
) )
@staticmethod @staticmethod

View File

@ -425,7 +425,7 @@ class GenericCarrierGenerator(GenericGroundObjectGenerator[GenericCarrierGroundO
return ship return ship
def steam_into_wind(self, group: ShipGroup) -> Optional[Heading]: def steam_into_wind(self, group: ShipGroup) -> Optional[Heading]:
wind = self.game.conditions.weather.wind.at_0m.direction wind = self.game.conditions.weather.wind.at_0m
brc = Heading.from_degrees(wind.direction).opposite brc = Heading.from_degrees(wind.direction).opposite
# Aim for 25kts over the deck. # Aim for 25kts over the deck.
carrier_speed = knots(25) - mps(wind.speed) carrier_speed = knots(25) - mps(wind.speed)