Ejemplo n.º 1
0
 def draw_two(self):
     new_cards = []
     for i in range(2):
         new_cards.append(df.choose_card())
     print('Draw 2! You drew: {} and {}.'.format(hf.decode(new_cards[0]),
                                                 hf.decode(new_cards[1])))
     self.hand.extend(new_cards)
     self.hand.sort()
     print('You\'re now holding: ' + self.display_hand() + '.')
Ejemplo n.º 2
0
 def draw_card(self, read=False):
     output_hand = self.hand.copy()
     self.new_card = df.choose_card()
     if read:
         print('You drew a {}.'.format(hf.decode(self.new_card)))
     output_hand.append(self.new_card)
     output_hand.sort()
     self.new_card = hf.decode(self.new_card)
     self.hand = output_hand
Ejemplo n.º 3
0
 def display_hand(self):
     readout = ''
     count = 2
     for card in self.hand:
         english = hf.decode(card)
         readout += english
         if count < len(self.hand):
             readout += ', '
         elif count == len(self.hand):
             readout += ', and '
         count += 1
     return readout
Ejemplo n.º 4
0
 def list_hand(self):
     i = 1
     for card in self.hand:
         print('  {}. {}'.format(i, hf.decode(card)))
         i += 1
Ejemplo n.º 5
0
 def read_last(self):
     print('Last card played was a {}.'.format(hf.decode(self.last_card)))
Ejemplo n.º 6
0
 print('What would you like to do?')
 print('  1. Draw a card\n  2. Play a card\n--> ', end='')
 prompt = input()
 if prompt == '1':  # Draw a card
     players[token.count].draw_card(read=True)
     players[token.count].holding(now=True)
     token.read_last()
 elif prompt == '2':  # Play a card
     choice = players[token.count].play_card()
     if choice == -1:
         continue
     chosen_card = players[token.count].hand[choice]
     if not hf.is_legal(chosen_card, token.last_card):
         hf.admonish(chosen_card, token.last_card)
     else:
         print('You played: ' + hf.decode(chosen_card) + '.')
         token.last_card = chosen_card
         token.wild_color = ''  # Clear the restriction on what color can be played.
         if chosen_card[0] == 'w':  # Record any actions that affect the following player. vv
             print('What color do you choose?')
             print('r = Red | y = Yellow | g = Green | b = Blue')
             token.wild_color = input('  --> ')
             token.last_card = token.wild_color + chosen_card[1]
         if chosen_card[1] == 's':
             token.is_skipped = True
         elif chosen_card[1] == 'r':
             token.reverse()
             token.is_first_reversed = True
         elif chosen_card[1] == 'd':
             token.is_draw_two = True
         elif chosen_card[1] == 'f':