Пример #1
0
 def test_no_lay_down(self):
     ranks = ["2", "3", "4", "5"]
     suits = ["spades"]
     deck = [(rank, suit) for rank in ranks for suit in suits]
     hand = {}
     for rank in ranks:
         drawCard("Matt", deck, hand)
         self.assertTrue(rank in hand and len(hand[rank]) == 1)
Пример #2
0
 def test_lay_down(self):
     ranks = ["2"]
     suits = ["spades", "hearts", "diamonds", "clubs"]
     deck = [(rank, suit) for rank in ranks for suit in suits]
     hand = {}
     for i in range(1, 4):
         drawCard("Matt", deck, hand)
         self.assertTrue("2" in hand and len(hand["2"]) == i)
     drawCard("Matt", deck, hand)
     self.assertFalse("2" in hand)  # 2s should be laid down
Пример #3
0
def play_game(deck,hand):
  logfiles = open('cardlog.txt','w')
  previousturnlength = 48
  while len(deck) > 0:
    logfiles.write('Deck length: ' + str(len(deck)) + '\n')
    logfiles.write('My hand: ' + str(hand) + '\n')
    gofish1.drawCard('Amy',deck,hand)
    assert len(deck) == (previousturnlength-1), 'Deck does not have one less card'
    previousturnlength = len(deck)
    logfiles.write('My hand: ' + str(hand) + '\n')
    if len(deck) < 13:
      for x in range(12,0,-1):
        if len(deck) == x:
          assert (len(hand) + len(deck)) <= x*4, 'Card not removed from hand'
  logfiles.close()   
Пример #4
0
import gofish1

deck1 = [ ( "3", "hearts" ) ]
hand1 = { "2" : [ "hearts", "spades" ] }

gofish1.drawCard("Test1", deck1, hand1)


deck2 = [ ( "3", "hearts" ) ]
hand2 = { "2" : [ "hearts", "spades" ],
          "3" : [ "diamonds" ] }

gofish1.drawCard("Test2", deck2, hand2)

deck3 = [ ( "3", "hearts" ) ]
hand3 = { "2" : [ "hearts", "spades" ],
          "3" : [ "diamonds", "clubs", "spades" ] }

gofish1.drawCard("Test3", deck3, hand3)

deck4 = [ ( "3", "hearts" ) ]
hand4 = { "2" : [ "hearts", "spades" ],
          "3" : [ "diamonds", "clubs", "spades", "hearts" ] }

gofish1.drawCard("Test4", deck4, hand4)


deck5 = [ ( "3", "hearts" ) ]
hand5 = { "4" : [ "hearts", "spades" ],
          "5" : [ "diamonds" ], 
          "6" : [ "clubs" ],