本文整理汇总了Python中models.Player.bank方法的典型用法代码示例。如果您正苦于以下问题:Python Player.bank方法的具体用法?Python Player.bank怎么用?Python Player.bank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Player
的用法示例。
在下文中一共展示了Player.bank方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_blackjack_payout
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import bank [as 别名]
def test_blackjack_payout(self):
player = Player('cory','password')
game = Game('Blackjack')
hand = Hand()
game.players = []
player.bank = 100
player.hands = [hand]
hand.bet = 0
game.deck = Hand()
game.dealer = Player('cory','password')
game.dealer.hands.append(Hand())
game.hands.append(game.dealer.hands[0])
player.hands.append(hand)
game.hands.append(hand)
game.deck.cards = piece_maker(suits, card_values, 1)
game.players.append(player)
cards_app.session.flush()
# testing player AND dealer get blackjack
hand.cards = [Card(sequence=1), Card(sequence=10)]
game.dealer.hands[0].cards = [Card(sequence=1), Card(sequence=10)]
bet(hand, 50)
count_blackjack(hand)
blackjack_dealer(game)
assert player.bank == 100
# Player gets 15 and dealer gets 15, dealer hits and breaks because deck is unshuffled and king on top
player.bank = 100
hand.cards = [Card(sequence=10), Card(sequence=5)]
game.dealer.hands[0].cards = [Card(sequence=10), Card(sequence=5)]
bet(hand, 50)
hand.is_expired = False
count_blackjack(hand)
blackjack_dealer(game)
assert player.bank == 150
# player gets blackjack, dealer doesn't
hand.is_expired = False
hand.bet = 0
player.bank = 100
hand.cards = [Card(sequence=10), Card(sequence=1)]
game.dealer.hands[0].cards = [Card(sequence=10), Card(sequence=10)]
bet(hand, 50)
count_blackjack(hand)
blackjack_dealer(game)
assert player.bank == 175
# player broke, loses bet
hand.is_expired = False
hand.bet = 0
player.bank = 100
hand.cards = [Card(sequence=10), Card(sequence=10), Card(sequence=10)]
game.dealer.hands[0].cards = [Card(sequence=10), Card(sequence=10)]
bet(hand, 50)
count_blackjack(hand)
blackjack_dealer(game)
blackjack_payout(game)
assert player.bank == 50
示例2: test_blackjack_player_wins
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import bank [as 别名]
def test_blackjack_player_wins(self):
player = Player('cory','password')
game = Game('Blackjack')
hand = Hand()
player.bank = 100
player.hands.append(hand)
game.hands.append(hand)
game.players.append(player)
bank_before_bet = player.bank
# cards_app.session.commit()
cards_app.session.flush()
bet(hand, 50)
cards = [Card(sequence=1), Card(sequence=10)]
hand.cards.extend(cards)
count_blackjack(hand)
evaluate_hit(hand)
# player wins with nautral evaluate_hit
assert player.bank == bank_before_bet - 50
# player stands on 18, dealer stands on 17
hand.cards = [Card(sequence=10), Card(sequence=8)]
bet(hand, 50)
game.dealer = Player('cory','password')
dealer = game.dealer
dealer.cards = [Card(sequence=10), Card(sequence=17)]
dealer_hand = Hand()
dealer_hand.cards = dealer.cards
示例3: test_blackjack_dealer
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import bank [as 别名]
def test_blackjack_dealer(self):
player = Player('cory','password')
game = Game('Blackjack')
hand = Hand()
game.players = []
player.bank = 100
game.deck = Hand()
game.dealer = Player('cory','password')
game.dealer.hands.append(Hand())
game.hands.append(game.dealer.hands[0])
player.hands.append(hand)
game.hands.append(hand)
game.deck.cards = piece_maker(suits, card_values, 1)
game.players.append(player)
cards_app.session.flush()
player.hands[0].cards = [Card(sequence=10), Card(sequence=8)]
game.dealer.hands[0].cards = [Card(sequence=6), Card(sequence=1)]
bet(player.hands[0], 50)
count_blackjack(player.hands[0])
blackjack_dealer(game)
blackjack_payout(game)
# blackjack dealer should break after hitting on he soft 17
assert player.bank == 150