Exemplo n.º 1
0
def sendBuyLevelFundsRet(userId, clientId, productId, idx, code, mode):
    """
    返回购买成长基金结果
    """
    message = MsgPack()
    message.setCmd("buyLevelFunds")
    message.setResult("gameId", config.FISH_GAMEID)
    message.setResult("userId", userId)
    message.setResult("productId", productId)
    message.setResult("code", code)
    rewardsState = []
    if code == 0:
        message.setResult("state", 1)
        hasTip, rewardsState = _getLevelFundsRewardState(userId, clientId, idx, mode)
        if hasTip:
            if mode == 1:
                module_tip.addModuleTipEvent(userId, "levelfundsNew", productId)
            else:
                module_tip.addModuleTipEvent(userId, "levelfunds", productId)
        else:
            if mode == 1:
                module_tip.cancelModuleTipEvent(userId, "levelfundsNew", productId)
            else:
                module_tip.cancelModuleTipEvent(userId, "levelfunds", productId)
    message.setResult("rewardsState", rewardsState)
    router.sendToUser(message, userId)
Exemplo n.º 2
0
def getReturnerReward(userId, clientId, taskId):
    """
    领取回归豪礼
    """
    rewards = None
    returnerMission = getReturnerMissionData(userId)
    if returnerMission:
        for taskConf in config.getReturnerMissionConf("tasks"):
            if taskConf["taskId"] == taskId and taskId in returnerMission["tasks"]:
                if returnerMission["tasks"][taskId]["state"] == 2:
                    rewards = buildTaskRewards(taskConf["rewards"], returnerMission["userLevel"], returnerMission["vipExp"])
                    returnerMission["tasks"][taskId]["state"] = 3
                    break
    mo = MsgPack()
    mo.setCmd("returner_reward")
    mo.setResult("gameId", FISH_GAMEID)
    mo.setResult("userId", userId)
    mo.setResult("taskId", taskId)
    mo.setResult("code", 0 if rewards else 1)
    if rewards:
        util.addRewards(userId, rewards, "BI_NFISH_RETURNER_REWARDS", int(taskId))
        gamedata.setGameAttr(userId, FISH_GAMEID, GameData.returnerMission, json.dumps(returnerMission))
        module_tip.cancelModuleTipEvent(userId, "returnerMission", taskId)
        mo.setResult("rewards", rewards)
    router.sendToUser(mo, userId)
Exemplo n.º 3
0
def getDailyQuestReward(userId, star, type="day"):
    """
    领取每日任务星级奖励
    """
    from newfish.entity.chest.chest_system import ChestFromType
    fromType = ChestFromType.Daily_Quest_Week_Chest if type == "week" else \
               ChestFromType.Daily_Quest_Daily_Chest
    reason = 0
    rewards = []
    finishedStar = 0
    key = _getUserDailyQuestWeeklyRewardKey(userId)
    ret = json.loads(weakdata.getWeekFishData(userId, key, "{}"))
    finishedWeekStar = ret.get("star", 0)
    gotRewardStars = _getUserQuestRewardData(userId, type)
    questInfo = getUserQuestInfoData(userId)
    all = len(questInfo) == len(config.getDailyQuestGroupOrder())
    if star in gotRewardStars:
        reason = 1  # 已经领取过奖励
    else:
        todayQuest, activeLv = getTodayQuest(userId)
        for k, v in todayQuest.iteritems():
            progress, state = questInfo.get(str(k), [0, QuestTaskState.Normal])
            if state == QuestTaskState.Received:
                finishedStar += v["taskLevel"]
        starConfig = config.getDailyQuestRewardConf(activeLv, all).get(str(star), {})
        if not starConfig or (type == "day" and finishedStar < star) or (type == "week" and finishedWeekStar < star):
            reason = 2  # 未达到领取条件
        else:
            rewards = starConfig.get("rewards")
            code = 0
            _insertQuestRewarded(userId, star, type)
            for reward in starConfig.get("rewards"):
                kindId = reward["itemId"]
                if util.isChestRewardId(kindId):
                    rewards = chest_system.getChestRewards(userId, kindId)
                    code = chest_system.deliveryChestRewards(userId, kindId, rewards, "DTASK_REWARD", fromType=fromType)
                else:
                    code = util.addRewards(userId, [reward], "DTASK_REWARD")
            if code != 0:
                ftlog.error("newfish->getDailyQuestReward =", userId, "rewards =", rewards)
    mo = MsgPack()
    mo.setCmd("task")
    mo.setResult("gameId", FISH_GAMEID)
    mo.setResult("userId", userId)
    mo.setResult("action", "dailyReward")
    mo.setResult("star", star)
    mo.setResult("type", type)
    mo.setResult("gotReward", gotRewardStars)
    mo.setResult("reason", reason)
    if reason == 0:
        gotRewardStars.append(star)
        mo.setResult("gotReward", gotRewardStars)
        mo.setResult("rewards", rewards)
        # _insertQuestRewarded(userId, star, type)
        module_tip.cancelModuleTipEvent(userId, "task", star)
    router.sendToUser(mo, userId)
    if ftlog.is_debug():
        ftlog.debug("daily_quest, userId =", userId, "star =", star, "type =", type, "mo =", mo)
