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> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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())
|
||||
print("I am a bot, boop boop beep boop")
|
||||
|
||||
def isTournamentReady(self):
|
||||
return(True);
|
||||
|
||||
def createTempBall(self):
|
||||
res = Ball()
|
||||
res.setObstacles(self.game.obstacles)
|
||||
|
@ -6,7 +6,7 @@
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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
|
||||
|
||||
maxPlayerSpeed = 6
|
||||
BotMovement = True
|
||||
BotMovement = False
|
||||
|
@ -6,7 +6,7 @@
|
||||
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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,13 +14,19 @@ class Player():
|
||||
def __init__(self, socket):
|
||||
self.socket = socket
|
||||
self.ready = False
|
||||
self.tournamentReady = False;
|
||||
self.pos = {"pos":0, "up": False}
|
||||
self.skin = 0
|
||||
self.goal = 0
|
||||
|
||||
def __del__(self):
|
||||
print("player destroy")
|
||||
|
||||
def isTournamentReady(self):
|
||||
return(self.tournamentReady)
|
||||
|
||||
def setGame(self, game):
|
||||
self.ready = False;
|
||||
self.tournamentReady = False;
|
||||
self.game = game
|
||||
self.socket.game = game
|
||||
|
@ -6,7 +6,7 @@
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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):
|
||||
players = []
|
||||
self.players[self.playerFromSocket(socket)].tournamentReady = True
|
||||
for x in range(len(self.players)):
|
||||
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})
|
||||
|
@ -21,18 +21,21 @@ class TournamentGame:
|
||||
self.left = left
|
||||
asyncio.create_task(self.loop())
|
||||
|
||||
def startGame(self):
|
||||
async def startGame(self):
|
||||
l = None
|
||||
r = None
|
||||
print("start new game")
|
||||
if(isinstance(self.left,TournamentGame)):
|
||||
self.game = Game(self.left.winner, self.right.winner, self.tournament.code)
|
||||
l = self.left.winner
|
||||
r = self.right.winner
|
||||
else:
|
||||
self.game = Game(self.left, self.right, self.tournament.code)
|
||||
l = self.left
|
||||
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", {
|
||||
"action":4,
|
||||
"id": r.socket.id,
|
||||
@ -57,11 +60,9 @@ class TournamentGame:
|
||||
if(self.game == None):
|
||||
if(isinstance(self.left, TournamentGame)):
|
||||
if(self.left.winner != None and self.right.winner != None):
|
||||
await asyncio.sleep(3)
|
||||
self.startGame()
|
||||
await self.startGame()
|
||||
else:
|
||||
await asyncio.sleep(3)
|
||||
self.startGame()
|
||||
await self.startGame()
|
||||
else:
|
||||
if(self.game.winner != None):
|
||||
print("game ended, winner is", self.game.pWinner.socket.username)
|
||||
|
Reference in New Issue
Block a user