Ejemplo n.º 1
0
 def test_payout_bonus_scenario_any_natural(self):
     calculator = Lucky9PayoutCalculator()
     dealer_up_card = Lucky9Card('spade', 10)
     player_cards = [Lucky9Card('club', 3), Lucky9Card('diamond', 6)]
     winning = calculator.calculate_bonus_winning(dealer_up_card,
                                                  player_cards)
     self.assertEqual(5, winning)
Ejemplo n.º 2
0
 def test_payout_bonus_scenario_suited_2_3_4(self):
     calculator = Lucky9PayoutCalculator()
     dealer_up_card = Lucky9Card('spade', 3)
     player_cards = [Lucky9Card('spade', 2), Lucky9Card('spade', 4)]
     winning = calculator.calculate_bonus_winning(dealer_up_card,
                                                  player_cards)
     self.assertEqual(100, winning)
Ejemplo n.º 3
0
    def test_is_lucky9(self):
        card1 = Lucky9Card('spade', 1)
        card2 = Lucky9Card('spade', 7)
        card3 = Lucky9Card('spade', 1)

        cards_in_hand = [card1, card2, card3]
        self.assertTrue(Lucky9Game.is_lucky9(cards_in_hand))
Ejemplo n.º 4
0
 def test_payout_bonus_lose(self):
     calculator = Lucky9PayoutCalculator()
     dealer_up_card = Lucky9Card('spade', 2)
     player_cards = [Lucky9Card('spade', 3), Lucky9Card('club', 7)]
     winning = calculator.calculate_bonus_winning(dealer_up_card,
                                                  player_cards)
     self.assertEqual(0, winning)
Ejemplo n.º 5
0
    def test_is_not_lucky9_10(self):
        card1 = Lucky9Card('spade', 3)
        card2 = Lucky9Card('spade', 7)
        card3 = Lucky9Card('spade', 10)

        cards_in_hand = [card1, card2, card3]
        self.assertFalse(Lucky9Game.is_lucky9(cards_in_hand))
Ejemplo n.º 6
0
 def test_payout_bonus_scenario_suited_9(self):
     calculator = Lucky9PayoutCalculator()
     dealer_up_card = Lucky9Card('club', 1)
     player_cards = [Lucky9Card('club', 2), Lucky9Card('club', 6)]
     winning = calculator.calculate_bonus_winning(dealer_up_card,
                                                  player_cards)
     self.assertEqual(30, winning)
Ejemplo n.º 7
0
 def test_card_value(self):
     for suit in valid_suits:
         cardc1 = Lucky9Card(suit, 1)
         cardc2 = Lucky9Card(suit, 9)
         cardc3 = Lucky9Card(suit, 10)
         cardc4 = Lucky9Card(suit, 13)
         self.assertEqual(1, cardc1.card_value())
         self.assertEqual(9, cardc2.card_value())
         self.assertEqual(10, cardc3.card_value())
         self.assertEqual(10, cardc4.card_value())
Ejemplo n.º 8
0
 def test_payout_bet_dealer_not_enough_cards(self):
     calculator = Lucky9PayoutCalculator()
     dealer_cards = [Lucky9Card('spade', 2)]
     player_cards = [
         Lucky9Card('spade', 1),
         Lucky9Card('spade', 3),
         Lucky9Card('spade', 4)
     ]
     self.assertRaises(ValueError, calculator.calculate_bet_winning,
                       dealer_cards, player_cards)
Ejemplo n.º 9
0
    def test_lucky9_dealer(self):
        dealer = Lucky9Dealer()
        dealer.add_card(Lucky9Card('spade', 1))
        self.assertIsNotNone(dealer.down_card)

        dealer.add_card(Lucky9Card('spade', 2))
        self.assertIsNotNone(dealer.up_card)

        dealer.add_card(Lucky9Card('spade', 4))

        self.assertRaises(ValueError, dealer.add_card, Lucky9Card('spade', 3))
Ejemplo n.º 10
0
 def test_payout_tie_scenario_win(self):
     calculator = Lucky9PayoutCalculator()
     dealer_cards = [
         Lucky9Card('spade', 1),
         Lucky9Card('spade', 2),
         Lucky9Card('spade', 3)
     ]
     player_cards = [
         Lucky9Card('club', 6),
         Lucky9Card('diamond', 6),
         Lucky9Card('spade', 4)
     ]
     winning = calculator.calculate_tie_winning(dealer_cards, player_cards)
     self.assertEqual(7, winning)
