From 98ec43e7b98c61db5314cb1c6d0789486de042d1 Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 26 Dec 2023 21:32:20 +0100 Subject: [PATCH] game: core: rename member to player --- games/models.py | 12 ++++++------ tournament/models.py | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/games/models.py b/games/models.py index 514e52c..81c2d60 100644 --- a/games/models.py +++ b/games/models.py @@ -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() \ No newline at end of file + player_id = models.IntegerField() \ No newline at end of file diff --git a/tournament/models.py b/tournament/models.py index 81ee3dc..8ab156c 100644 --- a/tournament/models.py +++ b/tournament/models.py @@ -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)]