def set_up(game: Game): # Make a copy of the deck deck = list(DECK) # Pop 3 camels into open game.open_cards = n_cards_from_top(3, deck) # Now shuffle balance deck random.shuffle(deck) # Pick 2 more cards for the open game.open_cards += n_cards_from_top(2, deck) # 5 cards to each player game.player1.cards = n_cards_from_top(5, deck) game.player2.cards = n_cards_from_top(5, deck) # Balance in the deck game.cards = deck
def test_buy_single_card_too_many_non_camel(): game = Game.initialize() set_up(game) game.next_up = 1 # Give next player 7 cards game.player1.cards = [Card(kind=CardKinds.Leather)] * 7 open_cards = list(game.open_cards) player_s_cards = list(game.player2.cards) top_card = game.cards[0] cards_left = len(game.cards) outcome = buy_one(game, 2) with soft_assertions(): assert_that(outcome).is_equal_to(Outcomes.TOO_MANY_CARDS) assert_that(game.cards).is_length(cards_left) assert_that(game.player1.cards).is_length(7)
def test_buy_single_card(): game = Game.initialize() set_up(game) game.next_up = 2 index = 3 # Let's keep the current open cards as reference open_cards = list(game.open_cards) player_s_cards = list(game.player2.cards) top_card = game.cards[0] cards_left = len(game.cards) outcome = buy_one(game, index) with soft_assertions(): assert_that(Card.camel()).is_equal_to(Card.camel()) assert_that(game).has_next_up(1) assert_that(game.open_cards).is_length(5) assert_that(game.cards).is_length(cards_left - 1) assert_that( game.open_cards).is_equal_to(open_cards[:index] + [top_card] + open_cards[index + 1:]) assert_that(game.player2.cards).is_equal_to(player_s_cards + [open_cards[index]]) assert_that(outcome).is_equal_to(Outcomes.NEXT_PLAYER)
def test_should_have_five_open_cards(): game = Game.initialize() set_up(game) assert_that(game.open_cards).is_length(5)
def test_should_have_40_cards_left_in_deck(): game = Game.initialize() set_up(game) assert_that(game.cards).is_length(40)
def test_should_have_given_5_cards_to_each_player(): game = Game.initialize() set_up(game) assert_that(game.player1.cards).is_length(5) assert_that(game.player2.cards).is_length(5)
def test_should_have_at_least_3_open_camels(): game = Game.initialize() set_up(game) open_camel_cards = camel_cards(cards=game.open_cards) assert_that(len(open_camel_cards)).is_greater_than_or_equal_to(3)