game: core: rename member to player
This commit is contained in:
parent
9bb6a32c70
commit
98ec43e7b9
@ -7,15 +7,15 @@ class GameModel(models.Model):
|
|||||||
started = models.BooleanField(default=False)
|
started = models.BooleanField(default=False)
|
||||||
winner_id = models.IntegerField(default=-1)
|
winner_id = models.IntegerField(default=-1)
|
||||||
|
|
||||||
def create(self, users_id: [int]):
|
def create(self, players_id: [int]):
|
||||||
self.save()
|
self.save()
|
||||||
for user_id in users_id:
|
for player_id in players_id:
|
||||||
GameMembersModel(game_id=self.pk, member_id=user_id).save()
|
GameMembersModel(game_id = self.pk, player_id = player_id).save()
|
||||||
return self.pk
|
return self.pk
|
||||||
|
|
||||||
def get_users(self):
|
def get_players_id(self):
|
||||||
return list(GameMembersModel.objects.filter(self.pk))
|
return [game_member.member_id for game_member in GameMembersModel.objects.filter(self.pk)]
|
||||||
|
|
||||||
class GameMembersModel(models.Model):
|
class GameMembersModel(models.Model):
|
||||||
game_id = models.IntegerField()
|
game_id = models.IntegerField()
|
||||||
member_id = models.IntegerField()
|
player_id = models.IntegerField()
|
@ -20,8 +20,8 @@ class TournamentModel(models.Model):
|
|||||||
started = models.BooleanField(default=False)
|
started = models.BooleanField(default=False)
|
||||||
finished = models.BooleanField(default=False)
|
finished = models.BooleanField(default=False)
|
||||||
|
|
||||||
def create_game(self, level, users_id):
|
def create_game(self, level, players_id):
|
||||||
game_id = GameModel().create(users_id=users_id)
|
game_id = GameModel().create(players_id = players_id)
|
||||||
TournamentGamesModel(game_id = game_id, tournament_id = self.pk, tournament_level = level).save()
|
TournamentGamesModel(game_id = game_id, tournament_id = self.pk, tournament_level = level).save()
|
||||||
return game_id
|
return game_id
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ class TournamentModel(models.Model):
|
|||||||
return [instance.game_id for instance in tmp]
|
return [instance.game_id for instance in tmp]
|
||||||
|
|
||||||
def get_games_id(self):
|
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):
|
def get_players_id(self):
|
||||||
return [model.participant_id for model in TournamentParticipantsModel.objects.filter(tournament_id=self.pk)]
|
return [model.participant_id for model in TournamentParticipantsModel.objects.filter(tournament_id=self.pk)]
|
||||||
|
Loading…
Reference in New Issue
Block a user