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
This commit is contained in:
parent
4d4c768fd5
commit
d2644f1258
5 changed files with 21 additions and 14 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
import urwid
|
||||
from logging import debug, info, warning, error
|
||||
import custom_widgets
|
||||
from xml.dom import minidom
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue