change tournament leave function

This commit is contained in:
2024-11-14 14:27:09 +01:00
parent 82b3649f0c
commit da5d244449
2 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,7 @@
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ # # By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2024/10/04 17:17:07 by tomoron #+# #+# # # Created: 2024/10/04 17:17:07 by tomoron #+# #+# #
# Updated: 2024/11/14 13:42:03 by tomoron ### ########.fr # # Updated: 2024/11/14 13:46:45 by tomoron ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -69,13 +69,13 @@ class Tournament:
return(-1) return(-1)
def leave(self, socket): def leave(self, socket):
if(self.started):
return;
index = self.playerFromSocket(socket) index = self.playerFromSocket(socket)
if(index == -1): if(index == -1):
return; return;
self.players.pop(index)
socket.tournament = None socket.tournament = None
if(self.started):
return;
self.players.pop(index)
self.broadcast({"action":2,"id":index}) self.broadcast({"action":2,"id":index})
def join(self, socket, skin=0, goal=0, isBot=False): def join(self, socket, skin=0, goal=0, isBot=False):

View File

@ -6,7 +6,7 @@
# By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ # # By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2024/10/22 01:37:00 by tomoron #+# #+# # # Created: 2024/10/22 01:37:00 by tomoron #+# #+# #
# Updated: 2024/10/22 01:37:12 by tomoron ### ########.fr # # Updated: 2024/11/14 13:59:35 by tomoron ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -38,7 +38,7 @@ class TournamentGame:
print("waiting for player") print("waiting for player")
nbLoop += 1 nbLoop += 1
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
if(not l.socket.online or not r.socket.online): if(not l.socket.tournament == self.tournament or not r.socket.tournament == self.tournament):
print("player is not online, opponent is winner") print("player is not online, opponent is winner")
self.winner = l if l.socket.online else r self.winner = l if l.socket.online else r
return; return;