def test_set_simple(): h1 = Hand() h1.put_card(Card(2, Color.DIAMOND)) h1.put_card(Card(2, Color.CLUB)) h1.put_card(Card(2, Color.SPADE)) sets1 = list(h1.iter_sets()) h2 = Hand() h2.put_card(Card(2, Color.SPADE)) h2.put_card(Card(2, Color.CLUB)) h2.put_card(Card(2, Color.DIAMOND)) sets2 = list(h2.iter_sets()) assert len(sets1) == 1 assert len(sets2) == 1 assert sets1 == sets2 h1.put_card(Card.JOKER) sets1 = list(h1.iter_sets()) assert len(sets1) == 5 assert sorted(sets1) == sorted([ Set(2, (Color.SPADE, Color.CLUB, Color.DIAMOND)), Set(2, (Color.SPADE, Color.CLUB, Color.DIAMOND, None)), Set(2, (None, Color.CLUB, Color.DIAMOND)), Set(2, (Color.SPADE, None, Color.DIAMOND)), Set(2, (Color.SPADE, Color.CLUB, None)), ])
from liverpool.common import Card, Color, Objective from liverpool.hand import Hand h = Hand() h.put_card(Card(7, Color.SPADE)) h.put_card(Card(7, Color.DIAMOND)) h.put_card(Card(7, Color.HEART)) h.put_card(Card(2, Color.HEART)) h.put_card(Card(3, Color.HEART)) h.put_card(Card(3, Color.CLUB)) h.put_card(Card.JOKER) h.put_card(Card(4, Color.HEART)) h.put_card(Card(5, Color.HEART)) print() print('Sets:') for set_ in h.iter_sets(): print(set_) print() print('Runs:') for run in h.iter_runs(): print(run) objective = Objective(1, 1) print() print('1/1 Melds:') for lay in h.iter_melds(objective): print(lay)