Exemplo n.º 4
0
def getQuestReward(userId, taskId, rewardflyPos):
    """
    领取每日任务奖励
    """
    code = 1
    reason = 2
    rewards = []
    questInfo = getUserQuestInfoData(userId)
    progress, state = questInfo.get(str(taskId), [0, QuestTaskState.Normal])
    # 未达到领取条件
    if state == QuestTaskState.Normal:
        reason = 2
    # 已经领取过奖励
    elif state == QuestTaskState.Received:
        reason = 1
    elif state == QuestTaskState.Complete:
        reason = 0
        questInfo[str(taskId)] = [progress, QuestTaskState.Received]
        setUserQuestInfoData(userId, questInfo)
        module_tip.cancelModuleTipEvent(userId, "task", taskId)     # -1
        todayQuest, activeLv = getTodayQuest(userId)
        quest = todayQuest.get(taskId, {})
        rewards = _processQuestReward(userId, quest)                # quest.get("rewards", [])
        code = util.addRewards(userId, rewards, "DTASK_REWARD")
        taskLevel = quest.get("taskLevel", 0)
        # 更新周奖励的星级
        finishedWeekStar = _incrDailyQuestWeekStar(userId, taskLevel)
        questData = getDailyQuestData(userId)
        finishedStar = questData.get("finishedStar", 0)
        all = len(questInfo) == len(config.getDailyQuestGroupOrder())
        dailyQuestRewardFinishedStars = config.getDailyQuestRewardFinishedStars("day", all)
        for star in dailyQuestRewardFinishedStars:
            if finishedStar >= star > finishedStar - taskLevel:
                module_tip.addModuleTipEvent(userId, "task", star)
                break
        dailyQuestRewardFinishedWeekStars = config.getDailyQuestRewardFinishedStars("week", all)
        for star in dailyQuestRewardFinishedWeekStars:
            if finishedWeekStar >= star > finishedWeekStar - taskLevel:
                module_tip.addModuleTipEvent(userId, "task", star)
                break
        from newfish.entity.event import DailyTaskRewardEvent
        from newfish.game import TGFish
        event = DailyTaskRewardEvent(userId, FISH_GAMEID, taskId, taskLevel)
        TGFish.getEventBus().publishEvent(event)
    mo = MsgPack()
    mo.setCmd("task")
    mo.setResult("gameId", FISH_GAMEID)
    mo.setResult("userId", userId)
    mo.setResult("action", "questReward")
    mo.setResult("taskId", taskId)
    mo.setResult("rewardflyPos", rewardflyPos)
    mo.setResult("reason", reason)
    if reason == 0:
        mo.setResult("code", code)
        mo.setResult("rewards", rewards)
    router.sendToUser(mo, userId)
