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


Python GameLevel.by_id方法代码示例

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


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

示例1: success_capture

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import by_id [as 别名]
    def success_capture(self, flag, old_reward=None):
        if self.config.teams:
            teamval = "team's "
        else:
            teamval = ""
        user = self.get_current_user()
        old_reward = flag.value if old_reward is None else old_reward
        reward_dialog = flag.name + " answered correctly. "
        if self.config.banking:
            reward_dialog += "$" + str(old_reward) + " has been added to your " + teamval + "account."
        else:
            reward_dialog += str(old_reward) + " points added to your " + teamval + "score."
        success = [reward_dialog]

        # Check for Box Completion
        boxcomplete = True
        box = flag.box
        for boxflag in box.flags:
            if not boxflag in user.team.flags:
                boxcomplete = False
                break
        if boxcomplete:
            success.append("Congratulations! You have completed " + box.name + ".")

        # Check for Level Completion
        level = GameLevel.by_id(box.game_level_id)
        level_progress = len(user.team.level_flags(level.number)) /  float(len(level.flags))
        if level_progress == 1.0 and level not in user.team.game_levels:
            reward_dialog = ""
            if level._reward > 0:
                user.team.money += level._reward
                self.dbsession.add(user.team)
                self.dbsession.flush()
                self.dbsession.commit()
                if self.config.banking:
                    reward_dialog += "$" + str(level._reward) + " has been added to your " + teamval + "account."
                else:
                    reward_dialog += str(level._reward) + " points added to your " + teamval + "score."
            success.append("Congratulations! You have completed " + str(level.name) + ". " + reward_dialog)

        # Unlock next level if based on Game Progress
        next_level = GameLevel.by_id(level.next_level_id)
        if next_level and next_level._type == "progress" and level_progress * 100 >= next_level.buyout and next_level not in user.team.game_levels:
            logging.info("%s (%s) unlocked %s" % (
                    user.handle, user.team.name, next_level.name
                ))
            user.team.game_levels.append(next_level)
            self.dbsession.add(user.team)
            self.dbsession.commit()
            self.event_manager.level_unlocked(user, next_level)
            success.append("Congratulations! You have unlocked " + str(next_level.name))
        
        return success
开发者ID:moloch--,项目名称:RootTheBox,代码行数:55,代码来源:MissionsHandler.py

示例2: to_dict

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import by_id [as 别名]
 def to_dict(self):
     ''' Returns editable data as a dictionary '''
     corp = Corporation.by_id(self.corporation_id)
     game_level = GameLevel.by_id(self.game_level_id)
     return {
         'name': self.name,
         'uuid': self.uuid,
         'corporation': corp.uuid,
         'description': self._description,
         'difficulty': self.difficulty,
         'game_level': game_level.uuid,
     }
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:14,代码来源:Box.py

示例3: to_dict

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import by_id [as 别名]
 def to_dict(self):
     ''' Returns editable data as a dictionary '''
     corp = Corporation.by_id(self.corporation_id)
     game_level = GameLevel.by_id(self.game_level_id)
     cat = Category.by_id(self.category_id)
     if cat:
         category = cat.uuid
     else:
         category = ""
     return {
         'name': self.name,
         'uuid': self.uuid,
         'corporation': corp.uuid,
         'category': category,
         'operating_system': self.operating_system,
         'description': self._description,
         'difficulty': self.difficulty,
         'game_level': game_level.uuid,
         'flag_submission_type': self.flag_submission_type,
         'flaglist': self.flaglist(self.id)
     }
开发者ID:moloch--,项目名称:RootTheBox,代码行数:23,代码来源:Box.py

示例4: game_level

# 需要导入模块: from models.GameLevel import GameLevel [as 别名]
# 或者: from models.GameLevel.GameLevel import by_id [as 别名]
 def game_level(self):
     return GameLevel.by_id(self.game_level_id)
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:4,代码来源:Box.py


注:本文中的models.GameLevel.GameLevel.by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。