add skin, goal and pfp in tournaments start request, add with_bot setting to matchmaking games
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
|
||||
# Updated: 2024/10/13 21:50:58 by tomoron ### ########.fr #
|
||||
# Updated: 2024/10/14 20:06:12 by tomoron ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -48,7 +48,7 @@ class Game:
|
||||
self.withBot = withBot
|
||||
|
||||
self.opponentLock = opponent
|
||||
if(1 or withBot):
|
||||
if(withBot):
|
||||
self.p1 = Bot(self)
|
||||
self.join(socket, skinId, goalId)
|
||||
elif(opponent != None):
|
||||
|
@ -6,7 +6,7 @@
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/10/04 17:17:07 by tomoron #+# #+# #
|
||||
# Updated: 2024/10/13 21:11:56 by tomoron ### ########.fr #
|
||||
# Updated: 2024/10/14 19:54:30 by tomoron ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -22,14 +22,14 @@ class Tournament:
|
||||
|
||||
playerLimit = 8
|
||||
levels = 3
|
||||
def __init__(self, socket, nbBot):
|
||||
def __init__(self, socket, nbBot, skin, goal):
|
||||
self.messages = []
|
||||
self.players = []
|
||||
self.nbBot = nbBot
|
||||
self.end = False
|
||||
self.genCode()
|
||||
Tournament.currentTournaments[self.code] = self
|
||||
self.join(socket)
|
||||
self.join(socket, skin, goal)
|
||||
|
||||
def genCode(self):
|
||||
nbChar = 4
|
||||
@ -72,7 +72,7 @@ class Tournament:
|
||||
socket.tournament = None
|
||||
self.broadcast({"action":2,"id":socket.id})
|
||||
|
||||
def join(self, socket, isBot=False):
|
||||
def join(self, socket, goal=0, skin=0, isBot=False):
|
||||
if(not isBot and socket.tournament != None):
|
||||
socket.sendError("already in a tournament", 9036)
|
||||
return
|
||||
@ -84,6 +84,8 @@ class Tournament:
|
||||
socket = player.socket
|
||||
else:
|
||||
player = Player(socket)
|
||||
player.skin = skin
|
||||
player.goal = goal
|
||||
socket.tournament = self
|
||||
self.players.append(player)
|
||||
socket.sync_send("tournament",{"action":0, "code":self.code})
|
||||
@ -92,7 +94,7 @@ class Tournament:
|
||||
self.start()
|
||||
if(len(self.players) == Tournament.playerLimit - self.nbBot):
|
||||
for x in range(self.nbBot):
|
||||
self.join(None, True)
|
||||
self.join(None, 0, 0, True)
|
||||
|
||||
def createGames(self, players, level=1):
|
||||
left = None
|
||||
|
@ -6,7 +6,7 @@
|
||||
# By: tomoron <marvin@42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/10/12 22:49:00 by tomoron #+# #+# #
|
||||
# Updated: 2024/10/13 22:01:59 by tomoron ### ########.fr #
|
||||
# Updated: 2024/10/14 20:10:13 by tomoron ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
import asyncio
|
||||
@ -34,12 +34,18 @@ class TournamentGame:
|
||||
l.sync_send("tournament", {
|
||||
"action":4,
|
||||
"id": r.id,
|
||||
"username":r.username
|
||||
"username":r.username,
|
||||
"skin" : r.skin,
|
||||
"goal": r.goal,
|
||||
"pfp": r.pfp
|
||||
})
|
||||
r.sync_send("tournament", {
|
||||
"action":4,
|
||||
"id": l.id,
|
||||
"username": l.username
|
||||
"username": l.username,
|
||||
"skin" : l.skin,
|
||||
"goal": l.goal,
|
||||
"pfp": l.pfp
|
||||
})
|
||||
|
||||
async def loop(self):
|
||||
|
@ -6,7 +6,7 @@
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/09/11 17:07:08 by tomoron #+# #+# #
|
||||
# Updated: 2024/10/12 23:31:22 by tomoron ### ########.fr #
|
||||
# Updated: 2024/10/14 20:04:28 by tomoron ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -29,5 +29,5 @@ async def start(socket, content):
|
||||
if(goalId < 0 or goalId >= GameSettings.nbGoals):
|
||||
socket.sendError("Goal id out of range", 9039)
|
||||
return;
|
||||
Game(socket, False,skinId, goalId,opponent)
|
||||
Game(socket, content.get("with_bot", False), skinId, goalId, opponent)
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/10/01 13:16:39 by edbernar #+# #+# #
|
||||
# Updated: 2024/10/10 13:26:17 by edbernar ### ########.fr #
|
||||
# Updated: 2024/10/14 19:57:12 by tomoron ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -39,6 +39,8 @@ from .tournamentActions.fetchAllData import fetchAllData
|
||||
# 4 : startGame : tell the client (client will launch a matchmaking like invitation)
|
||||
# - id : id of the player
|
||||
# - username : name of the player
|
||||
# - skin : skin id of the player
|
||||
# - goal : goal id of the player
|
||||
#
|
||||
# 5 : allData : gives tournament data to the client
|
||||
# - players : [{id, username, pfp}, ...]
|
||||
|
Reference in New Issue
Block a user