2020-04-05 16:00:48 +02:00
|
|
|
from app_instance import api
|
|
|
|
|
|
|
|
from wiz_game import the_game
|
|
|
|
|
|
|
|
|
|
|
|
@api.route("/player/{player}")
|
2020-04-12 15:27:05 +02:00
|
|
|
def show(req, resp, player: str):
|
2020-04-05 16:00:48 +02:00
|
|
|
p = int(player)
|
2020-04-12 15:27:05 +02:00
|
|
|
name = the_game.players[p].name
|
2020-04-05 23:27:33 +02:00
|
|
|
tcard = the_game.trump_card
|
|
|
|
tcolor = the_game.get_trump_color()
|
2020-04-13 22:07:38 +02:00
|
|
|
#isActive = the_game.is_players_turn(p)
|
|
|
|
try:
|
|
|
|
isActive = the_game.players_ordered[the_game.active_player].id == p
|
|
|
|
print("show p: {} | {}".format(the_game.players_ordered[the_game.active_player].id, p))
|
|
|
|
except IndexError:
|
|
|
|
isActive = False
|
|
|
|
print("show p: {} | {}".format('None', p))
|
|
|
|
|
|
|
|
#active_player = the_game.active_player
|
2020-04-13 16:14:36 +02:00
|
|
|
prev_player = the_game.get_prev_player()
|
2020-04-19 00:38:57 +02:00
|
|
|
if tcard and tcard.value == 'Z' and tcolor == '-':
|
2020-04-13 16:14:36 +02:00
|
|
|
choose_trump_color = True
|
|
|
|
else:
|
|
|
|
choose_trump_color = False
|
2020-04-13 22:07:38 +02:00
|
|
|
resp.content = api.template('home/player.html', player=p, playerActive=isActive, choose_trump_player=prev_player,
|
2020-04-13 16:14:36 +02:00
|
|
|
cards=the_game.players[p].cards, choose_trump_color=choose_trump_color,
|
2020-04-13 22:07:38 +02:00
|
|
|
trump_card=tcard, trump_color=tcolor, played_cards=the_game.played_cards)
|
2020-04-06 22:42:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
@api.route("/player/{player}/play/{card}")
|
|
|
|
def play(req, resp, player: str, card: str):
|
|
|
|
p = int(player)
|
2020-04-12 15:27:05 +02:00
|
|
|
c = int(card)
|
|
|
|
the_game.play_card(p, c)
|
2020-04-07 21:13:23 +02:00
|
|
|
url = '/player/'+player
|
|
|
|
api.redirect(resp, url, status_code=303)
|
2020-04-06 22:42:31 +02:00
|
|
|
|
2020-04-13 16:14:36 +02:00
|
|
|
@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)
|