diff frontends/quick_frontend/quick_card_game.py @ 162:ae50b53ff868

misc Tarot fixes - wix, primitivus, quick_frontend: autoplay fonction is activated by changing self._autoplay from None to 0 in quick card game - primitivus: added forgotten import of log methods - primitivus: fix bad selected color for notification messages - primitivus: score are now shown
author Goffi <goffi@goffi.org>
date Fri, 06 Aug 2010 12:18:50 +0800
parents 74aaf230a7c3
children fd2db62ea5eb
line wrap: on
line diff
--- a/frontends/quick_frontend/quick_card_game.py	Fri Aug 06 12:11:18 2010 +0800
+++ b/frontends/quick_frontend/quick_card_game.py	Fri Aug 06 12:18:50 2010 +0800
@@ -27,7 +27,7 @@
 class QuickCardGame():
     
     def __init__(self, parent, referee, players, player_nick):
-        self.__fake_idx = 0 #gof:
+        self._autoplay = None #XXX: use 0 to activate fake play, None else
         self.parent = parent
         self.referee = referee
         self.players = players
@@ -101,23 +101,26 @@
         if self.state == "chien":
             self.to_show = []
         self.state = "play"
-        #self.__fakePlay() #gof:
+        self.__fakePlay()
                   
     def __fakePlay(self):
         """Convenience method for stupid autoplay
         /!\ don't forgot to comment any interactive dialog for invalid card"""
-        #gof: 
-        if self.__fake_idx >= len(self.hand):
-            self.__fake_idx = 0
-        card = self.hand[self.__fake_idx]
+        if self._autoplay == None:
+            return
+        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)], profile_key = self.parent.host.profile)
-        del self.hand[self.__fake_idx]
+        del self.hand[self._autoplay]
         self.state = "wait"
-        self.__fake_idx+=1
+        self._autoplay+=1
 
     def showScores(self, xml_data, winners, loosers):
-        """Called when the player as to select hist contrat
-        @param xml_data: SàT xml representation of the form"""
+        """Called at the end of a game
+        @param xml_data: SàT xml representation of the scores
+        @param winners: list of winners' nicks
+        @param loosers: list of loosers' nicks"""
         raise NotImplementedError
     
     def cardsPlayed(self, player, cards):
@@ -149,5 +152,5 @@
             self.hand.append(self.cards[suit, value])
         
         self.hand.sort()
-        #self.__fakePlay() #gof:
+        self.__fakePlay()