mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Reset game state on new turn.
This may not be the way to do this long term, but it is how the old map works so it's at least not a regression. It might be better to generate events for the between-turn changes in state instead. https://github.com/dcs-liberation/dcs_liberation/issues/2039
This commit is contained in:
@@ -307,6 +307,7 @@ class Game:
|
||||
with logged_duration("Turn initialization"):
|
||||
self.initialize_turn(events)
|
||||
|
||||
events.begin_new_turn()
|
||||
EventStream.put_nowait(events)
|
||||
|
||||
# Autosave progress
|
||||
|
||||
@@ -35,6 +35,7 @@ class GameUpdateEventsJs(BaseModel):
|
||||
updated_control_points: set[int]
|
||||
reset_on_map_center: LeafletLatLon | None
|
||||
game_unloaded: bool
|
||||
new_turn: bool
|
||||
|
||||
@classmethod
|
||||
def from_events(
|
||||
@@ -85,4 +86,5 @@ class GameUpdateEventsJs(BaseModel):
|
||||
updated_control_points=events.updated_control_points,
|
||||
reset_on_map_center=recenter_map,
|
||||
game_unloaded=events.game_unloaded,
|
||||
new_turn=events.new_turn,
|
||||
)
|
||||
|
||||
@@ -36,6 +36,7 @@ class GameUpdateEvents:
|
||||
updated_control_points: set[int] = field(default_factory=set)
|
||||
reset_on_map_center: LatLng | None = None
|
||||
game_unloaded: bool = False
|
||||
new_turn: bool = False
|
||||
shutting_down: bool = False
|
||||
|
||||
@property
|
||||
@@ -136,6 +137,10 @@ class GameUpdateEvents:
|
||||
self.game_unloaded = False
|
||||
return self
|
||||
|
||||
def begin_new_turn(self) -> GameUpdateEvents:
|
||||
self.new_turn = True
|
||||
return self
|
||||
|
||||
def shut_down(self) -> GameUpdateEvents:
|
||||
self.shutting_down = True
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user