changeset 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 (2010-08-06)
parents c37826d80f2a
children f582fddd0cc0
files frontends/primitivus/card_game.py frontends/primitivus/custom_widgets.py frontends/primitivus/xmlui.py frontends/quick_frontend/quick_card_game.py frontends/wix/card_game.py
diffstat 5 files changed, 21 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/primitivus/card_game.py	Fri Aug 06 12:11:18 2010 +0800
+++ b/frontends/primitivus/card_game.py	Fri Aug 06 12:18:50 2010 +0800
@@ -275,6 +275,7 @@
         """Called when the player as to select hist contrat
         @param xml_data: SàT xml representation of the form"""
         form = XMLUI(self.parent.host, xml_data, title = _('You win \o/') if self.player_nick in winners else _('You loose :('), options = ['NO_CANCEL'])
+        form.show()
 
     def invalidCards(self, phase, played_cards, invalid_cards):
         """Invalid cards have been played
@@ -283,7 +284,8 @@
         @param invalid_cards: cards which are invalid"""
         QuickCardGame.invalidCards(self, phase, played_cards, invalid_cards)
         self.hand_wid.update(self.hand)
-        self.parent.host.notify(_('Cards played are invalid !'))
+        if self._autoplay==None: #No dialog if there is autoplay
+            self.parent.host.notify(_('Cards played are invalid !'))
         self.parent.host.redraw()
     
     def cardsPlayed(self, player, cards):
--- a/frontends/primitivus/custom_widgets.py	Fri Aug 06 12:11:18 2010 +0800
+++ b/frontends/primitivus/custom_widgets.py	Fri Aug 06 12:18:50 2010 +0800
@@ -372,7 +372,7 @@
 
     def __init__(self):
         self.waitNotifs = urwid.Text('')
-        self.message = ClickableText('', default_attr='notifs')
+        self.message = ClickableText('', default_attr='notifs', select_attr='notifs')
         urwid.connect_signal(self.message, 'click', lambda wid: self.showNext())
         self.columns = urwid.Columns([('fixed',6,self.waitNotifs),self.message])
         urwid.WidgetWrap.__init__(self, urwid.AttrMap(self.columns,'notifs'))
--- a/frontends/primitivus/xmlui.py	Fri Aug 06 12:11:18 2010 +0800
+++ b/frontends/primitivus/xmlui.py	Fri Aug 06 12:18:50 2010 +0800
@@ -20,6 +20,7 @@
 """
 
 import urwid
+from logging import debug, info, warning, error
 import custom_widgets
 from xml.dom import minidom
 
--- 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()
 
--- a/frontends/wix/card_game.py	Fri Aug 06 12:11:18 2010 +0800
+++ b/frontends/wix/card_game.py	Fri Aug 06 12:18:50 2010 +0800
@@ -121,7 +121,8 @@
 
         self._recalc_ori()
         self.Refresh()
-        wx.MessageDialog(self, _("Cards played are invalid !"), _("Error"), wx.OK | wx.ICON_ERROR).ShowModal()
+        if self._autoplay==None: #No dialog if there is autoplay
+            wx.MessageDialog(self, _("Cards played are invalid !"), _("Error"), wx.OK | wx.ICON_ERROR).ShowModal()
 
     def _is_on_hand(self, pos_x, pos_y):
         """Return True if the coordinate are on the hand cards"""