mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Operation refactor cleanup
Fix bug in closest cp algorithm
This commit is contained in:
parent
967574820f
commit
34a7a37409
@ -8,7 +8,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class AirWarEvent(Event):
|
||||
"""An Event centered on the overall Air War"""
|
||||
"""Event handler for the air battle"""
|
||||
|
||||
def __str__(self):
|
||||
return "Frontline attack"
|
||||
return "AirWar"
|
||||
|
||||
@ -38,7 +38,6 @@ class Event:
|
||||
location = None # type: Point
|
||||
from_cp = None # type: ControlPoint
|
||||
to_cp = None # type: ControlPoint
|
||||
operation = Operation
|
||||
difficulty = 1 # type: int
|
||||
BONUS_BASE = 5
|
||||
|
||||
@ -62,9 +61,9 @@ class Event:
|
||||
return int(math.log(self.to_cp.importance + 1, DIFFICULTY_LOG_BASE) * self.BONUS_BASE)
|
||||
|
||||
def generate(self) -> UnitMap:
|
||||
self.operation.prepare(self.game)
|
||||
unit_map = self.operation.generate()
|
||||
self.operation.current_mission.save(
|
||||
Operation.prepare(self.game)
|
||||
unit_map = Operation.generate()
|
||||
Operation.current_mission.save(
|
||||
persistency.mission_path_for("liberation_nextturn.miz"))
|
||||
return unit_map
|
||||
|
||||
|
||||
@ -193,7 +193,7 @@ class Game:
|
||||
if isinstance(event, Event):
|
||||
return event and event.attacker_name and event.attacker_name == self.player_name
|
||||
else:
|
||||
raise RuntimeError(f"{event} was passed when an expected")
|
||||
raise RuntimeError(f"{event} was passed when an Event type was expected")
|
||||
|
||||
def on_load(self) -> None:
|
||||
LuaPluginManager.load_settings(self.settings)
|
||||
|
||||
@ -485,6 +485,7 @@ class ConflictTheater:
|
||||
dist = cp.position.distance_to_point(control_point.position)
|
||||
if not closest_distance:
|
||||
closest_distance = dist
|
||||
distances[cp.id] = dist
|
||||
if dist < closest_distance:
|
||||
distances[cp.id] = dist
|
||||
closest_cp_id = min(distances, key=distances.get) # type: ignore
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user