game: core: use server game calulation form
This commit is contained in:
22
games/objects/GameManager.py
Normal file
22
games/objects/GameManager.py
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
from .Game import Game
|
||||
from ..models import GameModel
|
||||
|
||||
class GameManager():
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._game_list: [Game] = []
|
||||
|
||||
def get(self, game_id: int):
|
||||
|
||||
if (not GameModel.objects.filter(pk = game_id, started = True, finished = False).exists()):
|
||||
return None
|
||||
|
||||
for game in self._game_list:
|
||||
game: Game
|
||||
if (game.game_id == game_id):
|
||||
return game
|
||||
|
||||
return Game(game_id)
|
||||
|
||||
|
Reference in New Issue
Block a user