當前位置: 首頁>>代碼示例>>Python>>正文


Python GameLevel.number方法代碼示例

本文整理匯總了Python中models.GameLevel.GameLevel.number方法的典型用法代碼示例。如果您正苦於以下問題:Python GameLevel.number方法的具體用法?Python GameLevel.number怎麽用?Python GameLevel.number使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.GameLevel.GameLevel的用法示例。


在下文中一共展示了GameLevel.number方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_game_level

# 需要導入模塊: from models.GameLevel import GameLevel [as 別名]
# 或者: from models.GameLevel.GameLevel import number [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 number [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.number方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。