コード例 #1
0
ファイル: testCard.py プロジェクト: theodoremoreland/Poker
 def test_should_return_all_ranks(self):
     """
     """
     for number in range(1, 14):
         card = Card('Hearts', number)
         rank = card.get_rank()
         self.assertEqual(number, rank)
コード例 #2
0
ファイル: testCard.py プロジェクト: theodoremoreland/Poker
    def test_should_return_kind_for_king(self):
        """
        """

        card = Card('Hearts', 13)
        kind = card.get_kind()
        self.assertEqual('King', kind)
コード例 #3
0
ファイル: testCard.py プロジェクト: theodoremoreland/Poker
    def test_should_return_kind_for_queen(self):
        """
        """

        card = Card('Spades', 12)
        kind = card.get_kind()
        self.assertEqual('Queen', kind)
コード例 #4
0
ファイル: testCard.py プロジェクト: theodoremoreland/Poker
    def test_should_return_kind_for_jack(self):
        """
        """

        card = Card('Diamonds', 11)
        kind = card.get_kind()
        self.assertEqual('Jack', kind)
コード例 #5
0
ファイル: testCard.py プロジェクト: theodoremoreland/Poker
    def test_should_return_kind_for_ace(self):
        """
        """

        card = Card('Diamonds', 1)
        kind = card.get_kind()
        self.assertEqual('Ace', kind)
コード例 #6
0
ファイル: testCard.py プロジェクト: theodoremoreland/Poker
 def test_should_override_object_equality(self):
     """
     """
     card_1 = Card("Hearts", 13)
     card_2 = Card("Hearts", 13)
     card_3 = Card("Hearts", 12)
     self.assertEqual(card_1, card_2)
     self.assertNotEqual(card_2, card_3)
コード例 #7
0
ファイル: testCard.py プロジェクト: theodoremoreland/Poker
 def test_should_return_kind_for_numbers(self):
     """
     """
     for number in range(2, 11):
         card = Card('Hearts', number)
         kind = card.get_kind()
         self.assertEqual(
             str(number), kind,
             f"Test failed on number: {number} and kind: {kind}.")
コード例 #8
0
ファイル: Deck.py プロジェクト: USB-Port/BlackJack
 def __init__(self):
     self.cards = []
     for i in range(0, 4):
         for k in range(0, 13):
             card = Card((k * 98), (i * 175), (k * 97) + 105,
                         (i * 175) + 175)
             card.value = k + 1
             if k > 10:
                 card.value = 10
             self.cards.append(card)
コード例 #9
0
    def init_pinochle_deck(self):
        """
        Initializes deck to the pinochle configuration.
        See https://en.wikipedia.org/wiki/Pinochle for details.
        :return: Modifies self.cards in place.
        """

        self.cards = []
        allwd_val = {cs.NINE, cs.TEN, cs.JACK, cs.QUEEN, cs.KING, cs.ACE}

        for val in allwd_val:
            for suit in cs.SUITS:
                self.cards.append(Card(value=val, suit=suit))
                self.cards.append(Card(value=val, suit=suit))
コード例 #10
0
    def init_std_deck(self, num_jokers=0):
        """
        Initializes deck to the standard configuration of 52 cards (13 cards of all 4 suits).
        Can include jokers via optional arg.
        :return: Modifies self.cards in place.
        """
        self.cards = []

        for val in Value.allowed:
            if num_jokers == 0 and val != cs.JOKER:
                for suit in cs.SUITS:
                    self.cards.append(Card(value=val, suit=suit))
            elif num_jokers > 0 and val == cs.JOKER:
                for i in range(num_jokers):
                    self.cards.append(Card(value=cs.JOKER, suit=None))
コード例 #11
0
ファイル: testCard.py プロジェクト: theodoremoreland/Poker
 def test_should_return_expression_for_jack(self):
     """
     """
     for suit in self.suits:
         card = Card(suit, 11)
         kind = str(card)
         self.assertEqual(f'Jack of {suit}', kind,
                          f'Test failed on suit: {suit}')
コード例 #12
0
async def showCard(message: types.Message, state: FSMContext):
    await deleteMessages(message.message_id, message.chat.id, state)
    data = await state.get_data()
    if data.__len__() == 0:
        data['card'] = Card()
    await message.answer('Ваша корзина:',
                         reply_markup=showCardMarkup(data['card']),
                         disable_notification=True)
    await Yap.card.set()
コード例 #13
0
ファイル: play_game.py プロジェクト: theodoremoreland/Poker
def create_deck():
    """
    """
    deck = []
    suits = ['Clubs', 'Spades', 'Diamonds', 'Hearts']

    for suit in suits:
        for rank in range(1, 14):
            deck.append(Card(suit, rank))

    random.shuffle(deck)
    return deck
コード例 #14
0
async def openSettingsMenu(message: types.Message, state: FSMContext):
    await message.delete()
    await message.answer("Выберите категорию",
                         reply_markup=mainYapMarkup(),
                         disable_notification=True)
    await Yap.yapMainMenu.set()
    data = {
        'current': 1,
        'type': '',
        'card': Card(),
        'productType': message.text,
        'order': 'asc',
        'startId': message.message_id
    }
    await state.set_data(data)
