dcs-retribution/game/server/dependencies.py
2022-02-22 18:49:12 -08:00

26 lines
580 B
Python

from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from game import Game
from qt_ui.models import GameModel
class GameContext:
_game_model: GameModel
@classmethod
def set_model(cls, game_model: GameModel) -> None:
cls._game_model = game_model
@classmethod
def get(cls) -> Game:
if cls._game_model.game is None:
raise RuntimeError("GameContext has no Game set")
return cls._game_model.game
@classmethod
def get_model(cls) -> GameModel:
return cls._game_model