Ejemplo n.º 11
0
 def test_payout_bet_dealer_more_than_player(self):
     calculator = Lucky9PayoutCalculator()
     dealer_cards = [
         Lucky9Card('spade', 2),
         Lucky9Card('club', 3),
         Lucky9Card('spade', 4)
     ]
     player_cards = [
         Lucky9Card('club', 1),
         Lucky9Card('diamond', 2),
         Lucky9Card('club', 3)
     ]
     winning = calculator.calculate_bet_winning(dealer_cards, player_cards)
     self.assertEqual(0, winning)
Ejemplo n.º 12
0
 def test_payout_bet_dealer_total_9_player_lucky_9(self):
     calculator = Lucky9PayoutCalculator()
     dealer_cards = [
         Lucky9Card('club', 10),
         Lucky9Card('diamond', 7),
         Lucky9Card('club', 2)
     ]
     player_cards = [
         Lucky9Card('spade', 2),
         Lucky9Card('club', 3),
         Lucky9Card('spade', 4)
     ]
     winning = calculator.calculate_bet_winning(dealer_cards, player_cards)
     self.assertEqual(1.5, winning)
Ejemplo n.º 13
0
 def test_payout_bet_player_wins_natural_9_dealer_not_9(self):
     calculator = Lucky9PayoutCalculator()
     dealer_cards = [
         Lucky9Card('club', 1),
         Lucky9Card('diamond', 2),
         Lucky9Card('club', 3)
     ]
     player_cards = [
         Lucky9Card('spade', 10),
         Lucky9Card('club', 3),
         Lucky9Card('spade', 5)
     ]
     winning = calculator.calculate_bet_winning(dealer_cards, player_cards)
     self.assertEqual(1.5, winning)
Ejemplo n.º 14
0
    def test_is_tie_with_dealer(self):
        game = Lucky9Game(MockShuffle())
        player_card1 = Lucky9Card('spade', 2)
        player_card2 = Lucky9Card('spade', 7)
        player_card3 = Lucky9Card('spade', 10)

        dealer_card1 = Lucky9Card('spade', 2)
        dealer_card2 = Lucky9Card('spade', 7)
        dealer_card3 = Lucky9Card('spade', 10)

        player_cards_in_hand = [player_card2, player_card1, player_card3]
        dealer_cards_in_hand = [dealer_card1, dealer_card3, dealer_card2]

        game.dealer.cards_in_hand = dealer_cards_in_hand

        self.assertTrue(game.is_tie_with_dealer(player_cards_in_hand))
Ejemplo n.º 15
0
    def test_card_factory_lucky9(self):
        lucky9_card = CardFactory.factory('lucky9', 'spade', 1)
        expected = Lucky9Card('spade', 1)

        self.assertEqual(expected.suit, lucky9_card.suit)
        self.assertEqual(expected.value, lucky9_card.value)
Ejemplo n.º 16
0
 def test_to_string(self):
     card = Lucky9Card('spade', 1)
     self.assertEqual("{ suit: spade, value: 1 }", str(card))
Ejemplo n.º 17
0
    def test_pick_card_lower_boundary(self):
        dealer = Lucky9Dealer()
        dealer.up_card = Lucky9Card('spade', 4)

        self.assertTrue(dealer.handle_move())
Ejemplo n.º 18
0
    def test_pick_card_upper_boundary(self):
        dealer = Lucky9Dealer()
        dealer.up_card = Lucky9Card('spade', 6)

        self.assertFalse(dealer.handle_move())
Ejemplo n.º 19
0
 def test_payout_bonus_player_not_enough_cards(self):
     calculator = Lucky9PayoutCalculator()
     dealer_up_card = Lucky9Card('spade', 1)
     player_cards = [Lucky9Card('spade', 2)]
     self.assertRaises(ValueError, calculator.calculate_bonus_winning,
                       dealer_up_card, player_cards)
Ejemplo n.º 20
0
 def test_payout_bonus_dealer_no_cards(self):
     calculator = Lucky9PayoutCalculator()
     dealer_up_card = None
     player_cards = [Lucky9Card('spade', 3), Lucky9Card('spade', 3)]
     self.assertRaises(ValueError, calculator.calculate_bonus_winning,
                       dealer_up_card, player_cards)