Exemplo n.º 5
0
def _dealTips(userId, mailInfos, mailSenderType):
    """
    更新邮箱小红点
    """
    # 兼容处理老玩家数据。
    module_tip.cancelModuleTipEvent(userId, "mail", 0)
    module_tip.cancelModuleTipEvent(userId, "mail", mailSenderType)
    for mailInfo in mailInfos:
        if mailInfo["state"] == MailState.Default:
            module_tip.addModuleTipEvent(userId, "mail", mailSenderType)
            return
Exemplo n.º 6
0
def getQuestRewards(userId, clientId, taskId):
    """
    领取单个主线任务奖励
    """
    mo = MsgPack()
    mo.setCmd("task")
    mo.setResult("gameId", FISH_GAMEID)
    mo.setResult("userId", userId)
    mo.setResult("taskId", taskId)
    mo.setResult("action", "mainReward")
    code = 3
    taskConf = config.getMainQuestTaskConf(clientId, taskId)
    if taskConf:
        state = getTask(userId, taskId)[QuestIndex.State]
        if state == QuestState.Default:
            code = 2
        elif state == QuestState.Received:
            code = 1
        else:
            code = 0
            chestInfo = {}
            rewards = []
            rewards.extend(taskConf["normalRewards"])
            chestRewards = taskConf["chestRewards"]
            if chestRewards:
                chestId = chestRewards[0]["name"]
                chestInfo = chest_system.getChestInfo(chestId)
                _rewards = chest_system.getChestRewards(userId, chestId)
                rewards.extend(_rewards)
            setTask(
                userId, clientId, taskId,
                [QuestState.Received, int(time.time())])  # 领取任务奖励
            util.addRewards(userId, rewards, "BI_NFISH_MAIN_QUEST_REWARDS",
                            int(taskId))
            module_tip.cancelModuleTipEvent(userId, "mainquest", taskId)
            # 检查主线任务增加的星级能否解锁对应星级奖励.
            sectionId = getSectionId(taskId)
            sectionData = getSection(userId, sectionId)
            sectionConf = config.getMainQuestSectionConf(clientId, sectionId)
            totalStar = _getSectionStar(userId, clientId, sectionId)
            for val in sectionConf["starRewards"]:
                if totalStar >= val["star"] and val["star"] not in sectionData[
                        SectionIndex.TakenStars]:
                    module_tip.addModuleTipEvent(userId, "mainquest",
                                                 "star_%d" % val["star"])
            mo.setResult("chestInfo", chestInfo)  # 宝箱奖励
            mo.setResult("rewards", rewards)
            bireport.reportGameEvent("BI_NFISH_GE_MAIN_QUEST_TASKID", userId,
                                     FISH_GAMEID, 0, 0, 0, 0, 0, 0, [taskId],
                                     clientId)
    mo.setResult("code", code)
    router.sendToUser(mo, userId)
    pushCurrTask(userId)
