def new_deal(self): dealer_name = self.dealer.player_name self.bc_pre("^R%s^~ (%s%s^~) gives the cards a good shuffle...\n" % (dealer_name, self.get_color_code(self.dealer), self.dealer)) deck = new_deck() deck.shuffle() # Deal out all of the cards. We'll flip the last one; that determines # the trump suit for the hand. self.bc_pre("^R%s^~ deals the cards out to all the players.\n" % dealer_name) for seat in self.seats: seat.data.hand = Hand() for i in range(13): for seat in self.seats: seat.data.hand.add(deck.discard()) # Flip the dealer's last card; it determines the trump suit. last_card = self.dealer.data.hand[-1] self.bc_pre("^R%s^~ flips their last card; it is ^C%s^~.\n" % (dealer_name, card_to_str(last_card, LONG))) self.trump_suit = last_card.suit # Sort everyone's hands. for seat in self.seats: seat.data.hand = sorted_hand(seat.data.hand, self.trump_suit) # Show everyone their hands. self.show_hands() # Set the trick counts to zero. self.ns.tricks = 0 self.ew.tricks = 0
def new_deck(self): # In 4-player mode, it's a standard 52-card pack. if self.mode == 4: self.deck = new_deck() else: # If it's a short deck, 7-A are full; if a long deck, 3-A are. full_ranks = [ACE, KING, QUEEN, JACK, '10', '9', '8', '7', '6'] if self.short: short_rank = '5' else: full_ranks.extend(['5', '4', '3']) short_rank = '2' # Build the deck, full ranks first. self.deck = Hand() for suit in (CLUBS, DIAMONDS, HEARTS, SPADES): for rank in full_ranks: self.deck.add(PlayingCard(rank, suit)) # We only want three of the short rank. No hearts, because. for suit in (CLUBS, DIAMONDS, SPADES): self.deck.add(PlayingCard(short_rank, suit))
def new_deal(self): # Set tricks and bids to zero. for seat in self.seats: seat.data.tricks = 0 seat.data.bid = 0 dealer_name = self.dealer.player_name self.bc_pre("^R%s^~ (%s%s^~) gives the cards a good shuffle...\n" % (dealer_name, self.get_color_code(self.dealer), self.dealer)) deck = new_deck() deck.shuffle() # Deal out all of the cards. self.bc_pre("^R%s^~ deals the cards out to all of the players.\n" % dealer_name) for seat in self.seats: seat.data.hand = Hand() for _ in range(13): for seat in self.seats: seat.data.hand.add(deck.discard()) # If we're in whist mode, flip the dealer's last card to determine # trumps. if self.whist: last_card = self.dealer.data.hand[-1] self.bc_pre("^R%s^~ flips their last card; it is ^C%s^~.\n" % (dealer_name, card_to_str(last_card, LONG))) self.trump_suit = last_card.suit else: # Hearts forever. self.trump_suit = HEARTS # Sort everyone's hands and show them to everyone. for seat in self.seats: seat.data.hand = sorted_hand(seat.data.hand, self.trump_suit) self.show_hands()
def new_deal(self): dealer_name = self.dealer.player_name self.bc_pre( "^R%s^~ (%s%s^~) gives the cards a good shuffle...\n" % (dealer_name, self.get_color_code(self.dealer), self.dealer)) deck = new_deck() deck.shuffle() # Deal out all of the cards. We'll flip the last one; that determines # the trump suit for the hand. self.bc_pre("^R%s^~ deals the cards out to all the players.\n" % dealer_name) for seat in self.seats: seat.data.hand = Hand() for i in range(13): for seat in self.seats: seat.data.hand.add(deck.discard()) # Flip the dealer's last card; it determines the trump suit. last_card = self.dealer.data.hand[-1] self.bc_pre("^R%s^~ flips their last card; it is ^C%s^~.\n" % (dealer_name, card_to_str(last_card, LONG))) self.trump_suit = last_card.suit # Sort everyone's hands. for seat in self.seats: seat.data.hand = sorted_hand(seat.data.hand, self.trump_suit) # Show everyone their hands. self.show_hands() # Set the trick counts to zero. self.ns.tricks = 0 self.ew.tricks = 0