game: core: rename member to player

This commit is contained in:
starnakin 2023-12-26 21:32:20 +01:00
parent 9bb6a32c70
commit 98ec43e7b9
2 changed files with 11 additions and 11 deletions

View File

@ -7,15 +7,15 @@ class GameModel(models.Model):
started = models.BooleanField(default=False)
winner_id = models.IntegerField(default=-1)
def create(self, users_id: [int]):
def create(self, players_id: [int]):
self.save()
for user_id in users_id:
GameMembersModel(game_id=self.pk, member_id=user_id).save()
for player_id in players_id:
GameMembersModel(game_id = self.pk, player_id = player_id).save()
return self.pk
def get_users(self):
return list(GameMembersModel.objects.filter(self.pk))
def get_players_id(self):
return [game_member.member_id for game_member in GameMembersModel.objects.filter(self.pk)]
class GameMembersModel(models.Model):
game_id = models.IntegerField()
member_id = models.IntegerField()
player_id = models.IntegerField()

View File

@ -20,17 +20,17 @@ class TournamentModel(models.Model):
started = models.BooleanField(default=False)
finished = models.BooleanField(default=False)
def create_game(self, level, users_id):
game_id = GameModel().create(users_id=users_id)
TournamentGamesModel(game_id=game_id, tournament_id=self.pk, tournament_level=level).save()
def create_game(self, level, players_id):
game_id = GameModel().create(players_id = players_id)
TournamentGamesModel(game_id = game_id, tournament_id = self.pk, tournament_level = level).save()
return game_id
def get_games_id_by_level(self, level):
tmp = TournamentGamesModel.objects.filter(tournament_id=self.pk, tournament_level=level)
tmp = TournamentGamesModel.objects.filter(tournament_id = self.pk, tournament_level = level)
return [instance.game_id for instance in tmp]
def get_games_id(self):
return list(TournamentGamesModel.objects.filter(tournament_id=self.pk))
return [tournament_game.game_id for tournament_game in TournamentGamesModel.objects.filter(tournament_id = self.pk)]
def get_players_id(self):
return [model.participant_id for model in TournamentParticipantsModel.objects.filter(tournament_id=self.pk)]