needs to be a global variable, of course
This commit is contained in:
parent
7ea63ce623
commit
0321296014
@ -4,6 +4,11 @@ from wiz_game import the_game
|
|||||||
from starlette.websockets import WebSocketDisconnect
|
from starlette.websockets import WebSocketDisconnect
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
|
playing_lock = asyncio.Lock()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@api.route("/player/{player}")
|
@api.route("/player/{player}")
|
||||||
def show(req, resp, player: str):
|
def show(req, resp, player: str):
|
||||||
p = int(player)
|
p = int(player)
|
||||||
@ -31,11 +36,11 @@ def show(req, resp, player: str):
|
|||||||
|
|
||||||
@api.route("/player/{player}/play/{card}")
|
@api.route("/player/{player}/play/{card}")
|
||||||
async def play(req, resp, player: str, card: str):
|
async def play(req, resp, player: str, card: str):
|
||||||
lock = asyncio.Lock()
|
|
||||||
p = int(player)
|
p = int(player)
|
||||||
c = int(card)
|
c = int(card)
|
||||||
|
|
||||||
async with lock:
|
global playing_lock
|
||||||
|
async with playing_lock:
|
||||||
try:
|
try:
|
||||||
isActive = the_game.players_ordered[the_game.active_player].id == p
|
isActive = the_game.players_ordered[the_game.active_player].id == p
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
Loading…
Reference in New Issue
Block a user