Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfarukfirat committed May 11, 2024
1 parent f27d8ab commit b0009ad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion API/Apps/Tournament/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
path('profile/<int:profile_id>', create),
path('<int:profile_id>/<uuid:tournament_id>', get_tournaments),
path('join/<int:tournament_id>', join),
path('delete/<int:tournament_id>', delete),
path('delete/<uuid:tournament_id>', delete),
path('profile/w/<str:nickname>/', websocket_test)

]
Expand Down
11 changes: 10 additions & 1 deletion API/Apps/Tournament/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,19 @@ def checkMatch(self, profile_id1, tournament_id):
winners.append(last_round.participants.first())
new_round.participants.set(winners)
tournament.rounds.add(new_round)

all_games = []
for i in range(0, len(winners), 2):
if i + 1 < len(winners):
game = Game.objects.create(player1=winners[i], player2=winners[i + 1])
game_id = str(game.id)
game.tournament_id = self.tournament_id
player1_nick = str(winners[i].nickname)
player2_nick = str(winners[i + 1].nickname)
game_info = {
"game_id": game_id,
"players": [player1_nick, player2_nick]
}
all_games.append(game_info)
new_round.matches.add(game)
new_round.participants.remove(winners[i])
new_round.participants.remove(winners[i + 1])
Expand Down

0 comments on commit b0009ad

Please sign in to comment.