Exemplo n.º 7
0
def getShareTaskInfo(userId):
    """
    获取分享有礼信息
    """
    shareGroupIds = weakdata.getDayFishData(userId, "shareGroupIds", [])
    shareGroupTotalCount = config.getCommonValueByKey("shareGroupTotalCount")
    shareGroupCurrentCount = min(len(shareGroupIds), shareGroupTotalCount)
    groupTask = {
        "taskId": 0,
        "progress": [shareGroupCurrentCount, shareGroupTotalCount], # 分享群数/总数
        "rewards": config.getCommonValueByKey("shareGroupRewards"),
        "state": weakdata.getDayFishData(userId, "shareGroupReward", 0)
    }
    if groupTask["state"] == 0 or util.isVersionLimit(userId):
        module_tip.cancelModuleTipEvent(userId, "invite", 0)
    inviteTasks = []
    inviteList = refreshInviteData(userId)
    for _, inviteData in enumerate(inviteList):
        name = util.getNickname(inviteData["userId"])
        avatar = userdata.getAttr(inviteData["userId"], "purl")
        if inviteData.get("isAppUser", 0) == 1:
            continue
        if inviteData.get("isNewUser"):
            rewards = config.getCommonValueByKey("newUserInviteFriendRewards")
        else:
            rewards = config.getCommonValueByKey("inviteFriendRewards")
        task = {
            "taskId": inviteData["inviteId"],
            "name": name,
            "avatar": avatar,
            "vip": hallvip.userVipSystem.getUserVip(userId).vipLevel.level,
            "state": 2 if inviteData.get("receiveTime") else 1,
            "rewards": rewards
        }
        inviteTasks.append(task)
    inviteCount = weakdata.getDayFishData(userId, "inviteCount", 0)
    inviteTotalCount = config.getCommonValueByKey("inviteLimitCount", 99999)
    inviteCount = min(inviteCount, inviteTotalCount)
    friendTask = {
        "progress": [inviteCount, inviteTotalCount],
        "rewards": config.getCommonValueByKey("inviteFriendRewards"),
        "newUserRewards": config.getCommonValueByKey("newUserInviteFriendRewards"),
        "tasks": inviteTasks
    }
    message = MsgPack()
    message.setCmd("share_task_info")
    message.setResult("gameId", FISH_GAMEID)
    message.setResult("userId", userId)
    if not util.isVersionLimit(userId):
        message.setResult("groupTask", groupTask)
    message.setResult("friendTask", friendTask)
    router.sendToUser(message, userId)
Exemplo n.º 8
0
def getLevelRewards(userId, level):
    """
    领取等级奖励
    """
    clientId = util.getClientId(userId)
    module_tip.cancelModuleTipEvent(userId, "levelrewards", level)
    code = 1
    userLevel = util.getUserLevel(userId)
    levels = gamedata.getGameAttrJson(userId, config.FISH_GAMEID,
                                      GameData.levelRewards, [])
    levelRewards = config.getLevelRewards(clientId, level)
    rewards = []
    chestRewards = {}
    if levelRewards and level not in levels and level <= userLevel:
        for val in levelRewards.get("rewards", []):
            itemId = val["name"]
            if util.isChestRewardId(itemId):
                chestRewards["chestId"] = itemId
                chestRewards["rewards"] = chest_system.getChestRewards(
                    userId, itemId)
                code = chest_system.deliveryChestRewards(
                    userId, itemId, chestRewards["rewards"],
                    "BI_NFISH_GET_LEVEL_REWARDS")
            else:
                r = [{"name": val["name"], "count": val["count"]}]
                rewards.extend(r)
                code = util.addRewards(userId, r, "BI_NFISH_GET_LEVEL_REWARDS",
                                       level)
        if levelRewards.get("rechargeBonus", 0) > 0:
            util.incrUserRechargeBonus(userId,
                                       levelRewards.get("rechargeBonus", 0))
        levels.append(level)
        gamedata.setGameAttr(userId, config.FISH_GAMEID, GameData.levelRewards,
                             json.dumps(levels))

    mo = MsgPack()
    mo.setCmd("levelRewards")
    mo.setResult("gameId", config.FISH_GAMEID)
    mo.setResult("userId", userId)
    mo.setResult("code", code)
    mo.setResult("level", level)
    mo.setResult("rewards", rewards)
    mo.setResult("chestRewards", chestRewards)
    router.sendToUser(mo, userId)
    ftlog.debug("level_rewards, userId =", userId, "code =", code, "level =",
                level, "userLevel =", userLevel, "rewards =", rewards,
                "levels =", levels)

    getLevelRewardsData(userId)
