Mercurial > libervia-backend
comparison sat_frontends/tools/games.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | 003b8b4b56a7 |
comparison
equal
deleted
inserted
replaced
2623:49533de4540b | 2624:56f94936df1e |
---|---|
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 """This library help manage general games (e.g. card games) and it is shared by the frontends""" | 20 """This library help manage general games (e.g. card games) and it is shared by the frontends""" |
21 | 21 |
22 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) | 22 SUITS_ORDER = [ |
23 "pique", | |
24 "coeur", | |
25 "trefle", | |
26 "carreau", | |
27 "atout", | |
28 ] # I have switched the usual order 'trefle' and 'carreau' because card are more easy to see if suit colour change (black, red, black, red) | |
23 VALUES_ORDER = [str(i) for i in xrange(1, 11)] + ["valet", "cavalier", "dame", "roi"] | 29 VALUES_ORDER = [str(i) for i in xrange(1, 11)] + ["valet", "cavalier", "dame", "roi"] |
24 | 30 |
25 | 31 |
26 class TarotCard(object): | 32 class TarotCard(object): |
27 """This class is used to represent a car logically""" | 33 """This class is used to represent a car logically""" |
56 return 1 | 62 return 1 |
57 if self.suit != other.suit: | 63 if self.suit != other.suit: |
58 idx1 = SUITS_ORDER.index(self.suit) | 64 idx1 = SUITS_ORDER.index(self.suit) |
59 idx2 = SUITS_ORDER.index(other.suit) | 65 idx2 = SUITS_ORDER.index(other.suit) |
60 return idx1.__cmp__(idx2) | 66 return idx1.__cmp__(idx2) |
61 if self.suit == 'atout': | 67 if self.suit == "atout": |
62 if self.value == other.value == 'excuse': | 68 if self.value == other.value == "excuse": |
63 return 0 | 69 return 0 |
64 if self.value == 'excuse': | 70 if self.value == "excuse": |
65 return -1 | 71 return -1 |
66 if other.value == 'excuse': | 72 if other.value == "excuse": |
67 return 1 | 73 return 1 |
68 return int(self.value).__cmp__(int(other.value)) | 74 return int(self.value).__cmp__(int(other.value)) |
69 # at this point we have the same suit which is not 'atout' | 75 # at this point we have the same suit which is not 'atout' |
70 idx1 = VALUES_ORDER.index(self.value) | 76 idx1 = VALUES_ORDER.index(self.value) |
71 idx2 = VALUES_ORDER.index(other.value) | 77 idx2 = VALUES_ORDER.index(other.value) |