Ejemplo n.º 1
0
 def pass_cards(self, hand, direction=2, all_is_win=False):
     pass_cards = []
     for count, colour in self.colour_lose_order(hand):
         pass_cards += sort_by_value(filter_colour(hand, colour),
                                     reverse=True)
         if len(pass_cards) >= 3:
             break
     return pass_cards[-3:]
Ejemplo n.º 2
0
 def show_summarized(cls, cards):
     from util import filter_colour
     txt = ''
     for colour in colours:
         card_values = [card.value for card in filter_colour(cards, colour)]
         if len(card_values):
             txt += u'%s%s ' % (cls.symbols[colour], ''.join(
                 cls.abbrev[val] for val in sorted(card_values)))
     return txt
Ejemplo n.º 3
0
 def round_winner(self, round):  # @ReservedAssignment
     ''' Consider only opening-colour cards '''
     opening_colour = self.opening_colour(round)
     cards = filter_colour(self._cards_played[round], opening_colour)
     ''' Pick the highest one '''
     highest_val = 0
     for k, card in enumerate(cards):
         if card.value > highest_val:
             highest_val = card.value
             highest_player = k
     return highest_player
Ejemplo n.º 4
0
 def play_turn(self, state, hand, all_is_win=False):
     legal = sort_by_value(legal_moves(state, hand))
     if not legal[0].colour == state.current_colour():
         ''' lose colour if good option (1-2 cards), else just play '''
         lose_colours = [
             pair[1] for pair in self.colour_lose_order(hand)
             if 1 <= pair[0] <= 2
         ]
         play_cards = []
         for colour in lose_colours:
             play_cards += sort_by_value(filter_colour(legal, colour),
                                         reverse=True)
         if len(play_cards):
             return play_cards[-1]
     ''' if recognizing or nothing to get rid of, just play '''
     return super(IsolateColour, self).play_turn(state=state,
                                                 hand=hand,
                                                 all_is_win=all_is_win)
Ejemplo n.º 5
0
 def opening_colour_cards(self, round=None):
     round = round if round is not None else self.round
     return filter_colour(self.round_cards(round),
                          self.opening_colour(round))
Ejemplo n.º 6
0
 def cards_played_colour(self, colour):
     return filter_colour(self.cards_played_all(), colour)