Ejemplo n.º 1
0
def test_lay_regression1():
  """Set iterator should not return duplicates."""
  h = Hand()
  cards = [
    Card(2, Color.CLUB),
    Card(2, Color.HEART),
    Card(2, Color.DIAMOND),
    Card(5, Color.SPADE),
    Card(5, Color.HEART),
    Card(Rank.KING, Color.DIAMOND),
    Card.JOKER,
    Card.JOKER,
    Card.JOKER,
    Card.JOKER,
  ]

  for card in cards:
    h.put_card(card)

  objective = Objective(3, 0)

  # if set iterator returns dupes, this will be ~= 780
  assert len(list(h.iter_melds(objective))) == 39
Ejemplo n.º 2
0
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)),
  ])
Ejemplo n.º 3
0
from __future__ import print_function

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):