diff --git a/frontends/primitivus/card_game.py b/frontends/primitivus/card_game.py index 1d76a211..350f9b0d 100644 --- a/frontends/primitivus/card_game.py +++ b/frontends/primitivus/card_game.py @@ -275,6 +275,7 @@ class CardGame(QuickCardGame,urwid.WidgetWrap): """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 @@ class CardGame(QuickCardGame,urwid.WidgetWrap): @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): diff --git a/frontends/primitivus/custom_widgets.py b/frontends/primitivus/custom_widgets.py index 94358af3..e9337066 100644 --- a/frontends/primitivus/custom_widgets.py +++ b/frontends/primitivus/custom_widgets.py @@ -372,7 +372,7 @@ class NotificationBar(urwid.WidgetWrap): 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')) diff --git a/frontends/primitivus/xmlui.py b/frontends/primitivus/xmlui.py index 9a70a579..60725a8a 100644 --- a/frontends/primitivus/xmlui.py +++ b/frontends/primitivus/xmlui.py @@ -20,6 +20,7 @@ along with this program. If not, see . """ import urwid +from logging import debug, info, warning, error import custom_widgets from xml.dom import minidom diff --git a/frontends/quick_frontend/quick_card_game.py b/frontends/quick_frontend/quick_card_game.py index 2bf1b1f3..2e1db9ea 100644 --- a/frontends/quick_frontend/quick_card_game.py +++ b/frontends/quick_frontend/quick_card_game.py @@ -27,7 +27,7 @@ from tools.jid import JID 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 @@ class QuickCardGame(): 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 @@ class QuickCardGame(): self.hand.append(self.cards[suit, value]) self.hand.sort() - #self.__fakePlay() #gof: + self.__fakePlay() diff --git a/frontends/wix/card_game.py b/frontends/wix/card_game.py index 79641eed..562243a8 100644 --- a/frontends/wix/card_game.py +++ b/frontends/wix/card_game.py @@ -121,7 +121,8 @@ class CardPanel(QuickCardGame,wx.Panel): 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"""