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


Python GameLevel.by_uuid方法代碼示例

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


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

示例1: buyout

# 需要導入模塊: from models.GameLevel import GameLevel [as 別名]
# 或者: from models.GameLevel.GameLevel import by_uuid [as 別名]
 def buyout(self):
     ''' Buyout and unlock a level '''
     user = self.get_current_user()
     level = GameLevel.by_uuid(self.get_argument('uuid', ''))
     if level is not None and user is not None:
         if level.buyout <= user.team.money:
             logging.info("%s (%s) payed buyout for level #%d" % (
                 user.handle, user.team.name, level.number
             ))
             user.team.game_levels.append(level)
             user.team.money -= level.buyout
             self.dbsession.add(user.team)
             self.dbsession.commit()
             event = self.event_manager.create_unlocked_level_event(user, level)
             self.new_events.append(event)
             self.redirect("/user/missions")
         else:
             self.render("missions/view.html",
                 team=user.team,
                 errors=["You do not have enough money to unlock this level"]
             )
     else:
         self.render("missions/view.html",
             team=user.team,
             errors=["Level does not exist"]
         )
開發者ID:AdaFormacion,項目名稱:RootTheBox,代碼行數:28,代碼來源:MissionsHandler.py

示例2: edit_game_level

# 需要導入模塊: from models.GameLevel import GameLevel [as 別名]
# 或者: from models.GameLevel.GameLevel import by_uuid [as 別名]
 def edit_game_level(self):
     ''' Update game level objects '''
     errors = []
     level = GameLevel.by_uuid(self.get_argument('uuid'))
     try:
         new_number = int(self.get_argument('number', ''))
         new_buyout = int(self.get_argument('buyout', ''))
         if level.number != new_number and GameLevel.by_number(new_number) is None:
             level.number = new_number
             self.dbsession.add(level)
             # Fix the linked-list
             game_levels = sorted(GameLevel.all())
             index = 0
             for game_level in game_levels[:-1]:
                 game_level.next_level_id = game_levels[index + 1].id
                 self.dbsession.add(game_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])
         if GameLevel.by_number(new_number) is not None:
             errors.append("GameLevel number is not unique")
         if level.buyout != new_buyout:
             level.buyout = new_buyout
             self.dbsession.add(level)
         self.dbsession.commit()
     except ValueError:
         errors.append("That was not a number ...")
     self.render("admin/view/game_levels.html", errors=errors)
開發者ID:AdaFormacion,項目名稱:RootTheBox,代碼行數:32,代碼來源:AdminHandlers.py

示例3: edit_game_level

# 需要導入模塊: from models.GameLevel import GameLevel [as 別名]
# 或者: from models.GameLevel.GameLevel import by_uuid [as 別名]
 def edit_game_level(self):
     ''' Update game level objects '''
     try:
         level = GameLevel.by_uuid(self.get_argument('uuid', ''))
         if level is None:
             raise ValidationError("Game level does not exist")
         if int(self.get_argument('number', level.number)) != level.number:
             level.number = self.get_argument('number')
         level.buyout = self.get_argument('buyout', '1')
         self.dbsession.add(level)
         self.dbsession.flush()
         # Fix the linked-list
         game_levels = sorted(GameLevel.all())
         for index, game_level in enumerate(game_levels[:-1]):
             game_level.next_level_id = game_levels[index + 1].id
             self.dbsession.add(game_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.add(level)
         self.dbsession.commit()
         self.redirect('/admin/view/game_levels')
     except ValueError:
         raise ValidationError("That was not a number ...")
     except ValidationError as error:
         self.render("admin/view/game_levels.html", errors=[str(error), ])
開發者ID:jinghli,項目名稱:RootTheBox,代碼行數:30,代碼來源:AdminGameObjectHandlers.py

示例4: box_level

# 需要導入模塊: from models.GameLevel import GameLevel [as 別名]
# 或者: from models.GameLevel.GameLevel import by_uuid [as 別名]
 def box_level(self):
     ''' Changes a boxs level '''
     errors = []
     box = Box.by_uuid(self.get_argument('box_uuid'))
     level = GameLevel.by_uuid(self.get_argument('level_uuid'))
     if box is not None and level is not None:
         box.game_level_id = level.id
         self.dbsession.add(box)
         self.dbsession.commit()
     elif box is None:
         errors.append("Box does not exist")
     elif level is None:
         errors.append("GameLevel does not exist")
     self.render("admin/view/game_levels.html", errors=errors)
開發者ID:AdaFormacion,項目名稱:RootTheBox,代碼行數:16,代碼來源:AdminHandlers.py

示例5: del_game_level

# 需要導入模塊: from models.GameLevel import GameLevel [as 別名]
# 或者: from models.GameLevel.GameLevel import by_uuid [as 別名]
 def del_game_level(self):
     ''' Deletes a game level, and fixes the linked list '''
     game_level = GameLevel.by_uuid(self.get_argument('uuid', ''))
     if game_level is not None:
         game_levels = sorted(GameLevel.all())
         game_levels.remove(game_level)
         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.delete(game_level)
         self.dbsession.commit()
         self.redirect('/admin/view/game_levels')
     else:
         self.render('admin/view/game_levels.html',
                     errors=["Game level does not exist in database."]
                     )
開發者ID:moloch--,項目名稱:RootTheBox,代碼行數:23,代碼來源:AdminGameObjectHandlers.py


注:本文中的models.GameLevel.GameLevel.by_uuid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。