Site
- Add multi online game Django - add somes paths
This commit is contained in:
@ -3,10 +3,10 @@
|
||||
# ::: :::::::: #
|
||||
# Game.py :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ #
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
|
||||
# Updated: 2024/09/15 13:33:31 by tomoron ### ########.fr #
|
||||
# Updated: 2024/09/15 14:44:14 by edbernar ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -48,16 +48,10 @@ class Game:
|
||||
self.p1 = socket
|
||||
else:
|
||||
self.p2 = socket
|
||||
print("set game to self")
|
||||
socket.game = self
|
||||
if(self.p2 != None and self.p1 != None):
|
||||
data = json.dumps({"type":"game", "content":{
|
||||
"action" : 1,
|
||||
"id": socket.id,
|
||||
"username": socket.username
|
||||
}})
|
||||
self.p1.sync_send(data)
|
||||
self.p2.sync_send(data)
|
||||
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}})
|
||||
except Exception as e:
|
||||
socket.sendError("invalid request", 9005, e)
|
||||
|
||||
|
@ -1,3 +1 @@
|
||||
<body>
|
||||
<p id="score"></p>
|
||||
</body>
|
||||
<p id="score"></p>
|
@ -22,6 +22,7 @@ urlpatterns = [
|
||||
path("homePage",views.homePage, name='homePage'),
|
||||
path("lobbyPage", views.lobbyPage, name='lobbyPage'),
|
||||
path("multiLocalGamePage", views.multiLocalGamePage, name='multiLocalGamePage'),
|
||||
path("multiOnlineGamePage", views.multiOnlineGamePage, name='multiOnlineGamePage'),
|
||||
path("waitingGamePage", views.waitingGamePage, name='waitingGamePage'),
|
||||
path("game", views.game, name='game'),
|
||||
path("wait_game", views.game, name='wait_game'),
|
||||
|
@ -37,6 +37,13 @@ def multiLocalGamePage(request):
|
||||
return(HttpResponse("you are not logged in",status=403))
|
||||
return render(request, "multiLocalGamePage.html", {})
|
||||
|
||||
def multiOnlineGamePage(request):
|
||||
if(request.method != "POST"):
|
||||
return index(request)
|
||||
if(not request.session.get("logged_in", False)):
|
||||
return(HttpResponse("you are not logged in",status=403))
|
||||
return render(request, "multiOnlineGamePage.html", {})
|
||||
|
||||
def waitingGamePage(request):
|
||||
if(request.method != "POST"):
|
||||
return index(request)
|
||||
|
Reference in New Issue
Block a user