Example #1
0
def checkSkillUpgrade(userId):
    """
    检查技能能否升级升星
    """
    upSkills = []
    for skillId in config.getAllSkillId():
        skillId = int(skillId)
        if not config.getSkillStarConf(skillId, 1, config.MULTIPLE_MODE):
            continue
        code, skill = checkSkillStatus(userId, skillId)
        if code != 0:
            continue
        if skill[INDEX_ORIGINAL_LEVEL] < MAX_ORIGINAL_LEVEL:
            skillGradeConf = config.getSkillGradeCommonConf(
                skillId, skill[INDEX_ORIGINAL_LEVEL] + 1)
            if checkUpgradeSkillItemCount(userId, skillGradeConf["consume"]):
                upSkills.append(skillId)
        if skill[INDEX_STAR_LEVEL] > 0 and skill[
                INDEX_STAR_LEVEL] < MAX_STAR_LEVEL:
            skillStarConf = config.getSkillStarCommonConf(
                skillId, skill[INDEX_STAR_LEVEL] + 1)
            if checkUpgradeSkillItemCount(userId, skillStarConf["consume"]):
                upSkills.append(skillId)
        bireport.reportGameEvent(
            "BI_NFISH_GE_SKILL_UPGRADE", userId, FISH_GAMEID, 0, 0, skillId, 0,
            0, 0, [skill[INDEX_STAR_LEVEL], skill[INDEX_ORIGINAL_LEVEL]],
            util.getClientId(userId))
    module_tip.resetModuleTip(userId, "upskill")
    if upSkills:
        module_tip.addModuleTipEvent(userId, "upskill", upSkills)
    else:
        module_tip.resetModuleTipEvent(userId, "upskill")
Example #2
0
def updateSkill(userId, skillId):
    """
    更新新增技能数据
    """
    assert str(skillId) in config.getAllSkillId()
    daobase.executeUserCmd(userId, "HSETNX", _getUserSkillKey(userId),
                           str(skillId), json.dumps(DEFAULT_VALUE))
Example #3
0
def setSkill(userId, skillId, skillInfo):
    """
    存储单个技能数据
    """
    assert str(skillId) in config.getAllSkillId()
    assert isinstance(skillInfo, list) and len(skillInfo) == len(DEFAULT_VALUE)
    daobase.executeUserCmd(userId, "HSET", _getUserSkillKey(userId),
                           str(skillId), json.dumps(skillInfo))
Example #4
0
def _main():
    gunLevel = gunLevel_m = 2100 + level
    gunLevel = min(gunLevel, config.getMaxGunLevel(0))
    gunLevel_m = min(gunLevel_m, config.getMaxGunLevel(1))
    userGuideStep = json.dumps(config.getPublic("allGuideIds", []))
    gamedata.setGameAttrs(userId, 44, ["level", "exp", "gunLevel", "gunLevel_m", "userGuideStep", "redState"],
                          [level, exp, gunLevel, gunLevel_m, userGuideStep, 1])
    for skillId in config.getAllSkillId():
        skillInfo = [5, 20, 20, 0, 0]
        skill_system.setSkill(userId, skillId, skillInfo)
Example #5
0
def checkSkillStatus(userId, skillId):
    """
    检查技能状态
    """
    skill = None
    if str(skillId) not in config.getAllSkillId():
        ftlog.error("checkSkillStatus-> not skillId", userId, skillId)
        return 1, skill
    skill = getSkill(userId, skillId)
    if not skill:
        setSkill(userId, skillId, deepcopy(DEFAULT_VALUE))
        ftlog.error("checkSkillStatus-> not skillInfo", userId, skillId)
        return 2, skill
    if skill[INDEX_STAR_LEVEL] < 0 or \
       skill[INDEX_STAR_LEVEL] > MAX_STAR_LEVEL or \
       skill[INDEX_ORIGINAL_LEVEL] < 0 or \
       skill[INDEX_ORIGINAL_LEVEL] > MAX_ORIGINAL_LEVEL:
        ftlog.warn("checkSkillStatus-> skillLevel error", userId, skillId)
        return 3, skill
    return 0, skill
Example #6
0
def _getAllSkills(userId):
    """
    获得所有技能数据
    """
    assert isinstance(userId, int) and userId > 0
    value = daobase.executeUserCmd(userId, "HGETALL", _getUserSkillKey(userId))
    if value:
        skillIds = value[0::2]
        infos = [
            strutil.loads(info, False, True) for info in value[1::2] if info
        ]
        skillDict = dict(zip(skillIds, infos))
        allSkillIdsConf = config.getAllSkillId()
        popSkillIds = [
            skillId for skillId in skillIds
            if str(skillId) not in allSkillIdsConf
        ]
        for _skillId in popSkillIds:
            del skillDict[_skillId]
        return skillDict
    return {}
Example #7
0
def doSkillCompensate(userId):
    """
    卸载技能,取消要卸载技能的小红点,并补偿金币
    """
    allSkillIds = config.getAllSkillId()
    installSkillIds = getInstalledSkill(userId, config.CLASSIC_MODE).keys()
    moduleTipSkillIds = module_tip.getTipValue(
        userId, module_tip.findModuleTip("upskill"))
    if installSkillIds:  # 卸载已经装备且要下线的技能
        for _skillId in installSkillIds:
            if str(_skillId) not in allSkillIds:
                code = installSkill(userId, _skillId, config.CLASSIC_MODE, 0)
                if code != 0:
                    ftlog.error("compensateSkill---> unstallSkill fail",
                                userId, _skillId, code)
    compenSkillIds = config.getSkillCompenConf("skillList")
    if compenSkillIds:  # 补偿要下线的技能,并去掉该技能的小红点
        for skillId in compenSkillIds:
            skillCompensate(userId, skillId)
            if skillId in moduleTipSkillIds:
                module_tip.cancelModuleTipEvent(userId, "upskill", skillId)
Example #8
0
def initSkill(userId):
    """
    初始化技能数据
    """
    for skillId in config.getAllSkillId():
        updateSkill(userId, skillId)