change nomenclature
This commit is contained in:
parent
89d11ee759
commit
2092c52edb
@ -13,7 +13,7 @@ def main():
|
|||||||
wiz_game.the_game.start_game()
|
wiz_game.the_game.start_game()
|
||||||
|
|
||||||
#api.run(port=8001, address="127.0.0.1")
|
#api.run(port=8001, address="127.0.0.1")
|
||||||
api.run(port=8001, address="192.168.42.1")
|
api.run(port=8001, address="192.168.42.100")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@
|
|||||||
Winner: {{trick_winner}} with Card {{highest_card}}
|
Winner: {{trick_winner}} with Card {{highest_card}}
|
||||||
<a href="/control/next_trick/">start next trick</a>
|
<a href="/control/next_trick/">start next trick</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if hand_finished %}
|
{% if round_finished %}
|
||||||
Winner: {{trick_winner}} with Card {{highest_card}}
|
Winner: {{trick_winner}} with Card {{highest_card}}
|
||||||
<a href="/control/next_hand/">start next hand</a>
|
<a href="/control/next_round/">start next round</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br>
|
<br>
|
||||||
<a href="/control/undo_last/">undo last card</a>
|
<a href="/control/undo_last/">undo last card</a>
|
||||||
|
@ -5,15 +5,15 @@ from wiz_game import the_game
|
|||||||
|
|
||||||
@api.route("/control/")
|
@api.route("/control/")
|
||||||
def index(req, resp):
|
def index(req, resp):
|
||||||
hand_finished = the_game.is_hand_finished()
|
round_finished = the_game.is_round_finished()
|
||||||
trick_finished = the_game.is_trick_finished()
|
trick_finished = the_game.is_trick_finished()
|
||||||
|
|
||||||
if hand_finished:
|
if round_finished:
|
||||||
trick_winner, highest_card = the_game.get_trick_winner()
|
trick_winner, highest_card = the_game.get_trick_winner()
|
||||||
winner = trick_winner.name
|
winner = trick_winner.name
|
||||||
resp.content = api.template('home/control.html', deck=the_game.card_deck,
|
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(),
|
trump_card=the_game.trump_card, trump_color=the_game.get_trump_color(),
|
||||||
hand_finished=True, trick_finished=False, trick_winner=winner,
|
round_finished=True, trick_finished=False, trick_winner=winner,
|
||||||
highest_card=highest_card
|
highest_card=highest_card
|
||||||
)
|
)
|
||||||
elif trick_finished:
|
elif trick_finished:
|
||||||
@ -30,9 +30,9 @@ def index(req, resp):
|
|||||||
round_finished=False, trick_finished=False
|
round_finished=False, trick_finished=False
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.route("/control/next_hand/")
|
@api.route("/control/next_round/")
|
||||||
async def start_next_hand(req, resp):
|
async def start_next_round(req, resp):
|
||||||
the_game.next_hand()
|
the_game.next_round()
|
||||||
await the_game.send_page_reload()
|
await the_game.send_page_reload()
|
||||||
api.redirect(resp, '/control/', status_code=303)
|
api.redirect(resp, '/control/', status_code=303)
|
||||||
|
|
||||||
@ -46,9 +46,9 @@ async def start_next_trick(req, resp):
|
|||||||
|
|
||||||
@api.route("/control/undo_last/")
|
@api.route("/control/undo_last/")
|
||||||
async def undo_last(req, resp):
|
async def undo_last(req, resp):
|
||||||
hand_finished = the_game.is_hand_finished()
|
round_finished = the_game.is_round_finished()
|
||||||
if the_game.played_cards:
|
if the_game.played_cards:
|
||||||
if not hand_finished:
|
if not round_finished:
|
||||||
p, c = the_game.played_cards.pop()
|
p, c = the_game.played_cards.pop()
|
||||||
the_game.active_player -= 1
|
the_game.active_player -= 1
|
||||||
p.add_card(c)
|
p.add_card(c)
|
||||||
|
@ -37,7 +37,7 @@ async def play_card(player, card):
|
|||||||
isActive = False
|
isActive = False
|
||||||
if isActive:
|
if isActive:
|
||||||
the_game.play_card(player, card)
|
the_game.play_card(player, card)
|
||||||
if the_game.is_hand_finished():
|
if the_game.is_round_finished():
|
||||||
trick_winner, highest_card = the_game.get_trick_winner()
|
trick_winner, highest_card = the_game.get_trick_winner()
|
||||||
trick_winner.take_trick()
|
trick_winner.take_trick()
|
||||||
elif the_game.is_trick_finished():
|
elif the_game.is_trick_finished():
|
||||||
|
@ -155,16 +155,16 @@ class WizGame:
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def is_hand_finished(self):
|
def is_round_finished(self):
|
||||||
h = self.is_trick_finished()
|
h = self.is_trick_finished()
|
||||||
if h and self.num_tricks_played == self.current_round:
|
if h and self.num_tricks_played == self.current_round:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def next_hand(self):
|
def next_round(self):
|
||||||
max_hands = len(self.card_deck)/len(self.players)
|
max_rounds = len(self.card_deck)/len(self.players)
|
||||||
if self.current_round <= max_hands:
|
if self.current_round <= max_rounds:
|
||||||
self.current_round += 1
|
self.current_round += 1
|
||||||
self.start_player += 1
|
self.start_player += 1
|
||||||
if self.start_player >= len(self.players):
|
if self.start_player >= len(self.players):
|
||||||
|
Loading…
Reference in New Issue
Block a user