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


Python GameLevel.all方法代码示例

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


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

示例1: create_game_level

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [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: edit_game_level

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [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: create_team

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [as 别名]
    def create_team(self):
        ''' Admins can create teams manually '''
        try:
            name = self.get_argument('team_name', '')
            if Team.by_name(name) is not None:
                raise ValidationError("Team already exists")
            team = Team()
            team.name = self.get_argument('team_name', '')
            team.motto = self.get_argument('motto', '')
            if not self.config.banking:
                team.money = 0
            level_0 = GameLevel.by_number(0)
            if not level_0:
                level_0 = GameLevel.all()[0]
            team.game_levels.append(level_0)
            self.dbsession.add(team)
            self.dbsession.commit()

            # Avatar
            avatar_select = self.get_argument('team_avatar_select', '')
            if avatar_select and len(avatar_select) > 0:
                team._avatar = avatar_select
            elif hasattr(self.request, 'files') and 'avatar' in self.request.files:
                team.avatar = self.request.files['avatar'][0]['body']
            self.dbsession.add(team)
            self.dbsession.commit()
            self.redirect('/admin/users')
        except ValidationError as error:
            self.render("admin/create/team.html", errors=[str(error), ])
开发者ID:moloch--,项目名称:RootTheBox,代码行数:31,代码来源:AdminGameObjectHandlers.py

示例4: edit_game_level

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [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

示例5: create_team

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [as 别名]
 def create_team(self):
     ''' Create a new team in the database '''
     team = Team()
     team.name = self.get_argument('team_name', '')
     team.motto = self.get_argument('motto', '')
     level_0 = GameLevel.all()[0]
     team.game_levels.append(level_0)
     self.dbsession.add(team)
     self.dbsession.commit()
     self.redirect('/admin/view/user_objects')
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:12,代码来源:AdminHandlers.py

示例6: create_team

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [as 别名]
 def create_team(self):
     ''' Create a new team '''
     if self.config.public_teams:
         team = Team()
         team.name = self.get_argument('team_name', '')
         team.motto = self.get_argument('motto', '')
         level_0 = GameLevel.all()[0]
         team.game_levels.append(level_0)
         return team
     else:
         raise ValidationError("Public teams are not enabled")
开发者ID:WeiEast,项目名称:RootTheBox,代码行数:13,代码来源:PublicHandlers.py

示例7: create_box

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [as 别名]
def create_box(corp=None):
    if corp is None:
        corp = create_corp()
    game_level = GameLevel.all()[0]
    box = Box(corporation_id=corp.id, game_level_id=game_level.id)
    box.name = "TestBox"
    box.description = "Some description"
    box.difficuly = "Easy"
    corp.boxes.append(box)
    dbsession.add(box)
    dbsession.commit()
    return box, corp
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:14,代码来源:Helpers.py

示例8: create_team

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [as 别名]
 def create_team(self):
     ''' Create a new team '''
     if not self.config.teams:
         team = Team.by_name(self.get_argument('handle', ''))
         if team is None:
             team = Team()
             team.name = self.get_argument('handle', '')
         else:
             logging.info("Team %s already exists - Player Mode: reset team." % team.name)
             team.flags = []
             team.hints = []
             team.boxes = []
             team.items = []
             team.game_levels = []
             team.purchased_source_code = []
         team.motto = self.get_argument('motto', '')
         if self.config.banking:
             team.money = self.config.starting_team_money
         else:
             team.money = 0
         level_0 = GameLevel.by_number(0)
         if not level_0:
             level_0 = GameLevel.all()[0]
         team.game_levels.append(level_0)
         return team
     elif self.config.public_teams:
         if Team.by_name(self.get_argument('team_name', '')) is not None:
             raise ValidationError("This team name is already registered.  Use team code to join that team.")
         team = Team()
         team.name = self.get_argument('team_name', '')
         team.motto = self.get_argument('motto', '')
         if not self.config.banking:
             team.money = 0
         level_0 = GameLevel.by_number(0)
         if not level_0:
             level_0 = GameLevel.all()[0]
         team.game_levels.append(level_0)
         return team
     else:
         raise ValidationError("Public teams are not enabled")
开发者ID:moloch--,项目名称:RootTheBox,代码行数:42,代码来源:PublicHandlers.py

示例9: export_game_objects

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [as 别名]
 def export_game_objects(self, root):
     '''
     Exports the game objects to an XML doc.
     For the record, I hate XML with a passion.
     '''
     levels_elem = ET.SubElement(root, "gamelevels")
     levels_elem.set("count", str(GameLevel.count()))
     for level in GameLevel.all()[1:]:
         level.to_xml(levels_elem)
     corps_elem = ET.SubElement(root, "corporations")
     corps_elem.set("count", str(Corporation.count()))
     for corp in Corporation.all():
         corp.to_xml(corps_elem)
开发者ID:jinghli,项目名称:RootTheBox,代码行数:15,代码来源:AdminGameHandlers.py

示例10: create_team

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [as 别名]
 def create_team(self):
     ''' Admins can create teams manually '''
     try:
         name = self.get_argument('team_name', '')
         motto = self.get_argument('motto', '')
         if Team.by_name(name) is not None:
             raise ValidationError("Team already exists")
         team = Team()
         team.name = self.get_argument('team_name', '')
         team.motto = self.get_argument('motto', '')
         level_0 = GameLevel.all()[0]
         self.dbsession.add(team)
         self.dbsession.commit()
         self.redirect('/admin/users')
     except ValidationError as error:
         self.render("admin/create/team.html", errors=[str(error), ])
开发者ID:AnarKyx01,项目名称:RootTheBox,代码行数:18,代码来源:AdminGameObjectHandlers.py

示例11: del_game_level

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [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

示例12: _make_level

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import all [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.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。