コード例 #1
0
ファイル: test_cards.py プロジェクト: JoieDFW/wargame
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
コード例 #2
0
ファイル: test_cards.py プロジェクト: JoieDFW/wargame
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
コード例 #3
0
ファイル: game.py プロジェクト: petrishutin/cli_game_loto
 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()
コード例 #4
0
ファイル: main.py プロジェクト: JoieDFW/wargame
        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, []))
コード例 #5
0
ファイル: main.py プロジェクト: gannmann/rpg_card_gam
    '''

    # 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)
コード例 #6
0
ファイル: main.py プロジェクト: JoieDFW/wargame
        #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, []))
コード例 #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
コード例 #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