add skin to opponent request(1),add protection to not select skin out of range
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/09/27 17:17:23 by tomoron ### ########.fr #
|
||||
# Updated: 2024/09/27 17:36:06 by tomoron ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -137,7 +137,7 @@ class Game:
|
||||
self.p2.sync_send({"type":"game", "content":{"action":7, "content":self.obstacles}})
|
||||
self.obstaclesInvLength()
|
||||
|
||||
def join(self, socket, skin):
|
||||
def join(self, socket, skin = 0):
|
||||
try:
|
||||
if(self.p1 == None):
|
||||
print("game created, set as player 1")
|
||||
@ -153,8 +153,8 @@ class Game:
|
||||
socket.game = self
|
||||
if(self.p2 != None and self.p1 != None):
|
||||
print("both players here, send opponent to both players")
|
||||
self.p1.sync_send({"type":"game", "content":{"action":1,"id":self.p2.id,"username":self.p2.username}})
|
||||
self.p2.sync_send({"type":"game", "content":{"action":1,"id":self.p1.id,"username":self.p1.username}})
|
||||
self.p1.sync_send({"type":"game", "content":{"action":1,"id":self.p2.id,"username":self.p2.username, "skin":self.p2Skin}})
|
||||
self.p2.sync_send({"type":"game", "content":{"action":1,"id":self.p1.id,"username":self.p1.username, "skin":self.p1Skin}})
|
||||
except Exception as e:
|
||||
socket.sendError("invalid request", 9005, e)
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/09/11 17:07:08 by tomoron #+# #+# #
|
||||
# Updated: 2024/09/27 16:33:32 by tomoron ### ########.fr #
|
||||
# Updated: 2024/09/27 17:39:59 by tomoron ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -20,5 +20,9 @@ async def start(socket, content):
|
||||
if(opponent != None and opponent not in socket.onlinePlayers):
|
||||
socket.sendError("Your opponent isn't online",9032)
|
||||
return;
|
||||
Game(socket, content.get("with_bot", False), content.get("skinId", 0),opponent)
|
||||
skinId = content.get("skinId", 0)
|
||||
if(skinId < 0 or skinId >= len(Game.skins)):
|
||||
socket.sendError("Skin id out of range", 9033)
|
||||
return;
|
||||
Game(socket, content.get("with_bot", False),skinId ,opponent)
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
- 9030 : You must provide your current password to it
|
||||
- 9031 : You can't set or change this field if you have a 42 account
|
||||
- 9032 : Your opponent isn't online
|
||||
- 9033 : Skin id out of range
|
||||
|
||||
- 9100 : Action out of range
|
||||
- 9101 : No game started
|
||||
|
Reference in New Issue
Block a user