fix
This commit is contained in:
parent
98ec43e7b9
commit
35a2f273f9
@ -3,9 +3,9 @@ from django.db import models
|
||||
# Create your models here.
|
||||
class GameModel(models.Model):
|
||||
|
||||
finished = models.BooleanField(default=False)
|
||||
started = models.BooleanField(default=False)
|
||||
winner_id = models.IntegerField(default=-1)
|
||||
finished = models.BooleanField(default = False)
|
||||
started = models.BooleanField(default = False)
|
||||
winner_id = models.IntegerField(default = -1)
|
||||
|
||||
def create(self, players_id: [int]):
|
||||
self.save()
|
||||
@ -14,7 +14,7 @@ class GameModel(models.Model):
|
||||
return self.pk
|
||||
|
||||
def get_players_id(self):
|
||||
return [game_member.member_id for game_member in GameMembersModel.objects.filter(self.pk)]
|
||||
return [game_member.member_id for game_member in GameMembersModel.objects.filter(game_id = self.pk)]
|
||||
|
||||
class GameMembersModel(models.Model):
|
||||
game_id = models.IntegerField()
|
||||
|
@ -13,12 +13,12 @@ from transcendence.abstract.AbstractRoomManager import AbstractRoomManager
|
||||
# Create your models here.tu
|
||||
class TournamentModel(models.Model):
|
||||
|
||||
name = models.CharField(max_length=100)
|
||||
name = models.CharField(max_length = 100)
|
||||
nb_players = models.IntegerField()
|
||||
nb_players_by_game = models.IntegerField()
|
||||
level = models.IntegerField()
|
||||
started = models.BooleanField(default=False)
|
||||
finished = models.BooleanField(default=False)
|
||||
started = models.BooleanField(default = False)
|
||||
finished = models.BooleanField(default = False)
|
||||
|
||||
def create_game(self, level, players_id):
|
||||
game_id = GameModel().create(players_id = players_id)
|
||||
@ -36,11 +36,11 @@ class TournamentModel(models.Model):
|
||||
return [model.participant_id for model in TournamentParticipantsModel.objects.filter(tournament_id=self.pk)]
|
||||
|
||||
def is_a_participant(self, participant_id: int):
|
||||
return TournamentParticipantsModel.objects.filter(participant_id=participant_id, tournament_id=self.pk).exists()
|
||||
return TournamentParticipantsModel.objects.filter(participant_id = participant_id, tournament_id = self.pk).exists()
|
||||
|
||||
def add_participants(self, participants_id: [int]):
|
||||
for participant_id in participants_id:
|
||||
TournamentParticipantsModel(tournament_id=self.pk, participant_id=participant_id).save()
|
||||
TournamentParticipantsModel(tournament_id = self.pk, participant_id = participant_id).save()
|
||||
|
||||
def start(self, participants_id: [int]):
|
||||
self.started = True
|
||||
@ -93,7 +93,7 @@ class TournamentRoom(AbstractRoom):
|
||||
def __init__(self, room_manager, tournament_id: int):
|
||||
super().__init__(room_manager)
|
||||
self.tournament_id = tournament_id
|
||||
self.tournament = TournamentModel.objects.get(pk=tournament_id)
|
||||
self.tournament = TournamentModel.objects.get(pk = tournament_id)
|
||||
|
||||
def start(self):
|
||||
self.broadcast("tournament_start")
|
||||
@ -144,7 +144,7 @@ class TournamentRoomManager(AbstractRoomManager):
|
||||
if (room.tournament_id == tournament_id):
|
||||
return room
|
||||
|
||||
if (TournamentModel.objects.filter(pk = tournament_id, finished=False).exists()):
|
||||
if (TournamentModel.objects.filter(pk = tournament_id).exists()):
|
||||
room = TournamentRoom(self, tournament_id)
|
||||
self.append(room)
|
||||
return room
|
||||
|
Loading…
Reference in New Issue
Block a user