Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_misc_tarot.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 26b7ed2817da |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
139 ) # args: room_jid, game phase, played_cards, invalid_cards, profile | 139 ) # args: room_jid, game phase, played_cards, invalid_cards, profile |
140 self.deck_ordered = [] | 140 self.deck_ordered = [] |
141 for value in ["excuse"] + list(map(str, list(range(1, 22)))): | 141 for value in ["excuse"] + list(map(str, list(range(1, 22)))): |
142 self.deck_ordered.append(TarotCard(("atout", value))) | 142 self.deck_ordered.append(TarotCard(("atout", value))) |
143 for suit in ["pique", "coeur", "carreau", "trefle"]: | 143 for suit in ["pique", "coeur", "carreau", "trefle"]: |
144 for value in list(map(str, list(range(1, 11)))) + ["valet", "cavalier", "dame", "roi"]: | 144 for value in list(map(str, list(range(1, 11)))) + [ |
145 "valet", | |
146 "cavalier", | |
147 "dame", | |
148 "roi", | |
149 ]: | |
145 self.deck_ordered.append(TarotCard((suit, value))) | 150 self.deck_ordered.append(TarotCard((suit, value))) |
146 self.__choose_contrat_id = host.register_callback( | 151 self.__choose_contrat_id = host.register_callback( |
147 self._contrat_choosed, with_data=True | 152 self._contrat_choosed, with_data=True |
148 ) | 153 ) |
149 self.__score_id = host.register_callback(self._score_showed, with_data=True) | 154 self.__score_id = host.register_callback(self._score_showed, with_data=True) |
472 if not suit_asked and played_card.value != "excuse": | 477 if not suit_asked and played_card.value != "excuse": |
473 suit_asked = played_card.suit | 478 suit_asked = played_card.suit |
474 if played_card.suit == "atout" and played_card > biggest_atout: | 479 if played_card.suit == "atout" and played_card > biggest_atout: |
475 biggest_atout = played_card | 480 biggest_atout = played_card |
476 idx = (idx + 1) % len(players) | 481 idx = (idx + 1) % len(players) |
477 has_suit = ( | 482 has_suit = False # True if there is one card of the asked suit in the hand of the player |
478 False | |
479 ) # True if there is one card of the asked suit in the hand of the player | |
480 has_atout = False | 483 has_atout = False |
481 biggest_hand_atout = None | 484 biggest_hand_atout = None |
482 | 485 |
483 for hand_card in game_data["hand"][current_player]: | 486 for hand_card in game_data["hand"][current_player]: |
484 if hand_card.suit == suit_asked: | 487 if hand_card.suit == suit_asked: |
606 random.shuffle(deck) | 609 random.shuffle(deck) |
607 for i in range(4): | 610 for i in range(4): |
608 hand[players[i]] = deck[0:hand_size] | 611 hand[players[i]] = deck[0:hand_size] |
609 del deck[0:hand_size] | 612 del deck[0:hand_size] |
610 chien.extend(deck) | 613 chien.extend(deck) |
611 del (deck[:]) | 614 del deck[:] |
612 msg_elts = {} | 615 msg_elts = {} |
613 for player in players: | 616 for player in players: |
614 msg_elts[player] = self.__card_list_to_xml(hand[player], "hand") | 617 msg_elts[player] = self.__card_list_to_xml(hand[player], "hand") |
615 | 618 |
616 RoomGame.new_round(self, room_jid, (common_data, msg_elts), profile) | 619 RoomGame.new_round(self, room_jid, (common_data, msg_elts), profile) |