本文整理汇总了Python中models.Game.players方法的典型用法代码示例。如果您正苦于以下问题:Python Game.players方法的具体用法?Python Game.players怎么用?Python Game.players使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Game
的用法示例。
在下文中一共展示了Game.players方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGameCreation
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import players [as 别名]
def testGameCreation(self):
football = Game()
football.title = "The Big football game"
football.description = "Blah Blah Blah"
football.players = self.players[1]
football.save()
for player in self.players[1:]:
football.players = player
football.save()
示例2: create_new_game
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import players [as 别名]
def create_new_game(players, name):
import uuid
from models import Game
from constants import default_counter
from constants import win_types
game = Game()
game.game_name = name
game.game_id = str(uuid.uuid1())
game.players = players
game.current_player = random.randint(0, len(players) - 1)
game.data = json.dumps(create_world_data())
game.move_counter = default_counter
game.major_arcana = []
arcana = get_major_arcana()
for i in range(len(players)):
num = random.randint(0, len(arcana) - 1)
game.major_arcana.append(arcana[num])
del arcana[num]
goals = get_goals()
game.goals = []
for i in game.major_arcana:
for goal in win_types[i]:
num = random.randint(0, len(goals[goal]) - 1)
game.goals.append(goals[goal][num])
del goals[goal][num]
game.put()
示例3: test_blackjack_payout
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import players [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
示例4: post
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import players [as 别名]
def post(self):
logging.debug("CreateGame: ")
user = auth()
if user == None:
logging.debug("CreateGame: Entered unauthenticated user!!")
self.response.out.write(json.dumps({'error': 'Unauthenticated User'}))
return
#sendMessage(user, "HELLO");
logging.debug("CreateGame: Before creating Game Object")
#Create Game
game = Game()
game.name = self.request.get("name")
game.players = []
game.messages = []
game.creator = user.key().id()
game.location = user.location
game.range = float(self.request.get('range'))
game.startTime = datetime.datetime.now()
logging.debug("CreateGame: Before creating Clue Object")
clue = MyMessage()
clue.text = self.request.get('clue')
clue.time = datetime.datetime.now()
clue.put()
logging.debug("CreateGame: Clue Object Created")
game.clue = clue.key().id()
game.active = True
game.put()
logging.debug("Game object created")
clue.gameid = game.key().id()
clue.user = user
clue.put()
user.activeGame = game
user.put()
#Notify users in the location
#Return Game ID to UI
logging.debug(game.key().id())
self.response.out.write(json.dumps({'gameid': game.key().id()}))
示例5: test_blackjack_dealer
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import players [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