Exemplo n.º 9
0
def getShareTaskRewards(userId, taskId):
    """
    领取分享好礼奖励
    """
    code = 1
    chestId = 0
    rewards = []
    eventId = "BI_NFISH_INVITE_TASK_REWARDS"
    if taskId == 0:
        isReceiveReward = weakdata.getDayFishData(userId, "shareGroupReward", 0)
        shareGroupIds = weakdata.getDayFishData(userId, "shareGroupIds", [])
        shareGroupTotalCount = config.getCommonValueByKey("shareGroupTotalCount")
        if isReceiveReward == 1 and len(shareGroupIds) >= shareGroupTotalCount:
            rewards = config.getCommonValueByKey("shareGroupRewards")
            from newfish.entity.chest import chest_system
            for reward in rewards:
                kindId = reward["name"]
                if util.isChestRewardId(kindId):
                    chestId = kindId
                    rewards = chest_system.getChestRewards(userId, kindId)
                    code = chest_system.deliveryChestRewards(userId, kindId, rewards, eventId)
                else:
                    code = util.addRewards(userId, [reward], eventId)
            weakdata.setDayFishData(userId, WeakData.shareGroupReward, 2)
    else:
        inviteList = refreshInviteData(userId)
        for _, inviteData in enumerate(inviteList):
            if inviteData["inviteId"] == taskId and not inviteData.get("receiveTime"):
                if inviteData.get("isAppUser", 0) == 1:
                    continue
                if inviteData.get("isNewUser"):
                    rewards = config.getCommonValueByKey("newUserInviteFriendRewards")
                else:
                    rewards = config.getCommonValueByKey("inviteFriendRewards")
                code = util.addRewards(userId, rewards, eventId)
                inviteData["receiveTime"] = int(time.time())
                break
        gamedata.setGameAttr(userId, FISH_GAMEID, GameData.inviteList, json.dumps(inviteList))
    message = MsgPack()
    message.setCmd("share_task_receive")
    message.setResult("gameId", FISH_GAMEID)
    message.setResult("userId", userId)
    message.setResult("taskId", taskId)
    message.setResult("code", code)
    if code == 0:
        module_tip.cancelModuleTipEvent(userId, "invite", taskId)
        message.setResult("chestId", chestId)
        message.setResult("rewards", rewards)
    router.sendToUser(message, userId)
Exemplo n.º 10
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)
Exemplo n.º 11
0
 def receiveActivityReward(self, taskId=None, extend=None):
     """
     领取活动奖励
     """
     assert (self.activityData)
     if self.activityData["state"] == ActivityState.Normal:
         if isinstance(self.activityConfig.get("extends"), dict):
             self.activityData["state"] = self.activityConfig[
                 "extends"].get("receiveState", ActivityState.Normal)
     if self.activityData["state"] == ActivityState.Received:
         return CodeType.Received, []
     if self.activityData["state"] == ActivityState.Complete:
         self.activityData["state"] = ActivityState.Received
         self.activityData["receiveTime"] = int(time.time())
         self.saveActivityData()
         rewards = self.activityConfig["reward"]
         code = util.addRewards(self.userId, rewards,
                                "BI_NFISH_ACTIVITY_REWARDS")
         module_tip.cancelModuleTipEvent(self.userId, "activity",
                                         self.activityId)
         return code, rewards
     return CodeType.NotComplete, []
