當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。