本文整理汇总了Python中models.GameLevel.GameLevel._reward方法的典型用法代码示例。如果您正苦于以下问题:Python GameLevel._reward方法的具体用法?Python GameLevel._reward怎么用?Python GameLevel._reward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.GameLevel.GameLevel
的用法示例。
在下文中一共展示了GameLevel._reward方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_game_level
# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import _reward [as 别名]
def create_game_level(self):
'''
Creates a new level in the database, the levels are basically a
linked-list where each level points to the next, and the last points to
None. This function creates a new level and sorts everything based on
the 'number' attrib
'''
try:
new_level = GameLevel()
new_level.number = self.get_argument('level_number', '')
new_level.buyout = self.get_argument('buyout', 0)
new_level.name = self.get_argument('name', None)
new_level._type = self.get_argument('type', 'buyout')
new_level._reward = self.get_argument('reward', 0)
if new_level._type == "progress":
new_level.buyout = min(new_level.buyout, 100)
elif new_level._type == "none":
new_level.buyout = 0
if new_level._type != "none" and new_level.buyout == 0:
new_level._type = "none"
self.dbsession.add(new_level)
self.dbsession.flush()
game_levels = sorted(GameLevel.all())
for index, level in enumerate(game_levels[:-1]):
level.next_level_id = game_levels[index + 1].id
self.dbsession.add(level)
if game_levels[0].number != 0:
game_levels[0].number = 0
self.dbsession.add(game_levels[0])
game_levels[-1].next_level_id = None
self.dbsession.add(game_levels[-1])
self.dbsession.commit()
self.redirect('/admin/view/game_levels')
except ValidationError as error:
self.render('admin/create/game_level.html', errors=[str(error), ])