source/common/Liverpool.py
def canPlayGroup(key, card_group, this_round):
    """checks if a group can be played
    
    For runs this assumes card_group has already been processed (sorted with Aces and Wilds assigned
    appropriate tempnumber).
    returns True if it can, otherwise raises an exception with an explanation.
    In dictionary key of prepared (=assigned) cards = key of button = (based on (player index, card group index))
    """

    if key[1] < Meld_Threshold[this_round][0]:   # then this is a set.
        # check if this is a valid set.
        if len(card_group) < 3:
            raise Exception("Too few cards in set - minimum is 3")
        # check that group contains only wilds and one card_number.
        card_numbers = []
        num_cards = len(card_group)
        for card in card_group:
            if not isWild(card):
                card_numbers.append(card.number)
        num_naturals = len(card_numbers)
        unique_numbers = list(set(card_numbers))
        if len(unique_numbers) > 1:
            raise Exception("Cards in a set must all have the same rank (except wilds).")
        # check that have more naturals than wilds.
        unique_number = unique_numbers[0]
        if num_naturals <= (num_cards - num_naturals):
            text = "Too many wilds in set of " + str(unique_number) + "'s"
            raise Exception(text)
    else:
        # check that this processed run follows rules
        # Note processRuns also has rule checking (rules around assigning Wilds and placing
        # Aces hi/lo are done in that method).
        if len(card_group) < 4:
            raise Exception("Too few cards in run - minimum is 4")
        suits_in_run = []
        for card in card_group:
            if not isWild(card):
                suits_in_run.append(card.suit)
        unique_suits = list(set(suits_in_run))
        if len(unique_suits) > 1:
            raise Exception("Cards in a run must all have the same suit (except wilds).")
    return True
checks if a group can be played
    
    For runs this assumes card_group has already been processed (sorted with Aces and Wilds assigned
    appropriate tempnumber).
    returns True if it can, otherwise raises an exception with an explanation.
    In dictionary key of prepared (=assigned) cards = key of button = (based on (player index, card group index))
    
checks if a group can be played
For runs this assumes card_group has already been processed (sorted with Aces and Wilds assigned
appropriate tempnumber).
returns True if it can, otherwise raises an exception with an explanation.
In dictionary key of prepared (=assigned) cards = key of button = (based on (player index, card group index))
checks if a group can be played For runs this assumes card_group has already been processed ( sorted with Aces and Wilds assigned appropriate tempnumber ) . returns True if it can otherwise raises an exception with an explanation . In dictionary key of prepared ( = assigned ) cards = key of button = ( based on ( player index card group index ))
def canPlayGroup(key, card_group, this_round):
    if key[1] < Meld_Threshold[this_round][0]:   
        if len(card_group) < 3:
            raise Exception("Too few cards in set - minimum is 3")
        card_numbers = []
        num_cards = len(card_group)
        for card in card_group:
            if not isWild(card):
                card_numbers.append(card.number)
        num_naturals = len(card_numbers)
        unique_numbers = list(set(card_numbers))
        if len(unique_numbers) > 1:
            raise Exception("Cards in a set must all have the same rank (except wilds).")
        unique_number = unique_numbers[0]
        if num_naturals <= (num_cards - num_naturals):
            text = "Too many wilds in set of " + str(unique_number) + "'s"
            raise Exception(text)
    else:
        if len(card_group) < 4:
            raise Exception("Too few cards in run - minimum is 4")
        suits_in_run = []
        for card in card_group:
            if not isWild(card):
                suits_in_run.append(card.suit)
        unique_suits = list(set(suits_in_run))
        if len(unique_suits) > 1:
            raise Exception("Cards in a run must all have the same suit (except wilds).")
    return True
def canPlayGroup ( key , card_group , this_round ) : if key [ 1 ] < Meld_Threshold [ this_round ] [ 0 ] : if len ( card_group ) < 3 : raise Exception ( "Too few cards in set - minimum is 3" ) card_numbers = [ ] num_cards = len ( card_group ) for card in card_group : if not isWild ( card ) : card_numbers . append ( card . number ) num_naturals = len ( card_numbers ) unique_numbers = list ( set ( card_numbers ) ) if len ( unique_numbers ) > 1 : raise Exception ( "Cards in a set must all have the same rank (except wilds)." ) unique_number = unique_numbers [ 0 ] if num_naturals <= ( num_cards - num_naturals ) : text = "Too many wilds in set of " + str ( unique_number ) + "'s" raise Exception ( text ) else : if len ( card_group ) < 4 : raise Exception ( "Too few cards in run - minimum is 4" ) suits_in_run = [ ] for card in card_group : if not isWild ( card ) : suits_in_run . append ( card . suit ) unique_suits = list ( set ( suits_in_run ) ) if len ( unique_suits ) > 1 : raise Exception ( "Cards in a run must all have the same suit (except wilds)." ) return True
checks if a group can be played
For runs this assumes card_group has already been processed (sorted with Aces and Wilds assigned
appropriate tempnumber).
checks if a group can be played For runs this assumes card_group has already been processed ( sorted with Aces and Wilds assigned appropriate tempnumber ) .
"""checks if a group can be played
    
    For runs this assumes card_group has already been processed (sorted with Aces and Wilds assigned
    appropriate tempnumber).
    returns True if it can, otherwise raises an exception with an explanation.
    In dictionary key of prepared (=assigned) cards = key of button = (based on (player index, card group index))
    """ # then this is a set. # check if this is a valid set. # check that group contains only wilds and one card_number. # check that have more naturals than wilds. # check that this processed run follows rules # Note processRuns also has rule checking (rules around assigning Wilds and placing # Aces hi/lo are done in that method).
key
card_group
this_round