number of fixes

This commit is contained in:
Vasyl Horbachenko
2018-06-14 03:44:24 +03:00
parent 8a783625ce
commit 064b9ba877
14 changed files with 124 additions and 76 deletions

View File

@@ -29,15 +29,18 @@ class AAConflictGenerator:
class ExtraAAConflictGenerator:
def __init__(self, mission: Mission, conflict: Conflict, theater: ConflictTheater, player_name: Country, enemy_name: Country):
def __init__(self, mission: Mission, conflict: Conflict, game, player_name: Country, enemy_name: Country):
self.mission = mission
self.theater = theater
self.game = game
self.conflict = conflict
self.player_name = player_name
self.enemy_name = enemy_name
def generate(self):
for cp in self.theater.controlpoints:
for cp in self.game.theater.controlpoints:
if cp.is_global:
continue
if cp.position.distance_to_point(self.conflict.position) > EXTRA_AA_MIN_DISTANCE:
country_name = cp.captured and self.player_name or self.enemy_name

View File

@@ -24,6 +24,7 @@ INTERCEPT_ATTACKERS_HEADING = -45, 45
INTERCEPT_DEFENDERS_HEADING = -10, 10
INTERCEPT_ATTACKERS_DISTANCE = 60000
INTERCEPT_DEFENDERS_DISTANCE = 30000
INTERCEPT_MAX_DISTANCE = 45000
class Conflict:
@@ -56,8 +57,13 @@ class Conflict:
return instance
@classmethod
def intercept_conflict(self, attacker: Country, defender: Country, position: Point, heading: int, radials: typing.List[int]):
def intercept_conflict(self, attacker: Country, defender: Country, from_cp, to_cp):
from theater.conflicttheater import SIZE_REGULAR
from theater.conflicttheater import ALL_RADIALS
heading = from_cp.position.heading_between_point(to_cp.position)
distance = min(from_cp.position.distance_to_point(to_cp.position) / 2, INTERCEPT_MAX_DISTANCE)
position = from_cp.position.point_from_heading(heading, distance)
instance = self()
instance.attackers_side = attacker
@@ -65,7 +71,7 @@ class Conflict:
instance.position = position
instance.size = SIZE_REGULAR
instance.radials = radials
instance.radials = ALL_RADIALS
instance.air_attackers_location = instance.position.point_from_heading(random.randint(*INTERCEPT_ATTACKERS_HEADING) + heading, INTERCEPT_ATTACKERS_DISTANCE)
instance.air_defenders_location = instance.position.point_from_heading(random.randint(*INTERCEPT_DEFENDERS_HEADING) + heading, INTERCEPT_DEFENDERS_DISTANCE)

View File

@@ -7,22 +7,34 @@ from theater.weatherforecast import WeatherForecast
RANDOM_TIME = {
"night": 5,
"dusk": 25,
"down": 50,
"night": 0,
"dusk": 5,
"dawn": 35,
"noon": 75,
"day": 100,
}
class EnvironmentSettingsGenerator:
def __init__(self, mission: Mission):
def __init__(self, mission: Mission, game):
self.mission = mission
self.game = game
def generate(self):
self.mission.random_weather = True
time_roll = random.randint(0, 100)
time_period = [k for k, v in RANDOM_TIME.items() if v > time_roll][-1]
self.mission.random_daytime(time_period)
time_period = None
for k, v in RANDOM_TIME.items():
if v >= time_roll:
time_period = k
break
self.mission.random_daytime(time_period)
self.mission.weather.random(self.mission.start_time, self.mission.terrain)
for cp in self.game.theater.controlpoints:
if cp.is_global:
continue
player_coalition = self.game.player == "USA" and "blue" or "red"
enemy_coalition = player_coalition == "blue" and "red" or "blue"
self.mission.terrain.airport_by_id(cp.at.id).set_coalition(cp.captured and player_coalition or enemy_coalition)