Beispiel #1
0
 def __init__(self, name):
     self.cards = Cards()
     self.name = name
     self.winner = False
     self.cut = None
     self.played_dropped_card = False
     self.rest_value = None
Beispiel #2
0
 def test_receiving_valid_card(self):
     cards = Cards()
     number_of_cards_before_receiving_card = len(cards)
     valid_card = Card(4, "O")
     cards.receive_card(valid_card)
     number_of_cards_after_receiving_card = len(cards)
     assert cards[
         0] == valid_card and number_of_cards_after_receiving_card - number_of_cards_before_receiving_card == 1
 def _give_cards_to_players(game, deck):
     for i in range(len(game.players)):
         game.players[i].cards = Cards()
         for _ in range(game.CARDS_IN_HAND):
             game.players[i].cards.receive_card(deck.retrieve_card())
         game.players[i].rest_value = game.players[i].value_of_current_hand(
         )
     return game, deck
Beispiel #4
0
 def test_dropping_last_card_when_no_card_in_cards(self):
     cards = Cards()
     number_of_cards_before_dropping_card = len(cards)
     try:
         cards.drop_cards()
         has_raised_empty_list_of_cards_exception = False
     except game_exceptions.EmptyListOfCards:
         has_raised_empty_list_of_cards_exception = True
     except Exception:
         has_raised_empty_list_of_cards_exception = False
     number_of_cards_after_dropping_card = len(cards)
     assert has_raised_empty_list_of_cards_exception and number_of_cards_before_dropping_card == number_of_cards_after_dropping_card
Beispiel #5
0
 def test_receiving_a_non_card_element(self):
     cards = Cards()
     number_of_cards_before_receiving_card = len(cards)
     invalid_card = "string"
     try:
         cards.receive_card(invalid_card)
         has_rised_type_error = False
     except TypeError:
         has_rised_type_error = True
     except Exception:
         has_rised_type_error = False
     number_of_cards_after_receiving_card = len(cards)
     assert has_rised_type_error and number_of_cards_after_receiving_card == number_of_cards_before_receiving_card
Beispiel #6
0
 def _initialize_hand(self, style=None):
     if not hasattr(self, 'games_detector'):
         self.games_detector = GamesDetector()
     hand = Cards()
     if style == "one_same_number_game_one_ladder":
         hand.receive_card(Card(1, "O"))
         hand.receive_card(Card(1, "B"))
         hand.receive_card(Card(1, "C"))
         hand.receive_card(Card(3, "O"))
         hand.receive_card(Card(4, "O"))
         hand.receive_card(Card(5, "O"))
         hand.receive_card(Card(9, "O"))
     elif style == "two_same_number_game_no_ladder":
         hand.receive_card(Card(1, "O"))
         hand.receive_card(Card(1, "B"))
         hand.receive_card(Card(1, "C"))
         hand.receive_card(Card(3, "E"))
         hand.receive_card(Card(3, "O"))
         hand.receive_card(Card(3, "C"))
         hand.receive_card(Card(9, "O"))
     elif style == "no_same_number_game_one_ladder":
         hand.receive_card(Card(1, "O"))
         hand.receive_card(Card(2, "B"))
         hand.receive_card(Card(4, "C"))
         hand.receive_card(Card(5, "E"))
         hand.receive_card(Card(6, "E"))
         hand.receive_card(Card(7, "E"))
         hand.receive_card(Card(8, "E"))
     elif style == "no_game":
         hand.receive_card(Card(1, "O"))
         hand.receive_card(Card(2, "B"))
         hand.receive_card(Card(4, "C"))
         hand.receive_card(Card(5, "E"))
         hand.receive_card(Card(6, "E"))
         hand.receive_card(Card(10, "E"))
         hand.receive_card(Card(11, "C"))
     return hand
Beispiel #7
0
 def test_retrieving_card_when_no_card_left(self):
     deck = Deck()
     deck.cards_in_deck = Cards()
     deck.retrieve_card()
     assert len(deck.cards_in_deck) == 47