diff sat_frontends/quick_frontend/quick_game_tarot.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 003b8b4b56a7
line wrap: on
line diff
--- a/sat_frontends/quick_frontend/quick_game_tarot.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat_frontends/quick_frontend/quick_game_tarot.py	Wed Jun 27 20:14:46 2018 +0200
@@ -18,14 +18,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sat.core.log import getLogger
+
 log = getLogger(__name__)
 from sat_frontends.tools.jid import JID
 
 
 class QuickTarotGame(object):
-
     def __init__(self, parent, referee, players):
-        self._autoplay = None  #XXX: use 0 to activate fake play, None else
+        self._autoplay = None  # XXX: use 0 to activate fake play, None else
         self.parent = parent
         self.referee = referee
         self.players = players
@@ -42,8 +42,8 @@
         idx = (idx + 1) % len(self.players)
         self.left_nick = unicode(self.players[idx])
         self.bottom_nick = unicode(self.player_nick)
-        self.selected = []  #Card choosed by the player (e.g. during ecart)
-        self.hand_size = 13  #number of cards in a hand
+        self.selected = []  # Card choosed by the player (e.g. during ecart)
+        self.hand_size = 13  # number of cards in a hand
         self.hand = []
         self.to_show = []
         self.state = None
@@ -59,25 +59,27 @@
 
     def getPlayerLocation(self, nick):
         """return player location (top,bottom,left or right)"""
-        for location in ['top','left','bottom','right']:
-            if getattr(self,'%s_nick' % location) == nick:
+        for location in ["top", "left", "bottom", "right"]:
+            if getattr(self, "%s_nick" % location) == nick:
                 return location
-        assert(False)
+        assert False
 
     def loadCards(self):
         """Load all the cards in memory
         @param dir: directory where the PNG files are"""
-        self.cards={}
-        self.deck=[]
-        self.cards["atout"]={} #As Tarot is a french game, it's more handy & logical to keep french names
-        self.cards["pique"]={} #spade
-        self.cards["coeur"]={} #heart
-        self.cards["carreau"]={} #diamond
-        self.cards["trefle"]={} #club
+        self.cards = {}
+        self.deck = []
+        self.cards[
+            "atout"
+        ] = {}  # As Tarot is a french game, it's more handy & logical to keep french names
+        self.cards["pique"] = {}  # spade
+        self.cards["coeur"] = {}  # heart
+        self.cards["carreau"] = {}  # diamond
+        self.cards["trefle"] = {}  # club
 
     def tarotGameNewHandler(self, hand):
         """Start a new game, with given hand"""
-        assert (len(self.hand) == 0)
+        assert len(self.hand) == 0
         for suit, value in hand:
             self.hand.append(self.cards[suit, value])
         self.hand.sort()
@@ -93,7 +95,7 @@
         self.to_show = []
         for suit, value in cards:
             self.to_show.append(self.cards[suit, value])
-        if game_stage == "chien" and data['attaquant'] == self.player_nick:
+        if game_stage == "chien" and data["attaquant"] == self.player_nick:
             self.state = "wait_for_ecart"
         else:
             self.state = "chien"
@@ -113,10 +115,12 @@
         if self._autoplay >= len(self.hand):
             self._autoplay = 0
         card = self.hand[self._autoplay]
-        self.parent.host.bridge.tarotGamePlayCards(self.player_nick, self.referee, [(card.suit, card.value)], self.parent.profile)
+        self.parent.host.bridge.tarotGamePlayCards(
+            self.player_nick, self.referee, [(card.suit, card.value)], self.parent.profile
+        )
         del self.hand[self._autoplay]
         self.state = "wait"
-        self._autoplay+=1
+        self._autoplay += 1
 
     def tarotGameScoreHandler(self, xml_data, winners, loosers):
         """Called at the end of a game
@@ -130,7 +134,7 @@
         if self.to_show:
             self.to_show = []
         pl_cards = []
-        if self.played[player] != None: #FIXME
+        if self.played[player] != None:  # FIXME
             for pl in self.played:
                 self.played[pl] = None
         for suit, value in cards:
@@ -148,11 +152,10 @@
         elif phase == "ecart":
             self.state = "ecart"
         else:
-            log.error ('INTERNAL ERROR: unmanaged game phase')
+            log.error("INTERNAL ERROR: unmanaged game phase")
 
         for suit, value in played_cards:
             self.hand.append(self.cards[suit, value])
 
         self.hand.sort()
         self.__fakePlay()
-