mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
The contents are completely uninteresting, but at least it's visible. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/978.
29 lines
879 B
Python
29 lines
879 B
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Iterator
|
|
from contextlib import contextmanager
|
|
from typing import TYPE_CHECKING
|
|
|
|
from game.server import EventStream
|
|
from game.turnstate import TurnState
|
|
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
|
from qt_ui.windows.gameoverdialog import GameOverDialog
|
|
|
|
if TYPE_CHECKING:
|
|
from game import Game
|
|
from game.sim import GameUpdateEvents
|
|
|
|
|
|
@contextmanager
|
|
def game_state_modifying_cheat_context(game: Game) -> Iterator[GameUpdateEvents]:
|
|
with EventStream.event_context() as events:
|
|
yield events
|
|
|
|
state = game.check_win_loss()
|
|
if state is not TurnState.CONTINUE:
|
|
dialog = GameOverDialog(won=state is TurnState.WIN)
|
|
dialog.exec()
|
|
else:
|
|
game.initialize_turn(events)
|
|
GameUpdateSignal.get_instance().updateGame(game)
|