当前位置: 首页>>代码示例>>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;未经允许,请勿转载。