code cleanup
This commit is contained in:
@ -5,7 +5,6 @@ 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()
|
||||
|
||||
@ -38,7 +37,7 @@ async def start_next_hand(req, resp):
|
||||
try:
|
||||
await ws.send_text("reload")
|
||||
except Exception as e:
|
||||
print("ws: got {}".format(e))
|
||||
pass
|
||||
api.redirect(resp, '/control/', status_code=303)
|
||||
|
||||
|
||||
@ -49,10 +48,6 @@ async def start_next_trick(req, resp):
|
||||
try:
|
||||
await ws.send_text("reload")
|
||||
except Exception as e:
|
||||
print("ws: got {}".format(e))
|
||||
pass
|
||||
api.redirect(resp, '/control/', status_code=303)
|
||||
|
||||
#@api.route("/control/deal/{cards}")
|
||||
#def deal(req, resp, cards):
|
||||
# the_game.deal_cards(int(cards))
|
||||
# api.redirect(resp, '/control/', status_code=303)
|
||||
|
@ -8,22 +8,16 @@ import asyncio
|
||||
playing_lock = asyncio.Lock()
|
||||
|
||||
|
||||
|
||||
@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()
|
||||
#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
|
||||
prev_player = the_game.get_prev_player()
|
||||
if tcard and tcard.value == 'Z' and tcolor == '-':
|
||||
choose_trump_color = True
|
||||
@ -45,16 +39,12 @@ async def play(req, resp, player: str, card: str):
|
||||
isActive = the_game.players_ordered[the_game.active_player].id == p
|
||||
except IndexError:
|
||||
isActive = False
|
||||
print("show p: {} | {}".format('None', p))
|
||||
if isActive:
|
||||
the_game.play_card(p, c)
|
||||
if the_game.is_hand_finished():
|
||||
print("hand finished")
|
||||
trick_winner, highest_card = the_game.get_trick_winner()
|
||||
trick_winner.take_trick()
|
||||
#the_game.next_hand()
|
||||
elif the_game.is_trick_finished():
|
||||
print("trick finished")
|
||||
trick_winner, highest_card = the_game.get_trick_winner()
|
||||
trick_winner.take_trick()
|
||||
the_game.next_trick()
|
||||
@ -64,7 +54,7 @@ async def play(req, resp, player: str, card: str):
|
||||
try:
|
||||
await ws.send_text("reload")
|
||||
except Exception as e:
|
||||
print("ws: got {}".format(e))
|
||||
pass
|
||||
api.redirect(resp, url, status_code=303)
|
||||
|
||||
@api.route("/player/{player}/set_trump/{trump}")
|
||||
@ -76,7 +66,7 @@ async def set_trump_color(req, resp, player, trump):
|
||||
try:
|
||||
await ws.send_text("reload")
|
||||
except Exception as e:
|
||||
print("ws: got {}".format(e))
|
||||
pass
|
||||
api.redirect(resp, url, status_code=303)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user