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 refreshQuestModuleTip(userId, clientId):
    """
    刷新当前章节小红点提示数据
    """
    currSectionId = gamedata.getGameAttr(userId, FISH_GAMEID,
                                         GameData.currSectionId)
    if currSectionId:
        sectionConf = config.getMainQuestSectionConf(clientId, currSectionId)
        taskIds = []
        totalStar = _getSectionStar(userId, clientId, currSectionId)
        for _taskId in sectionConf["taskIds"]:
            state = getTask(userId, _taskId)[QuestIndex.State]
            if state == QuestState.Completed:
                taskIds.append(_taskId)
        module_tip.resetModuleTip(userId, "mainquest")
        sectionData = getSection(userId, currSectionId)
        state = sectionData[SectionIndex.State]
        if state == QuestState.Completed:
            module_tip.addModuleTipEvent(userId, "mainquest", currSectionId)
        if taskIds:
            module_tip.addModuleTipEvent(userId, "mainquest", taskIds)
        # 检查主线任务增加的星级能否解锁对应星级奖励.
        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"])
Example #3
0
def getInviteTasks(userId, actionType):
    weakDatas = weakdata.getDayFishDataAll(userId, FISH_GAMEID)
    taskConfs_ = config.getInviteTasks(actionType)
    taskConfs = taskConfs_.values()
    taskConfs = sorted(taskConfs, key=lambda data: data["Id"])
    if actionType == NewPlayerAction:
        taskState = strutil.loads(weakDatas.get("inviteTasks", "[]"))
        playerNums = len(strutil.loads(weakDatas.get("inviteNewPlayers", "[]")))

    else:
        taskState = strutil.loads(weakDatas.get("recallTasks", "[]"))
        playerNums = len(strutil.loads(weakDatas.get("recallPlayers", "[]")))

    taskStartIndex = len(taskState) / OneGroupNum * OneGroupNum
    taskStartIndex = min((len(taskConfs) / OneGroupNum - 1) * OneGroupNum, taskStartIndex)

    # 奖励
    taskInfos = []
    tipsTaskIds = []
    for m in range(taskStartIndex, taskStartIndex + 5):
        if m >= len(taskConfs):
            break
        taskConf = taskConfs[m]
        taskId = taskConf["Id"]
        taskInfo = {}
        taskInfo["Id"] = taskId
        rewards = []
        for _reward in taskConf["rewards"]:
            rewardMap = {}
            kindId = _reward["name"]
            rewardMap["name"] = kindId
            rewardMap["count"] = _reward["count"]
            rewardMap["info"] = {}
            if util.isChestRewardId(kindId):
                rewardMap["info"] = chest_system.getChestInfo(kindId)
            rewards.append(rewardMap)
        taskInfo["rewards"] = rewards
        taskInfo["target"] = taskConf["target"]
        state = 0
        if taskId in taskState:
            state = 2
        elif playerNums >= taskConf["target"]:
            tipsTaskIds.append(taskId)
            state = 1
        taskInfo["state"] = state
        taskInfos.append(taskInfo)

    module_tip.resetModuleTip(userId, "invitetasks")
    if tipsTaskIds:
        module_tip.addModuleTipEvent(userId, "invitetasks", tipsTaskIds)
    return taskInfos, playerNums
def updateUnReadNotice(userId, clientId, allConfigs=None, readNotice=None):
    """
    是否有未读的活动
    """
    hasUnRead = False
    tipsIds = []
    allConfigs = allConfigs or _getAllNoticeConfigs(userId, clientId)
    readNotice = readNotice or _getNoticeReadInfo(userId)
    for notConf in allConfigs:
        if notConf["Id"] not in readNotice:
            hasUnRead = True
            tipsIds.append(notConf["Id"])
    module_tip.resetModuleTip(userId, "noticenew")
    if hasUnRead:
        tipsIds.append(0)
    module_tip.addModuleTipEvent(userId, "noticenew", tipsIds)
