def ask(self, top_card = None, trump = None, played_cards = basics.trick(), cards = [], msg = "", error = "", team = [99,99], players = [], dealer = None, secret = 0, quit = 0): #def ask(self, data): # in top: played_cards, top_card, score? (team) master = self.master self.cards = cards self.top_frame = Frame(master) self.top_frame.pack(side=TOP) self.bottom_frame = Frame(master) self.bottom_frame.pack(side=BOTTOM) # in bottom: cards / msg / input / error / self.msg = Label(self.bottom_frame, text = msg) self.msg.pack() self.show_score(self.top_frame, team) if (msg[:7] == "The win"): # Results played_cards._shift(-1, destructive=1) self.show_played(self.top_frame, played_cards, dealer) self.show_next(self.bottom_frame) elif (msg[-6:] == "play? "): # Play self.show_played(self.top_frame, played_cards, dealer) self.show_trump(self.bottom_frame, trump) self.show_cards(self.bottom_frame) elif (msg[-4:] == "up? "):#Bid self.show_played(self.top_frame, played_cards, dealer) self.show_card(top_card, self.top_frame, text = "Top Card: ", relief=FLAT) self.show_cards(self.bottom_frame) self.show_yesno(self.bottom_frame, top_card) elif (msg[-6:] == "Pass? "): # Bid self.show_played(self.top_frame, played_cards, dealer) self.show_cards(self.bottom_frame) self.show_bid(self.bottom_frame) elif (msg[-9:] == "discard? "): # Pick it Up trump = top_card.suit self.show_played(self.top_frame, played_cards, dealer) self.show_trump(self.bottom_frame, trump) self.show_cards(self.bottom_frame) elif (1): #someone bid. points scored, and game over? #import tkMessageBox self.hide_score() self.show_next(self.bottom_frame) #tkMessageBox.showinfo("Info", msg) #self.say("") else: # Bad print "|%s|" % msg raise Exception("Should have called one of those ^") if error: import tkMessageBox tkMessageBox.showerror("Error", error)
def results(self, winner, leader, played_cards, team, players, dealer): perspective = trick() try: #msg = ("The winner was: " + str(winner.owner + leader) + " = " + str(played_cards.cards[(leader + winner.owner) % 4])) msg = ("The winner was: " + str(winner) + "\n") except: #msg = ("The winner was: " + str(winner.owner + leader)) msg = ("The winner was: " + str(winner) + "\n") shift = (self.index - leader + 1) perspective.cards = played_cards._shift(shift) players = players[self.index:] + players[:self.index] dealer = ((dealer - self.index) % 4) answer = self.ask(msg = msg, played_cards = perspective, team = team, players = players, cards = self.cards, dealer = dealer) if answer == "Q": print "someone quit" quit()#exit pass leader = winner
def ask(self, top_card = None, trump = None, played_cards = basics.trick(), cards = [], msg = "", error = "", team = [99,99], players = [], dealer = None, secret = 0, quit = 0): #def ask(self, data): # in top: played_cards, top_card, score? (team) self.cards = cards if (msg[:7] == "The win"): # Results played_cards._shift(-1, destructive=1) self.show_played(self.top_frame, played_cards, dealer) self.show_next(self.bottom_frame) elif (msg[-6:] == "play? "): # Play self.show_played(self.top_frame, played_cards, dealer) self.show_trump(self.bottom_frame, trump) self.show_cards(self.bottom_frame) elif (msg[-4:] == "up? "):#Bid self.show_played(self.top_frame, played_cards, dealer) self.show_card(top_card, self.top_frame, text = "Top Card: ", relief=FLAT) self.show_cards(self.bottom_frame) self.show_yesno(self.bottom_frame, top_card) elif (msg[-6:] == "Pass? "): # Bid self.show_played(self.top_frame, played_cards, dealer) self.show_cards(self.bottom_frame) self.show_bid(self.bottom_frame) elif (msg[-9:] == "discard? "): # Pick it Up trump = top_card.suit self.show_played(self.top_frame, played_cards, dealer) self.show_trump(self.bottom_frame, trump) self.show_cards(self.bottom_frame) else: # Bad print "|%s|" % msg raise Exception("Should have called one of those ^") if error: import tkMessageBox tkMessageBox.showerror("Error", error)