annotate frontends/src/quick_frontend/quick_card_game.py @ 930:cbf4122baae7

core, memory: use XDG recommended paths as the defaults for the config and local directories
author souliane <souliane@mailoo.org>
date Sun, 23 Mar 2014 22:43:43 +0100
parents 1fe00f0c9a91
children d1084f7e56a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
4 # helper class for making a SAT frontend
811
1fe00f0c9a91 dates update
Goffi <goffi@goffi.org>
parents: 680
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
7 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
10 # (at your option) any later version.
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
12 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
15 # GNU Affero General Public License for more details.
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
19
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from logging import debug, info, error
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents: 223
diff changeset
21 from sat.tools.jid import JID
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
22
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
23
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
24
588
beaf6bec2fcd Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
25 class QuickCardGame(object):
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
26
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
27 def __init__(self, parent, referee, players, player_nick):
329
be9f682c53a5 QuickApp: autoplay deactivated in Tarot game
Goffi <goffi@goffi.org>
parents: 328
diff changeset
28 self._autoplay = None #XXX: use 0 to activate fake play, None else
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
29 self.parent = parent
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
30 self.referee = referee
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
31 self.players = players
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
32 self.played = {}
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
33 for player in players:
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
34 self.played[player] = None
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
35 self.player_nick = player_nick
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
36 self.bottom_nick = unicode(self.player_nick)
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
37 idx = self.players.index(self.player_nick)
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
38 idx = (idx + 1) % len(self.players)
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
39 self.right_nick = unicode(self.players[idx])
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
40 idx = (idx + 1) % len(self.players)
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
41 self.top_nick = unicode(self.players[idx])
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
42 idx = (idx + 1) % len(self.players)
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
43 self.left_nick = unicode(self.players[idx])
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
44 self.bottom_nick = unicode(player_nick)
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
45 self.selected = [] #Card choosed by the player (e.g. during ecart)
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
46 self.hand_size = 13 #number of cards in a hand
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
47 self.hand = []
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.to_show = []
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
49 self.state = None
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
50
328
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
51 def resetRound(self):
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
52 """Reset the game's variables to be reatty to start the next round"""
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
53 del self.selected[:]
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
54 del self.hand[:]
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
55 del self.to_show[:]
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
56 self.state = None
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
57 for pl in self.played:
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
58 self.played[pl] = None
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
59
148
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
60 def getPlayerLocation(self, nick):
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
61 """return player location (top,bottom,left or right)"""
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
62 for location in ['top','left','bottom','right']:
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
63 if getattr(self,'%s_nick' % location) == nick:
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
64 return location
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
65 assert(False)
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
66
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
67 def loadCards(self):
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
68 """Load all the cards in memory
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
69 @param dir: directory where the PNG files are"""
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
70 self.cards={}
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
71 self.deck=[]
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
72 self.cards["atout"]={} #As Tarot is a french game, it's more handy & logical to keep french names
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
73 self.cards["pique"]={} #spade
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
74 self.cards["coeur"]={} #heart
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
75 self.cards["carreau"]={} #diamond
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
76 self.cards["trefle"]={} #club
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
77
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
78 def newGame(self, hand):
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
79 """Start a new game, with given hand"""
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
80 assert (len(self.hand) == 0)
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
81 for suit, value in hand:
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
82 self.hand.append(self.cards[suit, value])
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
83 self.hand.sort()
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
84 self.state = "init"
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
85
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
86 def contratSelected(self, contrat):
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
87 """Called when the contrat has been choosed
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
88 @param data: form result"""
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
89 self.parent.host.bridge.tarotGameContratChoosed(self.player_nick, self.referee, contrat or 'Passe', self.parent.host.profile)
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
90
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
91 def chooseContrat(self, xml_data):
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
92 """Called when the player as to select his contrat
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
93 @param xml_data: SàT xml representation of the form"""
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
94 raise NotImplementedError
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
95
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
96 def showCards(self, game_stage, cards, data):
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
97 """Display cards in the middle of the game (to show for e.g. chien ou poignée)"""
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
98 self.to_show = []
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
99 for suit, value in cards:
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
100 self.to_show.append(self.cards[suit, value])
328
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
101 if game_stage == "chien" and data['attaquant'] == self.player_nick:
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
102 self.state = "wait_for_ecart"
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
103 else:
809733b8d9be Tarot game:
Goffi <goffi@goffi.org>
parents: 228
diff changeset
104 self.state = "chien"
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
105
148
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
106 def myTurn(self):
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
107 """Called when we have to play :)"""
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
108 if self.state == "chien":
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
109 self.to_show = []
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
110 self.state = "play"
162
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
111 self.__fakePlay()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
112
148
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
113 def __fakePlay(self):
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
114 """Convenience method for stupid autoplay
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
115 /!\ don't forgot to comment any interactive dialog for invalid card"""
162
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
116 if self._autoplay == None:
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
117 return
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
118 if self._autoplay >= len(self.hand):
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
119 self._autoplay = 0
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
120 card = self.hand[self._autoplay]
680
8281587eb528 primitivus, wix: fixed bridge methods calls for plugins radiocol and card game
souliane <souliane@mailoo.org>
parents: 609
diff changeset
121 self.parent.host.bridge.tarotGamePlayCards(self.player_nick, self.referee, [(card.suit, card.value)], self.parent.host.profile)
162
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
122 del self.hand[self._autoplay]
148
1d74c59a36a9 Quick Frontend: quick card game: added convenience method getPlayerLocation & __fakePlay
Goffi <goffi@goffi.org>
parents: 144
diff changeset
123 self.state = "wait"
162
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
124 self._autoplay+=1
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
125
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
126 def showScores(self, xml_data, winners, loosers):
162
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
127 """Called at the end of a game
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
128 @param xml_data: SàT xml representation of the scores
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
129 @param winners: list of winners' nicks
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
130 @param loosers: list of loosers' nicks"""
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
131 raise NotImplementedError
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
132
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
133 def cardsPlayed(self, player, cards):
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
134 """A card has been played by player"""
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
135 if self.to_show:
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
136 self.to_show = []
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
137 pl_cards = []
185
fd2db62ea5eb minor deletions
Goffi <goffi@goffi.org>
parents: 162
diff changeset
138 if self.played[player] != None: #FIXME
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
139 for pl in self.played:
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
140 self.played[pl] = None
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
141 for suit, value in cards:
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
142 pl_cards.append(self.cards[suit, value])
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
143 self.played[player] = pl_cards[0]
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
144
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
145 def invalidCards(self, phase, played_cards, invalid_cards):
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
146 """Invalid cards have been played
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
147 @param phase: phase of the game
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
148 @param played_cards: all the cards played
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
149 @param invalid_cards: cards which are invalid"""
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
150
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
151 if phase == "play":
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
152 self.state = "play"
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
153 elif phase == "ecart":
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
154 self.state = "ecart"
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
155 else:
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
156 error ('INTERNAL ERROR: unmanaged game phase')
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
157
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
158 for suit, value in played_cards:
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
159 self.hand.append(self.cards[suit, value])
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
160
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
161 self.hand.sort()
162
ae50b53ff868 misc Tarot fixes
Goffi <goffi@goffi.org>
parents: 158
diff changeset
162 self.__fakePlay()
144
80661755ea8d Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
163