def checkTreasureUpgrade(userId):
    """
    检查宝藏能否升级
    """
    upTreasures = []
    for kindId, _ in config.getTreasureConf().iteritems():
        treasureData = getTreasure(userId, kindId)
        levelConf = config.getTreasureConf(kindId, level=treasureData[INDEX_LEVEL] + 1)
        if treasureData[INDEX_LEVEL] < len(config.getTreasureConf(kindId).get("levels", {})):
            consumeItems = [{"name": int(kindId), "count": int(levelConf["cost"])}]
            if checkUpgradeTreasureItemCount(userId, consumeItems):
                upTreasures.append(int(kindId))
    module_tip.resetModuleTip(userId, "treasure")
    if upTreasures:
        module_tip.addModuleTipEvent(userId, "treasure", upTreasures)
    else:
        module_tip.resetModuleTipEvent(userId, "treasure")
Example #6
0
def getChestList(userId):
    """
    获取宝箱列表
    """
    module_tip.resetModuleTip(userId, "chest")
    userBag = hallitem.itemSystem.loadUserAssets(userId).getUserBag()
    chestItemList = userBag.getAllTypeItem(TYChestItem)
    chestItemList = sorted(chestItemList, key=lambda chestItem: chestItem.order)
    chestList = []
    openedChestList = []
    for chestItem in chestItemList:
        if not chestItem.chestId:
            ftlog.error("chest item error", userId)
            continue
        openingOrder = [chestItemTmp.order for chestItemTmp in chestItemList if chestItemTmp.state == 1]
        chestConf = config.getChestConf(chestItem.chestId)
        chest = {}
        if chestItem.totalTime <= 0:
            chestItem.state = ChestState.Opened
        if chestItem.state == ChestState.WaitOpen and not openingOrder:
            chestItem.state = ChestState.Opening
        if chestItem.state == ChestState.WaitOpen:
            chestTimeLeft = chestItem.totalTime
        elif chestItem.state == ChestState.Opening:
            chestTimeLeft = chestItem.beginTime + chestItem.totalTime - pktimestamp.getCurrentTimestamp() + CHEST_OPEN_DELAY_TIME
        else:
            chestTimeLeft = 0
        if chestItem.state == ChestState.Opening and chestTimeLeft <= 0:
            chestItem.state = ChestState.Opened
            noOpenOrderList = [chestItemTmp.order for chestItemTmp in chestItemList if chestItemTmp.state == 0]
            if noOpenOrderList:
                nextOpeningChestItem = None
                for noOpenOrder in noOpenOrderList:
                    if noOpenOrder > chestItem.order:
                        nextOpeningChestItem = [chestItemImp for chestItemImp in chestItemList if chestItemImp.order == noOpenOrder][0]
                        break
                if not nextOpeningChestItem:
                    nextOpeningChestItem = [chestItemImp for chestItemImp in chestItemList if chestItemImp.order == noOpenOrderList[0]][0]
                if nextOpeningChestItem:
                    nextOpeningChestItem.state = ChestState.Opening
                    nextOpeningChestItem.beginTime = chestItem.beginTime + chestItem.totalTime
                    userBag.updateItem(FISH_GAMEID, nextOpeningChestItem, pktimestamp.getCurrentTimestamp())
                    for chestTmp in chestList:
                        if chestTmp["order"] == nextOpeningChestItem.order:
                            chestTmp["state"] = 1
                            chestTmp["timeLeft"] = nextOpeningChestItem.beginTime + nextOpeningChestItem.totalTime - \
                                                   pktimestamp.getCurrentTimestamp() + CHEST_OPEN_DELAY_TIME
                            break
        chestTimeLeft = max(0, chestTimeLeft)
        chest["order"] = chestItem.order
        chest["state"] = chestItem.state
        chest["chestId"] = chestItem.chestId
        chest["itemId"] = chestItem.itemId
        chest["kindId"] = chestItem.kindId
        chest["desc"] = chestItem.itemKind.desc
        chest["createTime"] = chestItem.createTime
        chest["timeLeft"] = chestTimeLeft
        chest["totalTime"] = chestItem.totalTime
        chest["openCoin"] = chestConf["openCoin"]
        chest["diamond"] = _needCoinAsOpenChest(chestItem.chestId, chestTimeLeft)
        chest["info"] = getChestInfo(chestItem.chestId)
        chestList.append(chest)
        userBag.updateItem(FISH_GAMEID, chestItem, pktimestamp.getCurrentTimestamp())
        if chestItem.state == ChestState.Opened:
            openedChestList.append(chestItem.itemId)
    ftlog.debug("getChestList->", chestList)
    module_tip.addModuleTipEvent(userId, "chest", openedChestList)
    return chestList