39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from app_instance import api
|
|
|
|
from wiz_game import the_game
|
|
|
|
|
|
@api.route("/player/{player}")
|
|
def show(req, resp, player: str):
|
|
p = int(player)
|
|
name = the_game.players[p].name
|
|
tcard = the_game.trump_card
|
|
tcolor = the_game.get_trump_color()
|
|
table = the_game.table
|
|
isActive = the_game.is_players_turn(p)
|
|
active_player = the_game.active_player
|
|
prev_player = the_game.get_prev_player()
|
|
if tcard.value == 'Z' and p == prev_player and tcolor == '-':
|
|
choose_trump_color = True
|
|
else:
|
|
choose_trump_color = False
|
|
resp.content = api.template('home/player.html', playerActive=isActive, active_player=active_player, player=p,
|
|
cards=the_game.players[p].cards, choose_trump_color=choose_trump_color,
|
|
trump_card=tcard, trump_color=tcolor, played_cards=table.played_cards)
|
|
|
|
|
|
@api.route("/player/{player}/play/{card}")
|
|
def play(req, resp, player: str, card: str):
|
|
p = int(player)
|
|
c = int(card)
|
|
the_game.play_card(p, c)
|
|
url = '/player/'+player
|
|
api.redirect(resp, url, status_code=303)
|
|
|
|
@api.route("/player/{player}/set_trump/{trump}")
|
|
def set_trump_color(req, resp, player, trump):
|
|
p = int(player)
|
|
the_game.set_trump_color(trump)
|
|
url = '/player/'+player
|
|
api.redirect(resp, url, status_code=303)
|