Mercurial > libervia-backend
diff frontends/wix/card_game.py @ 141:8c80d4dec7a8
mover Card class to tools/games and renamed it in TarotCard
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 22 Jul 2010 15:49:16 +0800 |
parents | d998adb62d1a |
children | 80661755ea8d |
line wrap: on
line diff
--- a/frontends/wix/card_game.py Thu Jul 22 15:48:03 2010 +0800 +++ b/frontends/wix/card_game.py Thu Jul 22 15:49:16 2010 +0800 @@ -26,6 +26,7 @@ import pdb from logging import debug, info, error from tools.jid import JID +from tools.games import TarotCard from xmlui import XMLUI CARD_WIDTH = 74 @@ -33,10 +34,7 @@ MIN_WIDTH = 950 #Minimum size of the panel MIN_HEIGHT = 500 -suits_order = ['pique', 'coeur', 'trefle', 'carreau', 'atout'] #I have switched the usual order 'trefle' and 'carreau' because card are more easy to see if suit colour change (black, red, black, red) -values_order = map(str,range(1,11))+["valet","cavalier","dame","roi"] - -class Card(): +class wxCard(TarotCard): """This class is used to represent a card, graphically and logically""" def __init__(self, file): @@ -44,33 +42,9 @@ self.bitmap = wx.Image(file).ConvertToBitmap() root_name = os.path.splitext(os.path.basename(file))[0] self.suit,self.value=root_name.split('_') - #gof: self.bout = True if self.suit=="atout" and self.value in ["1","21","excuse"] else False - + TarotCard.__init__(self, (self.suit, self.value)) print "Carte:",self.suit, self.value #, self.bout - def __cmp__(self, other): - if other == None: - return 1 - if self.suit != other.suit: - idx1 = suits_order.index(self.suit) - idx2 = suits_order.index(other.suit) - return idx1.__cmp__(idx2) - if self.suit == 'atout': - if self.value == other.value == 'excuse': - return 0 - if self.value == 'excuse': - return -1 - if other.value == 'excuse': - return 1 - return int(self.value).__cmp__(int(other.value)) - #at this point we have the same suit which is not 'atout' - idx1 = values_order.index(self.value) - idx2 = values_order.index(other.value) - return idx1.__cmp__(idx2) - - def __str__(self): - return "[%s,%s]" % (self.suit, self.value) - def draw(self, dc, x, y): """Draw the card on the device context @param dc: device context @@ -127,7 +101,7 @@ self.cards["carreau"]={} #diamond self.cards["trefle"]={} #club for file in glob.glob(dir+'/*_*.png'): - card = Card(file) + card = wxCard(file) self.cards[card.suit, card.value]=card self.deck.append(card) """for value in map(str,range(1,22))+['excuse']: