Fix pep8 support in src/tools.

This commit is contained in:
Emmanuel Gil Peyrot 2013-01-18 17:55:35 +01:00
commit fb0d7c9ca4

View file

@ -20,12 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from logging import debug, info, error
"""This library help manage general games (e.g. card games)"""
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 = [str(i) for i in xrange(1, 11)] + ["valet", "cavalier", "dame", "roi"]
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 TarotCard(object):
"""This class is used to represent a car logically"""
@ -34,7 +33,7 @@ class TarotCard(object):
def __init__(self, tuple_card):
"""@param tuple_card: tuple (suit, value)"""
self.suit, self.value = tuple_card
self.bout = True if self.suit=="atout" and self.value in ["1","21","excuse"] else False
self.bout = self.suit == "atout" and self.value in ["1", "21", "excuse"]
if self.bout or self.value == "roi":
self.points = 4.5
elif self.value == "dame":
@ -47,7 +46,7 @@ class TarotCard(object):
self.points = 0.5
def get_tuple(self):
return (self.suit,self.value)
return (self.suit, self.value)
@staticmethod
def from_tuples(tuple_list):
@ -57,11 +56,11 @@ class TarotCard(object):
return result
def __cmp__(self, other):
if other == None:
if other is None:
return 1
if self.suit != other.suit:
idx1 = suits_order.index(self.suit)
idx2 = suits_order.index(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':
@ -71,9 +70,9 @@ class TarotCard(object):
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)
# 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):