add time before starting next tournament game, to wait for the player to be back on the tournament page
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
# By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ #
|
# By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/10/19 18:29:36 by tomoron #+# #+# #
|
# Created: 2024/10/19 18:29:36 by tomoron #+# #+# #
|
||||||
# Updated: 2024/10/19 22:41:25 by tomoron ### ########.fr #
|
# Updated: 2024/10/20 15:36:33 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -35,6 +35,9 @@ class Bot(Player):
|
|||||||
asyncio.create_task(self.goToObjectiveLoop())
|
asyncio.create_task(self.goToObjectiveLoop())
|
||||||
print("I am a bot, boop boop beep boop")
|
print("I am a bot, boop boop beep boop")
|
||||||
|
|
||||||
|
def isTournamentReady(self):
|
||||||
|
return(True);
|
||||||
|
|
||||||
def createTempBall(self):
|
def createTempBall(self):
|
||||||
res = Ball()
|
res = Ball()
|
||||||
res.setObstacles(self.game.obstacles)
|
res.setObstacles(self.game.obstacles)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/10/06 16:33:56 by tomoron #+# #+# #
|
# Created: 2024/10/06 16:33:56 by tomoron #+# #+# #
|
||||||
# Updated: 2024/10/19 22:41:38 by tomoron ### ########.fr #
|
# Updated: 2024/10/20 15:42:21 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -46,4 +46,4 @@ class GameSettings:
|
|||||||
maxScore = 2
|
maxScore = 2
|
||||||
|
|
||||||
maxPlayerSpeed = 6
|
maxPlayerSpeed = 6
|
||||||
BotMovement = True
|
BotMovement = False
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ #
|
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/10/05 03:22:32 by tomoron #+# #+# #
|
# Created: 2024/10/05 03:22:32 by tomoron #+# #+# #
|
||||||
# Updated: 2024/10/13 21:24:16 by tomoron ### ########.fr #
|
# Updated: 2024/10/20 15:37:20 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ class Player():
|
|||||||
def __init__(self, socket):
|
def __init__(self, socket):
|
||||||
self.socket = socket
|
self.socket = socket
|
||||||
self.ready = False
|
self.ready = False
|
||||||
|
self.tournamentReady = False;
|
||||||
self.pos = {"pos":0, "up": False}
|
self.pos = {"pos":0, "up": False}
|
||||||
self.skin = 0
|
self.skin = 0
|
||||||
self.goal = 0
|
self.goal = 0
|
||||||
@ -21,6 +22,11 @@ class Player():
|
|||||||
def __del__(self):
|
def __del__(self):
|
||||||
print("player destroy")
|
print("player destroy")
|
||||||
|
|
||||||
|
def isTournamentReady(self):
|
||||||
|
return(self.tournamentReady)
|
||||||
|
|
||||||
def setGame(self, game):
|
def setGame(self, game):
|
||||||
|
self.ready = False;
|
||||||
|
self.tournamentReady = False;
|
||||||
self.game = game
|
self.game = game
|
||||||
self.socket.game = game
|
self.socket.game = game
|
||||||
|
@ -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/10/19 21:53:02 by tomoron ### ########.fr #
|
# Updated: 2024/10/20 15:30:13 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -49,6 +49,7 @@ class Tournament:
|
|||||||
|
|
||||||
def sendAllInfo(self, socket):
|
def sendAllInfo(self, socket):
|
||||||
players = []
|
players = []
|
||||||
|
self.players[self.playerFromSocket(socket)].tournamentReady = True
|
||||||
for x in range(len(self.players)):
|
for x in range(len(self.players)):
|
||||||
players.append({"id":x,"username":self.players[x].socket.username, "pfp":self.players[x].socket.pfp})
|
players.append({"id":x,"username":self.players[x].socket.username, "pfp":self.players[x].socket.pfp})
|
||||||
socket.sync_send("tournament",{"action":5, "players":players, "messages" : self.messages, "history": self.history})
|
socket.sync_send("tournament",{"action":5, "players":players, "messages" : self.messages, "history": self.history})
|
||||||
|
@ -21,18 +21,21 @@ class TournamentGame:
|
|||||||
self.left = left
|
self.left = left
|
||||||
asyncio.create_task(self.loop())
|
asyncio.create_task(self.loop())
|
||||||
|
|
||||||
def startGame(self):
|
async def startGame(self):
|
||||||
l = None
|
l = None
|
||||||
r = None
|
r = None
|
||||||
print("start new game")
|
print("start new game")
|
||||||
if(isinstance(self.left,TournamentGame)):
|
if(isinstance(self.left,TournamentGame)):
|
||||||
self.game = Game(self.left.winner, self.right.winner, self.tournament.code)
|
|
||||||
l = self.left.winner
|
l = self.left.winner
|
||||||
r = self.right.winner
|
r = self.right.winner
|
||||||
else:
|
else:
|
||||||
self.game = Game(self.left, self.right, self.tournament.code)
|
|
||||||
l = self.left
|
l = self.left
|
||||||
r = self.right
|
r = self.right
|
||||||
|
while (not l.isTournamentReady() or not r.isTournamentReady()):
|
||||||
|
print("waiting for player")
|
||||||
|
await asyncio.sleep(0.1)
|
||||||
|
await asyncio.sleep(3)
|
||||||
|
self.game = Game(l, r, self.tournament.code)
|
||||||
l.socket.sync_send("tournament", {
|
l.socket.sync_send("tournament", {
|
||||||
"action":4,
|
"action":4,
|
||||||
"id": r.socket.id,
|
"id": r.socket.id,
|
||||||
@ -57,11 +60,9 @@ class TournamentGame:
|
|||||||
if(self.game == None):
|
if(self.game == None):
|
||||||
if(isinstance(self.left, TournamentGame)):
|
if(isinstance(self.left, TournamentGame)):
|
||||||
if(self.left.winner != None and self.right.winner != None):
|
if(self.left.winner != None and self.right.winner != None):
|
||||||
await asyncio.sleep(3)
|
await self.startGame()
|
||||||
self.startGame()
|
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(3)
|
await self.startGame()
|
||||||
self.startGame()
|
|
||||||
else:
|
else:
|
||||||
if(self.game.winner != None):
|
if(self.game.winner != None):
|
||||||
print("game ended, winner is", self.game.pWinner.socket.username)
|
print("game ended, winner is", self.game.pWinner.socket.username)
|
||||||
|
Reference in New Issue
Block a user