Exemplo n.º 12
0
def receiveInvitTaskReward(userId, taskId, actionType):
    weakDatas = weakdata.getDayFishDataAll(userId, FISH_GAMEID)
    taskConf = config.getInviteTaskConf(taskId, actionType)
    code = 0
    chestId = 0
    rewards = []
    taskState = []
    saveKey = "inviteTasks"
    if not taskConf:
        return 999, chestId, rewards, taskState
    if actionType == NewPlayerAction:
        taskState = strutil.loads(weakDatas.get("inviteTasks", "[]"))
        playerNums = len(strutil.loads(weakDatas.get("inviteNewPlayers", "[]")))
    else:
        saveKey = "recallTasks"
        taskState = strutil.loads(weakDatas.get("recallTasks", "[]"))
        playerNums = len(strutil.loads(weakDatas.get("recallPlayers", "[]")))

    if taskConf["target"] > playerNums:
        return 1, chestId, rewards, taskState

    if taskId in taskState:
        return 2, chestId, rewards, taskState

    rewards = taskConf["rewards"]
    for _reward in taskConf["rewards"]:
        kindId = _reward["name"]
        if util.isChestRewardId(kindId):
            chestId = kindId
            rewards = chest_system.getChestRewards(userId, kindId)
            code = chest_system.deliveryChestRewards(userId, kindId, rewards, "BI_NFISH_INVITE_TASK_REWARDS")
        else:
            code = util.addRewards(userId, [_reward], "BI_NFISH_INVITE_TASK_REWARDS", int(taskId))
    taskState.append(taskId)
    weakdata.setDayFishData(userId, saveKey, strutil.dumps(taskState))
    # 更新小红点
    module_tip.cancelModuleTipEvent(userId, "invitetasks", taskId)
    return code, chestId, rewards, taskState
Exemplo n.º 13
0
def getLevelFundsRewards(userId, clientId, productId, level=0, rewardType=0):
    """
    领取基金奖励
    """
    code = 0
    rewards = []
    rewardsState = []
    isQuickGet = (level == 0)
    # 根据商品Id确定游戏模式.
    mode = config.CLASSIC_MODE
    for _m in [config.CLASSIC_MODE, config.MULTIPLE_MODE]:
        fundsConf = config.getLevelFundsConf(clientId, _m)
        for val in fundsConf.get("funds"):
            if val.get("productId") == productId:
                mode = _m
                break
    lf_rewards = _getRewardsState(userId, mode)
    lf_funds = _getBoughtFunds(userId, mode)
    userLv = util.getGunLevelVal(userId, mode)
    fundsConf = config.getLevelFundsConf(clientId, mode)
    funds = fundsConf.get("funds")
    rewardsConf = fundsConf.get("rewards")
    rewardsTypeStr = ["free_rewards", "funds_rewards"]
    if rewardType in [0, 1]:
        for val in funds:
            if val.get("productId") != productId:
                continue
            rewardsData = rewardsConf.get(str(val["idx"]))
            isChanged = False
            for lvData in rewardsData:
                lv = lvData["level"]
                if (isQuickGet and lv <= userLv) or (not isQuickGet and lv == level):
                    lf_rewards.setdefault(str(lv), [0, 0])
                    # 一键领取时需要检测两种奖励是否可以领取。
                    typeList = [rewardType]
                    if isQuickGet:
                        typeList = [0, 1]
                    for _type in typeList:
                        if lf_rewards[str(lv)][_type] == 0 and (_type == 0 or val["idx"] in lf_funds):
                            isChanged = True
                            lf_rewards[str(lv)][_type] = 2
                            for _reward in lvData[rewardsTypeStr[_type]]:
                                itemId = _reward["name"]
                                if util.isChestRewardId(itemId):
                                    chestRewards = {}
                                    chestRewards["chestId"] = itemId
                                    chestRewards["rewards"] = chest_system.getChestRewards(userId, itemId)
                                    chest_system.deliveryChestRewards(userId, itemId, chestRewards["rewards"],
                                                                      "BI_NFISH_GET_LEVEL_FUNDS", param01=lv, param02=_type)
                                    rewards.append(chestRewards)
                                else:
                                    rewards.append([_reward])
                                    util.addRewards(userId, [_reward], "BI_NFISH_GET_LEVEL_FUNDS", param01=lv, param02=_type)
                            if _type == 0 and lvData.get("rechargeBonus", 0) > 0:
                                util.incrUserRechargeBonus(userId, lvData["rechargeBonus"])
            if isChanged:
                daobase.executeUserCmd(userId, "HSET", _getRdKey(userId, mode), GameData.lf_rewards, json.dumps(lf_rewards))
            hasTip, rewardsState = _getLevelFundsRewardState(userId, clientId, val["idx"], mode, lf_funds=lf_funds, lf_rewards=lf_rewards)
            if not hasTip:
                if mode == 1:
                    module_tip.cancelModuleTipEvent(userId, "levelfundsNew", productId)
                else:
                    module_tip.cancelModuleTipEvent(userId, "levelfunds", productId)
            break
        else:
            code = 1
    else:
        code = 2
    message = MsgPack()
    message.setCmd("levelFundsRewards")
    message.setResult("gameId", config.FISH_GAMEID)
    message.setResult("userId", userId)
    message.setResult("productId", productId)
    message.setResult("code", code)
    message.setResult("rewards", rewards)
    message.setResult("rewardType", rewardType)
    message.setResult("rewardsState", rewardsState)
    router.sendToUser(message, userId)
