当前位置: 首页>>代码示例>>Python>>正文


Python GameLevel.buyout方法代码示例

本文整理汇总了Python中models.GameLevel.GameLevel.buyout方法的典型用法代码示例。如果您正苦于以下问题:Python GameLevel.buyout方法的具体用法?Python GameLevel.buyout怎么用?Python GameLevel.buyout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.GameLevel.GameLevel的用法示例。


在下文中一共展示了GameLevel.buyout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_game_level

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import buyout [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), ])
开发者ID:moloch--,项目名称:RootTheBox,代码行数:37,代码来源:AdminGameObjectHandlers.py

示例2: _make_level

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import buyout [as 别名]
 def _make_level(self, level_number):
     '''
     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
     '''
     new_level = GameLevel()
     new_level.number = level_number
     new_level.buyout = self.get_argument('buyout', '')
     game_levels = GameLevel.all()
     game_levels.append(new_level)
     game_levels = sorted(game_levels)
     index = 0
     for level in game_levels[:-1]:
         level.next_level_id = game_levels[index + 1].id
         self.dbsession.add(level)
         index += 1
     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()
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:25,代码来源:AdminHandlers.py


注:本文中的models.GameLevel.GameLevel.buyout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。