コード例 #15
0
    def play(self):
        card = Card(0, 0, 100, 175)
        deck = Deck()
        dealer = Dealer()
        player = Player()

        isGame = False

        i = 0
        while True:
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN:

                    if event.key == pygame.K_a:
                        pass

                    if event.key == pygame.K_s:
                        deck.shuffle()
                        isGame = True

                    if event.key == pygame.K_SPACE:
                        if i < 52:
                            i = i + 1

                    if event.key == pygame.K_ESCAPE:
                        sys.exit()

            self.screen.fill((0, 0, 0))
            self.screen.blit(self.image, self.rect)

            deck.deal(self.screen, dealer, player)

            pygame.display.flip()

            if dealer.get_hand >= player.get_hand:
                msg = "Dealer Wins"
            else:
                msg = "player wins"
            if isGame:
                Tk().wm_withdraw()  # to hide the main window
                messagebox.showinfo("Game", msg)
                isGame = False
コード例 #16
0
ファイル: testCard.py プロジェクト: theodoremoreland/Poker
 def setUpClass(cls):
     cls.suits = ['Clubs', 'Spades', 'Diamonds', 'Hearts']
     cls.card = Card("Diamonds", 13)
コード例 #17
0
ファイル: testPoker.py プロジェクト: theodoremoreland/Poker
    def setUpClass(cls):
        cls.Poker = Poker()
        cls.poker_hands = [
            "Straight Flush", "Four Of A Kind", "Full House", "Flush",
            "Straight", "Three Of A Kind", "Two Pair", "One Pair"
        ]

        cls.test_cards = {
            "Straight Flush": [
                Card("Hearts", 7),
                Card("Hearts", 8),
                Card("Hearts", 9),
                Card("Hearts", 10),
                Card("Hearts", 11)
            ],
            "Four Of A Kind": [
                Card('Spades', 7),
                Card('Spades', 7),
                Card('Spades', 7),
                Card('Spades', 7),
                Card('Spades', 1)
            ],
            "Full House": [
                Card('Spades', 13),
                Card('Spades', 13),
                Card('Spades', 12),
                Card('Spades', 12),
                Card('Spades', 12)
            ],
            "Flush": [
                Card("Hearts", 1),
                Card("Hearts", 2),
                Card("Hearts", 3),
                Card("Hearts", 5),
                Card("Hearts", 6)
            ],
            "Straight": [
                Card("Spades", 7),
                Card("Hearts", 8),
                Card("Diamonds", 9),
                Card("Clubs", 10),
                Card("Hearts", 11)
            ],
            "Three Of A Kind": [
                Card("Clubs", 12),
                Card("Clubs", 12),
                Card("Clubs", 12),
                Card("Clubs", 13),
                Card("Clubs", 11)
            ],
            "Two Pair": [
                Card("Clubs", 12),
                Card("Clubs", 12),
                Card("Clubs", 13),
                Card("Clubs", 13),
                Card("Clubs", 11)
            ],
            "One Pair": [
                Card("Clubs", 12),
                Card("Clubs", 12),
                Card("Clubs", 13),
                Card("Clubs", 1),
                Card("Clubs", 11)
            ]
        }
コード例 #18
0
ファイル: main.py プロジェクト: ArtemiiLulevich/game_pc
from classes.Card import Card
import shelve
import random

with shelve.open('data_for_game') as data:
    cards = data['cards']

deck = []

for card in cards:

    card_attributes = tuple(card.split('\t'))

    color, form, value = card_attributes

    new_card = Card(color, form, value)  # colour, form, value

    deck.append(new_card)

random.shuffle(deck)

for card in deck:
    # print(card)
    card.get_card_name()

print('Count of cards in deck is {}'.format(len(deck)))



コード例 #19
0
    def initialize_combinations(self):
        # Class A
        ace_trump = Card(cs.ACE, self.trump)
        king_trump = Card(cs.KING, self.trump)
        queen_trump = Card(cs.QUEEN, self.trump)
        jack_trump = Card(cs.JACK, self.trump)
        ten_trump = Card(cs.TEN, self.trump)

        self.combinations["RUN"] = (list_to_dict(
            [ace_trump, king_trump, queen_trump, jack_trump,
             ten_trump]), 150, "A")
        self.combinations["DIX"] = (list_to_dict([Card(cs.NINE,
                                                       self.trump)]), 10, "A")

        for suit in cs.SUITS:
            self.combinations["MARRIAGE_" + suit] = \
                (list_to_dict([Card(cs.KING, suit), Card(cs.QUEEN, suit)]), 40 if suit == self.trump else 20, "A")

        # Class B
        for value in [(cs.ACE, 100), (cs.KING, 80), (cs.QUEEN, 60),
                      (cs.JACK, 40, "B")]:
            list_around = []

            for suit in cs.SUITS:
                list_around.append(Card(value[0], suit))

            self.combinations[value[0] +
                              "_AROUND"] = (list_to_dict(list_around),
                                            value[1], "B")

        # Class C
        pinochle_list = [Card(cs.QUEEN, cs.SPADES), Card(cs.JACK, cs.DIAMONDS)]
        self.combinations["PINOCHLE"] = (list_to_dict(pinochle_list), 40, "C")

        double_pinochle_list = pinochle_list + pinochle_list
        self.combinations["DOUBLE_PINOCHLE"] = (
            list_to_dict(double_pinochle_list), 300, "C")
コード例 #20
0
def get_user_card(user_id):
    query = "select * from kart where sahip_id::int={barcode_no}".format(
        barcode_no=int(user_id))
    cursor.execute(query)
    card = cursor.fetchone()
    return Card(card[0], card[1], card[2], card[3])