mover Card class to tools/games and renamed it in TarotCard
This commit is contained in:
parent
b6dac0a610
commit
914a59adbb
1 changed files with 91 additions and 90 deletions
|
|
@ -26,6 +26,7 @@ import os.path, glob
|
|||
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 @@ CARD_HEIGHT = 136
|
|||
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 @@ class Card():
|
|||
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 @@ class CardPanel(wx.Panel):
|
|||
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']:
|
||||
|
|
|
|||
Loading…
Reference in a new issue