diff --git a/templates/home/player.html b/templates/home/player.html
index 18ecbf0..aa01b44 100644
--- a/templates/home/player.html
+++ b/templates/home/player.html
@@ -15,6 +15,22 @@
{% endfor %}
||
+
+ Tricks:
+ {% for player,_ in last_trick %}
+ ||
+ {{player.name}}: {{player.tricks_taken}}
+ {% endfor %}
+ ||
+
+ Last Trick:
+ {% for player,card in last_trick %}
+ ||
+ {{player.name}}: {{card}}
+ {% endfor %}
+ ||
+
+
Your cards:
-
diff --git a/views/player.py b/views/player.py
index d89b1a5..a8c9995 100644
--- a/views/player.py
+++ b/views/player.py
@@ -26,7 +26,7 @@ def show(req, resp, player: str):
choose_trump_color = False
resp.content = api.template('home/player.html', player=p, playerActive=isActive, choose_trump_player=prev_player,
cards=the_game.players[p].cards, choose_trump_color=choose_trump_color,
- trump_card=tcard, trump_color=tcolor, played_cards=the_game.played_cards)
+ trump_card=tcard, trump_color=tcolor, played_cards=the_game.played_cards, last_trick=the_game.last_trick)
@api.route("/player/{player}/play/{card}")
@@ -34,6 +34,17 @@ async def play(req, resp, player: str, card: str):
p = int(player)
c = int(card)
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()
+
url = '/player/'+player
for ws in the_game.websockets:
try:
diff --git a/wiz_game.py b/wiz_game.py
index b607aa5..6affb6b 100644
--- a/wiz_game.py
+++ b/wiz_game.py
@@ -58,15 +58,20 @@ class Player:
self.name = name
self.id = player_id
self.cards = []
+ self.tricks_taken = 0
def set_cards(self, cards):
self.cards = sorted(cards, key=attrgetter('color', 'value'))
+ self.tricks_taken = 0
def play_card(self, card_idx):
c = self.cards[card_idx]
self.cards.remove(c)
return c
+ def take_trick(self):
+ self.tricks_taken += 1
+
class WizGame:
def __init__(self, player_names: list):
@@ -81,6 +86,7 @@ class WizGame:
self.num_tricks_played = 0
self.played_cards = list()
self.players_ordered = self.players
+ self.last_trick = None
self.websockets = []
def start_game(self):
@@ -91,6 +97,7 @@ class WizGame:
self.deal_cards(1)
self.played_cards = list()
self.players_ordered = self.players
+ self.last_trick = [('-', '-')]*len(self.players)
self.websockets = []
def create_deck(self):
@@ -167,6 +174,7 @@ class WizGame:
return False
def next_trick(self):
+ self.last_trick = self.played_cards.copy()
win = self.get_trick_winner()
winner = win[0]
starter = winner.id