本文整理汇总了Python中games.models.Game.percentage方法的典型用法代码示例。如果您正苦于以下问题:Python Game.percentage方法的具体用法?Python Game.percentage怎么用?Python Game.percentage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类games.models.Game
的用法示例。
在下文中一共展示了Game.percentage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_games
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import percentage [as 别名]
def _create_games(self, n=1):
if Color.objects.count() < Game.AVAILABLE_COLORS:
print "Impossible to create games. No enough colors."
print "ESCAPING..."
return
print "Populating Games"
for i in range(n):
available_colors = Color.objects.all().order_by('?')[:Game.AVAILABLE_COLORS]
game = Game()
game.initial_amount = random.randint(0, 100)
game.percentage = random.randint(0, 100)
game.payment = random.uniform(0, 5)
game.start_date = timezone.now()
game.end_date = game.start_date + datetime.timedelta(days=random.randint(3, 30))
game.save()
game.available_colors.add(*available_colors)
print "SUCCESS"