Example #1
0
def test_deal_cards():
    deck = cards.create_deck()
    inDeck = deck[:]
    (hum, cpu) = cards.deal_cards(inDeck)
    assert len(hum) == 26
    assert len(cpu) == 26
    assert deck == inDeck
Example #2
0
def test_deal_cards():
    deck = cards.create_deck()
    inDeck = deck[:]
    (hum, cpu) = cards.deal_cards(inDeck)
    assert len(hum) == 26
    assert len(cpu) == 26
    assert deck == inDeck
Example #3
0
 def new_game(self, num_of_players: int, num_of_humans: int):
     self.pool: List[int] = pool_of_numbers()
     self.winner: Union[Human, Computer, None] = None
     self.cards: List[list] = deal_cards(num_of_players)
     self.table_of_players: List[Union[Human, Computer]] = []
     if num_of_humans == num_of_players:
         for pl in range(num_of_players):
             player = Human(f'Person{pl + 1}', self.cards.pop())
             self.table_of_players.append(player)
     else:
         for hm in range(num_of_humans):
             human = Human(f"Person{hm + 1}", self.cards.pop())
             self.table_of_players.append(human)
         for cm in range(num_of_players - num_of_humans):
             computer = Computer(f"Computer{cm + 1}", self.cards.pop())
             self.table_of_players.append(computer)
     self.start_match()
Example #4
0
        print("You lose {} cards!".format(len(pot)))
        # print("LOSE", end="")
        c_reserve.extend(pot)

    elif winner == 0:  # A tie; a cause for WAR!
        print("There is a tie.")
        print("Declare War!")
        interface.wait_for_input()
        # print(" TIE", end="\n")

        (h_hand, h_reserve) = flip_if_needed((h_hand, h_reserve), n=3)
        (c_hand, c_reserve) = flip_if_needed((c_hand, c_reserve), n=3)

        pot.extend(cards.pull_three(h_hand))
        pot.extend(cards.pull_three(c_hand))

        # Weeeee, recursion!
        ((h_hand, h_reserve), (c_hand, c_reserve)) = play_turn((h_hand, h_reserve), (c_hand, c_reserve), pot)

    return ((h_hand, h_reserve), (c_hand, c_reserve))


if __name__ == "__main__":

    deck = cards.create_deck()
    deck = cards.shuffle_cards(deck)
    (h_hand, c_hand) = cards.deal_cards(deck)

    interface.wait_for_input(DISABLE_WAIT)
    won = main((h_hand, []), (c_hand, []))
Example #5
0
    '''

    # BUY ROUND

    # Make it possible to buy cards from discard

    card_dragging = False
    card_dragged = None
    end_buy_button = pg_gui.elements.UIButton(relative_rect=pg.Rect((SCREEN_SIZE[0]//2.5, SCREEN_SIZE[1]//2), (150, 100)),
                                                        text='End Buy Round',
                                                        manager=GUI_MANAGER)

    # Shuffling

    cards.deal_cards('PLAYERS', 2)
    cards.deal_cards('SHOP', 4)

    while GAME_STATE == 'BUY_ROUND':
        DT = CLOCK.tick(FPS)/1000.0
        # input
        for event in pg.event.get():
            if event.type == pg.QUIT:
                GAME_STATE = 'MAIN_MENU'
            if event.type == pg.MOUSEBUTTONDOWN:
                x, y = event.pos
                for card in cards.P1_HAND:
                    if card.rect.collidepoint(x, y):
                        player.P1.points += card.cost # add value of card
                        if card.type == 'STORY':
                            cards.STORY_DISCARD.append(card)
Example #6
0
        #print("LOSE", end="")
        c_reserve.extend(pot)

    elif winner == 0:  # A tie; a cause for WAR!
        print("There is a tie.")
        print("Declare War!")
        interface.wait_for_input()
        #print(" TIE", end="\n")

        (h_hand, h_reserve) = flip_if_needed((h_hand, h_reserve), n=3)
        (c_hand, c_reserve) = flip_if_needed((c_hand, c_reserve), n=3)

        pot.extend(cards.pull_three(h_hand))
        pot.extend(cards.pull_three(c_hand))

        # Weeeee, recursion!
        ((h_hand, h_reserve), (c_hand, c_reserve)) = play_turn(
            (h_hand, h_reserve), (c_hand, c_reserve), pot)

    return ((h_hand, h_reserve), (c_hand, c_reserve))


if __name__ == '__main__':

    deck = cards.create_deck()
    deck = cards.shuffle_cards(deck)
    (h_hand, c_hand) = cards.deal_cards(deck)

    interface.wait_for_input(DISABLE_WAIT)
    won = main((h_hand, []), (c_hand, []))
Example #7
0
 def test_deal_cards_invalid_input(self, error, user_input):
     with pytest.raises(error) as exp:
         deal_cards(user_input)
         assert exp == error
Example #8
0
 def test_deal_cards_diff_num_of_players(self, num, exp):
     """Test if number of cards in stack returned and if all cards in stack has 27 cells"""
     cards = deal_cards(num)
     assert len(cards) == exp
     for card in cards:
         assert len(card) == 27