cowiz20/views/gplayer.py

30 lines
1.0 KiB
Python
Raw Normal View History

from app_instance import api
from wiz_game import the_game
from starlette.websockets import WebSocketDisconnect
import asyncio
2020-12-11 22:12:27 +01:00
# don't define here, it's defined elsewhere!
#playing_lock = asyncio.Lock()
@api.route("/gplayer/{player}")
def show(req, resp, player: str):
p = int(player)
tcard = the_game.trump_card
tcolor = the_game.get_trump_color()
try:
isActive = the_game.players_ordered[the_game.active_player].id == p
except IndexError:
isActive = False
prev_player = the_game.get_prev_player()
if tcard and tcard.value == 'Z' and tcolor == '-':
choose_trump_color = True
else:
choose_trump_color = False
resp.content = api.template('home/gplayer.html', player=p, playerActive=isActive, choose_trump_player=prev_player,
cards=the_game.players[p].cards, choose_trump_color=choose_trump_color,
trump_card=tcard, trump_color=tcolor, played_cards=the_game.played_cards, last_trick=the_game.last_trick)