Exemplo n.º 14
0
def getSectionStarRewards(userId, clientId, sectionId, star):
    """
    领取章节星级奖励
    """
    mo = MsgPack()
    mo.setCmd("task")
    mo.setResult("gameId", FISH_GAMEID)
    mo.setResult("userId", userId)
    mo.setResult("action", "sectionStarReward")
    mo.setResult("star", star)
    code = 1
    # honorId = 0
    sectionConf = config.getMainQuestSectionConf(clientId, sectionId)
    currSectionId = gamedata.getGameAttr(userId, FISH_GAMEID,
                                         GameData.currSectionId)
    gotReward = []
    # 检查领取的章节是否为当前生效章节.
    if sectionConf and sectionId == currSectionId:
        sectionData = getSection(userId, sectionId)
        # 检查该星级是否已经领取过.
        star = int(star)
        if star not in sectionData[SectionIndex.TakenStars]:
            starRewards = sectionConf["starRewards"]
            stars = []
            for val in starRewards:
                stars.append(val["star"])
                if val["star"] == star:
                    code = 0
                    rewards = {
                        "name": val["rewards"][0]["itemId"],
                        "count": val["rewards"][0]["count"]
                    }
                    sectionData[SectionIndex.TakenStars].append(star)
                    gotReward = sectionData[SectionIndex.TakenStars]
                    sectionData[SectionIndex.FinishTime] = int(time.time())
                    kindId = rewards["name"]
                    if util.isChestRewardId(kindId):
                        rewards = chest_system.getChestRewards(userId, kindId)
                        chest_system.deliveryChestRewards(
                            userId,
                            kindId,
                            rewards,
                            "BI_NFISH_MAIN_QUEST_STAR_REWARDS",
                            param01=star)
                    else:
                        util.addRewards(userId, [rewards],
                                        "BI_NFISH_MAIN_QUEST_STAR_REWARDS",
                                        int(sectionId), star)
                    module_tip.cancelModuleTipEvent(userId, "mainquest",
                                                    "star_%d" % star)
                    mo.setResult("rewards", rewards)
            if code == 0:
                # 章节任务全部完成并且星级奖励全部领取即可跳转章节.
                finishTaskIds = sectionData[SectionIndex.FinishTasks]
                if len(set(sectionConf["taskIds"]) -
                       set(finishTaskIds)) == 0 and len(
                           set(stars) -
                           set(sectionData[SectionIndex.TakenStars])) == 0:
                    # honorId = sectionConf["honorId"]
                    sectionData[
                        SectionIndex.State] = QuestState.Received  # 领取星级奖励
                    module_tip.cancelModuleTipEvent(userId, "mainquest",
                                                    sectionId)
                    switchToNextSection(userId, clientId,
                                        currSectionId)  # 解锁下一个章节
                    from newfish.game import TGFish
                    event = MainQuestSectionFinishEvent(
                        userId, FISH_GAMEID, sectionId, currSectionId)
                    TGFish.getEventBus().publishEvent(event)
                setSection(userId, sectionId, sectionData)  # 保存当前章节数据
    mo.setResult("code", code)
    mo.setResult("gotReward", gotReward)
    router.sendToUser(mo, userId)
    pushCurrTask(userId)