tournament: use tournamentGameModel instead gameModel

This commit is contained in:
2024-04-25 16:11:27 +02:00
parent c4407adffb
commit ff230bccf6
3 changed files with 35 additions and 18 deletions

View File

@ -1,4 +1,5 @@
from __future__ import annotations
from typing import Any
from games.models import GameModel
@ -96,10 +97,20 @@ class TournamentGameModel(GameModel):
round = models.IntegerField()
pos = models.IntegerField()
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
from .consumers import tournament_manager
self.room = tournament_manager.get(self.tournament)
def start(self):
super().start()
self.room.set_game_as_started(self)
def finish(self, winner_id):
super().finish(winner_id)
from .consumers import tournament_manager
room = tournament_manager.get(self.tournament)
room.set_game_as_finished(self)
self.room.set_game_as_finished(self)