starting reworking
This commit is contained in:
@ -5,10 +5,41 @@ from wiz_game import the_game
|
||||
|
||||
@api.route("/control/")
|
||||
def index(req, resp):
|
||||
current_round = the_game.current_round
|
||||
hand_finished = the_game.is_hand_finished()
|
||||
trick_finished = the_game.is_trick_finished()
|
||||
|
||||
resp.content = api.template('home/control.html', deck=the_game.card_deck,
|
||||
trump_card=the_game.trump_card, trump_color=the_game.get_trump_color())
|
||||
if hand_finished:
|
||||
trick_winner, highest_card = the_game.get_trick_winner()
|
||||
winner = trick_winner.name
|
||||
resp.content = api.template('home/control.html', deck=the_game.card_deck,
|
||||
trump_card=the_game.trump_card, trump_color=the_game.get_trump_color(),
|
||||
hand_finished=True, trick_finished=False, trick_winner=winner,
|
||||
highest_card=highest_card
|
||||
)
|
||||
elif trick_finished:
|
||||
trick_winner, highest_card = the_game.get_trick_winner()
|
||||
winner = trick_winner.name
|
||||
resp.content = api.template('home/control.html', deck=the_game.card_deck,
|
||||
trump_card=the_game.trump_card, trump_color=the_game.get_trump_color(),
|
||||
round_finished=False, trick_finished=True, trick_winner=winner,
|
||||
highest_card=highest_card
|
||||
)
|
||||
else:
|
||||
resp.content = api.template('home/control.html', deck=the_game.card_deck,
|
||||
trump_card=the_game.trump_card, trump_color=the_game.get_trump_color(),
|
||||
round_finished=False, trick_finished=False
|
||||
)
|
||||
|
||||
@api.route("/control/next_hand/")
|
||||
def start_next_hand(req, resp):
|
||||
the_game.next_hand()
|
||||
api.redirect(resp, '/control/', status_code=303)
|
||||
|
||||
@api.route("/control/next_trick/")
|
||||
def start_next_trick(req, resp):
|
||||
the_game.next_trick()
|
||||
api.redirect(resp, '/control/', status_code=303)
|
||||
|
||||
@api.route("/control/deal/{cards}")
|
||||
def deal(req, resp, cards):
|
||||
|
@ -11,7 +11,14 @@ def show(req, resp, player: str):
|
||||
tcolor = the_game.get_trump_color()
|
||||
table = the_game.table
|
||||
isActive = the_game.is_players_turn(p)
|
||||
resp.content = api.template('home/player.html', playerActive=isActive, player=p, cards=the_game.players[p].cards,
|
||||
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)
|
||||
|
||||
|
||||
@ -19,10 +26,13 @@ def show(req, resp, player: str):
|
||||
def play(req, resp, player: str, card: str):
|
||||
p = int(player)
|
||||
c = int(card)
|
||||
#pl = the_game.players[p]
|
||||
#c = pl.play_card(int(card))
|
||||
#the_game.table.play_card(p, c)
|
||||
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)
|
||||
|
Reference in New Issue
Block a user