--- 大天使秘境副本 --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by zhoutao. --- DateTime: 2024/11/20 16:43 BigSecretRealm = {} local this = {} --- 获取大天使秘境面板信息 --- @param actor table 角色对象 function BigSecretRealm.getPanelInfo(actor) -- 获取钥匙等级 local keyLevel = getplaydef(actor, PlayerDefKey.bigSecretRealm.KEY_LEVEL) keyLevel = keyLevel and tonumber(keyLevel) or 0 -- 获取大天使秘境副本评分 local score = getplaydef(actor, string.format(PlayerDefKey.bigSecretRealm.SCORE, keyLevel)) score = score and score or "" -- 获取是否领取奖励 local isReceiveReward = getplaydef(actor, PlayerDefKey.bigSecretRealm.IS_RECEIVE_REWARD) -- 获取剩余奖励次数 local rewardCount = getplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT) -- 获取副本加成信息 local bonusInfo = getsysvar(SystemVarConst.BIG_SECRET_REALM_BONUS_INFO) if table.isNullOrEmpty(bonusInfo) then bonusInfo = this.getRandomBonusInfo() setsysvar(SystemVarConst.BIG_SECRET_REALM_BONUS_INFO, bonusInfo) end local text = ConfigDataManager.getTableValue("cfg_bigUncharted_buff", "text", "id", bonusInfo["id"]) local str = (bonusInfo["value"] / 100) .. "%" text = string.format(text, str) sendluamsg(actor, LuaMessageIdToClient.RES_BIG_SECRET_REALM_PANEL_INFO, { ["score"] = score, ["keyLevel"] = keyLevel, ["isReceiveReward"] = isReceiveReward, ["rewardCount"] = rewardCount, ["bonusInfo"] = text }) end --- 设置默认领取奖励状态 --- @param actor table 角色对象 function BigSecretRealm.setReceiveStatus(actor) local receiveStatus = getplaydef(actor, PlayerDefKey.bigSecretRealm.IS_RECEIVE_REWARD) setplaydef(actor, PlayerDefKey.bigSecretRealm.IS_RECEIVE_REWARD, not receiveStatus) sendluamsg(actor, LuaMessageIdToClient.RES_BIG_SECRET_REALM_RECEIVE_STATUS, not receiveStatus) end --- 进入大天使秘境副本 --- @param actor table 角色对象 --- @param configId number 副本配置id function BigSecretRealm.ReqEnterBigSecretRealm(actor, configId) -- 重置发送邮件标识 setplaydef(actor, PlayerDefKey.bigSecretRealm.IS_SEND_EMAIL, false) -- 判断角色等级是否满足 local playerLevel = tonumber(getbaseinfo(actor, "level")) local levelConfig = ConfigDataManager.getTableValue("cfg_rep", "level", "id", configId) local levelList = string.split(levelConfig, "#") local minLevel = tonumber(levelList[1]) local maxLevel = tonumber(levelList[2]) if playerLevel < minLevel or playerLevel > maxLevel then noticeTip.noticeinfo(actor, StringIdConst.LEVEL_NOT_MATCH) return end -- 判断秘境钥匙等级是否满足 local keyLevel = getplaydef(actor, PlayerDefKey.bigSecretRealm.KEY_LEVEL) local repLevel = ConfigDataManager.getTableValue("cfg_rep", "repLevel", "id", configId) if not keyLevel or keyLevel < tonumber(repLevel) then noticeTip.noticeinfo(actor, StringIdConst.TEXT495) return end local x, y = DuplicateCommon.GetEnterPointXYCommon(configId) local mapId = DuplicateCommon.CreateDupMapCommon(actor, configId, true) -- 回蓝回血 DuplicateCommon.RecoverHPMP(actor) -- 删除秘境钥匙道具 local keyId = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.bigSecretRealm.KEY_ID) Bag.cost(actor, keyId, 1) -- 进入副本 enterduplicate(actor, mapId, x, y) sendluamsg(actor, LuaMessageIdToClient.RES_ENTER_BIG_SECRET_REALM, configId) end --- 副本状态更新 function BigSecretRealm.DupStateUpdate(system, mapId, state, nextStateStartTime, configId) if state == DuplicateState.PREPARE then -- 初始化第一个任务 this.initTask(mapId, configId) elseif state == DuplicateState.FIGHT then -- 战斗阶段 local monsterId = ConfigDataManager.getTableValue("cfg_rep", "monster", "id", configId) DuplicateCommon.DupGenMonsterCommon(mapId, monsterId) --刷怪 this.ResAllTaskPhaseUpdate(mapId) end end --- 进入副本响应任务信息 function BigSecretRealm.AfterEnterBigSecretRealm(actor, mapId, state, nextStateStartTime, configId) -- 记录开始时间 this.recordStartTime(mapId) local startTime = getplaydef(actor, PlayerDefKey.bigSecretRealm.START_TIME) local offlineTime = getplaydef(actor, PlayerDefKey.offline.START_TIME) if startTime and offlineTime and startTime <= offlineTime then this.ResAllTaskPhaseUpdate(mapId) end end --- 怪物死亡 --- @param mapId number 地图id --- @param monCfgId number 怪物配置id function BigSecretRealm.BigSecretRealmMonsterDie(mapId, killer, monCfgId, monActor) local taskInfo = getenvirvar(mapId, DuplicateVarConst.BIG_SECRET_REALM_TASK_INFO) local taskId = taskInfo[2] local taskType = taskInfo[3] if taskType == DuplicateTaskType.KILL_MONSTER_COUNT then local totalCount = taskInfo[4] local oldCount = taskInfo[5] local newCount = oldCount + 1 if newCount >= totalCount then -- 完成任务,给客户端回包 this.FinishTask(mapId, taskId) else -- 更新记录,给客户端回包 taskInfo[5] = newCount setenvirvar(mapId, DuplicateVarConst.BIG_SECRET_REALM_TASK_INFO, taskInfo) end elseif taskType == DuplicateTaskType.KILL_TARGET_MONSTER then local targetMon = taskInfo[6] local totalCount = taskInfo[4] local oldCount = taskInfo[5] if tonumber(monCfgId) ~= targetMon then return end local newCount = oldCount + 1 if newCount >= totalCount then -- 调用副本完成方法 DuplicateCommon.FinishDupActivity(killer, getbaseinfo(killer, "mapid")) -- 完成任务,给客户端回包 this.FinishTask(mapId, taskId) end -- 更新记录,给客户端回包 taskInfo[5] = newCount setenvirvar(mapId, DuplicateVarConst.BIG_SECRET_REALM_TASK_INFO, taskInfo) end this.ResAllTaskPhaseUpdate(mapId) -- 任务信息 end --- 钥匙升级 --- @param actor table 角色对象 --- @param msgData table 消息数据 function BigSecretRealm.keyLevelUp(actor, upgradeLevel) if string.isNullOrEmpty(upgradeLevel) then info("BigSecretRealm.keyLevelUp upgradeLevel is null") return end if upgradeLevel > 0 then -- 钥匙升级操作 this.keyLevelChange(actor, MailConfig.BIG_SECRET_REALM_KEY_LEVEL_UP, upgradeLevel) else -- 发送当前等级钥匙 this.keyLevelChange(actor, MailConfig.BIG_SECRET_REALM_CURRENT_KEY_LEVEL, upgradeLevel) end end --- 领取通关奖励 --- @param actor table 角色对象 --- @param configId number 副本配置id function BigSecretRealm.receiveReward(actor, configId) -- 判断奖励次数是否大于零 local rewardCount = getplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT) if rewardCount <= 0 then return end -- 获取奖励列表 local rewardTable = ConfigDataManager.getTableValue("cfg_bigUncharted", "reward", "id", configId) if string.isNullOrEmpty(rewardTable) then return end local splitTable = string.split(rewardTable, "|") local rewards = {} for _, item in ipairs(splitTable) do local itemInfo = string.split(item, "#") local itemId = tonumber(itemInfo[1]) local itemCount = tonumber(itemInfo[2]) rewards[itemId] = itemCount end -- 发放奖励 Bag.sendRewards(actor, rewards, ItemAction.BIG_SECRET_REALM_REWARD) -- 减少奖励次数 setplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT, rewardCount - 1) end --- 退出大天使秘境副本 --- @param actor table 角色对象 --- @param configId number 副本配置id function BigSecretRealm.quitBigSecretRealm(actor, configId) -- 查询角色是否通关 local isPassed = getplaydef(actor, PlayerDefKey.bigSecretRealm.IS_PASSED_LEVEL) -- 没有通关手动退出读表降级钥匙 if not isPassed then local penalize = ConfigDataManager.getTableValue("cfg_bigUncharted", "penalize", "id", configId) penalize = tonumber(penalize) this.keyLevelChange(actor, MailConfig.BIG_SECRET_REALM_QUIT_KEY_LEVEL_DOWN, -penalize) end -- 退出副本重置 setplaydef(actor, PlayerDefKey.bigSecretRealm.IS_PASSED_LEVEL, false) -- 清空副本开始时间 setplaydef(actor, PlayerDefKey.bigSecretRealm.START_TIME, nil) -- 调用退出副本接口 quitduplicate(actor) end --- 秘境副本扫荡 --- @param actor table 角色对象 --- @param configId number 副本配置id function BigSecretRealm.sweep(actor, configId) local keyLevel = getplaydef(actor, PlayerDefKey.bigSecretRealm.KEY_LEVEL) -- 判断评分是否可以开启扫荡 local score = getplaydef(actor, string.format(PlayerDefKey.bigSecretRealm.SCORE, keyLevel)) local scoreCondition = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.bigSecretRealm.SWEEP_CONDITION) local scoreValue = ConfigDataManager.getTableValue("cfg_bigUncharted", "score", "id", configId) if not string.isNullOrEmpty(scoreValue) then local scoreSplit = string.split(scoreValue, "#") local scoreIndex = table.getKey(scoreSplit, score) local scoreConditionIndex = table.getKey(scoreSplit, scoreCondition) if scoreIndex > scoreConditionIndex then gameDebug.print("大天使秘境副本评分不足,无法扫荡 score:", score) return end -- 判断奖励次数是否支持扫荡 local rewardCount = getplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT) if rewardCount and rewardCount > 0 then -- 直接发放奖励 BigSecretRealm.receiveReward(actor, configId) -- 响应面板信息 BigSecretRealm.getPanelInfo(actor) else return end end end --- 如果是首次登录则初始化大天使秘境信息 --- @param actor table 角色对象 function BigSecretRealm.login(actor) -- 初始化剩余奖励次数 local rewardCount = getplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT) if string.isNullOrEmpty(rewardCount) then rewardCount = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.bigSecretRealm.REWARD_COUNT) setplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT, tonumber(string.split(rewardCount, "#")[1])) end -- 初始化是否默认领取奖励 local isReceiveReward = getplaydef(actor, PlayerDefKey.bigSecretRealm.IS_RECEIVE_REWARD) if not isReceiveReward then setplaydef(actor, PlayerDefKey.bigSecretRealm.IS_RECEIVE_REWARD, false) end -- 初始化副本加成信息 local bonusInfo = getsysvar(actor, SystemVarConst.BIG_SECRET_REALM_BONUS_INFO) if table.isNullOrEmpty(bonusInfo) then bonusInfo = this.getRandomBonusInfo() setsysvar(actor, SystemVarConst.BIG_SECRET_REALM_BONUS_INFO, bonusInfo) end -- 判断是否为离线超时退出副本,是否发送邮件 local isPassed = getplaydef(actor, PlayerDefKey.bigSecretRealm.IS_PASSED_LEVEL) local isSend = getplaydef(actor, PlayerDefKey.bigSecretRealm.IS_SEND_EMAIL) local startTime = getplaydef(actor, PlayerDefKey.bigSecretRealm.START_TIME) if not isPassed and not isSend and startTime then local offlineTime = getplaydef(actor, PlayerDefKey.offline.START_TIME) local now = getbaseinfo("now") local timeout = ConfigDataManager.getTableValue("cfg_global", "value", "id", GlobalConfigId.DUPLICATE_TIME_OUT) if offlineTime and now - offlineTime > tonumber(timeout) * TimeUnit.MILLISECOND then this.keyLevelChange(actor, MailConfig.BIG_SECRET_REALM_QUIT_KEY_LEVEL_DOWN, -1) setplaydef(actor, PlayerDefKey.bigSecretRealm.START_TIME, nil) end end end --- 初始化大天使秘境钥匙等级 --- @param actor table 角色对象 --- @param itemCfgId number 物品配置id function BigSecretRealm.initKeyLevel(actor, itemCfgId) local keyId = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.bigSecretRealm.KEY_ID) if itemCfgId == tonumber(keyId) then local keyLevel = getplaydef(actor, PlayerDefKey.bigSecretRealm.KEY_LEVEL) if not keyLevel then setplaydef(actor, PlayerDefKey.bigSecretRealm.KEY_LEVEL, 1) end end end --- 重置大天使秘境副本奖励次数与副本加成信息 function BigSecretRealm.refreshBigSecretRealm() local seconds = getbaseinfo("nowsec") local now = TimeUtil.timeToDate(seconds) if now.min == 0 then gameDebug.print("BigSecretRealm.refreshBigSecretRealm now.hour:", now.hour) gameDebug.print("BigSecretRealm.refreshBigSecretRealm now.min:", now.min) gameDebug.print("BigSecretRealm.refreshBigSecretRealm now.sec:", now.sec) local refreshTime = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.bigSecretRealm.REFRESH_TIME) local rewardCount = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.bigSecretRealm.REWARD_COUNT) local split = string.split(rewardCount, "#") local incrementCount = tonumber(split[1]) local limit = tonumber(split[2]) if string.isNullOrEmpty(refreshTime) then gameDebug.print("BigSecretRealm cfg_repGlobal refreshTime is nil") return end local refreshTime_split = string.split(refreshTime, "#") local type = tonumber(refreshTime_split[1]) local time = tonumber(refreshTime_split[2]) if type == 1 then if now.hour == tonumber(time) and now.min == 0 and now.sec >= 0 then local allRoleInfos = getallrolesummaryinfos() if table.isNullOrEmpty(allRoleInfos) then return end for _, roleInfo in pairs(allRoleInfos) do local actor = roleInfo["actor"] -- 刷新奖励次数 this.refreshCount(actor, incrementCount, limit) -- 刷新副本buff local bonusInfo = this.getRandomBonusInfo() setsysvar(SystemVarConst.BIG_SECRET_REALM_BONUS_INFO, bonusInfo) end end return end if type == 2 then if now.wday == 1 and now.hour == tonumber(time) and now.min == 0 and now.sec >= 0 then local allRoleInfos = getallrolesummaryinfos() if table.isNullOrEmpty(allRoleInfos) then return end for _, roleInfo in pairs(allRoleInfos) do local actor = roleInfo["actor"] -- 刷新奖励次数 this.refreshCount(actor, incrementCount, limit) -- 刷新副本buff local bonusInfo = this.getRandomBonusInfo() setsysvar(SystemVarConst.BIG_SECRET_REALM_BONUS_INFO, bonusInfo) end end return end end end --- 初始化任务信息 --- @param mapId number 地图id --- @param configId number 副本配置id function this.initTask(mapId, configId) --当前任务信息 local taskId = ConfigDataManager.getTableValue("cfg_rep", "repTarget", "id", configId) local taskInfo = DuplicateCommon.GenDupTaskInfoCommon(taskId) table.insert(taskInfo, 1, BigSecretRealmTaskPhase.ONE) setenvirvar(mapId, DuplicateVarConst.BIG_SECRET_REALM_TASK_INFO, taskInfo) end --- 记录开始时间 --- @param mapId number 副本id function this.recordStartTime(mapId) local dupInfo = getduplicate(mapId) local players = dupInfo["players"] for _, actor in ipairs(players) do local startTime = getplaydef(actor, PlayerDefKey.bigSecretRealm.START_TIME) if not startTime then setplaydef(actor, PlayerDefKey.bigSecretRealm.START_TIME, getbaseinfo("now")) end end end --- 响应客户端任务更新 --- @param actor table 角色对象 --- @param mapId number 副本id --- @param configId number 副本配置id function this.ResTaskPhaseUpdate(actor, mapId, configId) local taskInfo = getenvirvar(mapId, DuplicateVarConst.BIG_SECRET_REALM_TASK_INFO) local nowPhase = taskInfo[1] local taskId = taskInfo[2] local totalCount = taskInfo[4] local nowCount = taskInfo[5] local dupInfo = getduplicate(mapId) local nextStateStartTime = dupInfo["nextstatetime"] local response = {} response["phase"] = nowPhase response["taskId"] = taskId response["nowCount"] = nowCount response["totalCount"] = totalCount response["configId"] = configId response["nextStateStartTime"] = nextStateStartTime sendluamsg(actor, LuaMessageIdToClient.RES_BIG_SECRET_REALM_TASK_UPDATE, response) end function this.ResAllTaskPhaseUpdate(mapId) local dupInfo = getduplicate(mapId) local players = dupInfo["players"] local configId = dupInfo["dupcfgid"] for _, actor in ipairs(players) do this.ResTaskPhaseUpdate(actor, mapId, configId) end end --- 完成任务 --- @param mapId number 副本id --- @param taskId number 任务id function this.FinishTask(mapId, taskId) local taskInfo = getenvirvar(mapId, DuplicateVarConst.BIG_SECRET_REALM_TASK_INFO) local nextTaskId = ConfigDataManager.getTableValue("cfg_repTask", "nextID", "id", taskId) local dupInfo = getduplicate(mapId) local configId = dupInfo["dupcfgid"] if string.isNullOrEmpty(nextTaskId) then -- 根据条件判断 发送钥匙升级弹窗信息 this.sendKeyLevelUpPanelInfo(mapId) -- 如果副本玩家离线则直接发放钥匙与奖励 this.offlineHandle(mapId) return end local dupLevel = ConfigDataManager.getTableValue("cfg_rep", "repLevel", "id", configId) dupLevel = tonumber(dupLevel) local nowPhase = taskInfo[1] if nowPhase == BigSecretRealmTaskPhase.ONE then nowPhase = nowPhase + 1 end local type = ConfigDataManager.getTableValue("cfg_repTask", "type", "id", nextTaskId) if type == DuplicateTaskType.KILL_TARGET_MONSTER then nowPhase = nowPhase + 1 end if nowPhase == BigSecretRealmTaskPhase.TWO then --阶段二,刷新小怪 DuplicateCommon.DupGenMonsterCommon(mapId, nextTaskId) --刷怪 elseif nowPhase == BigSecretRealmTaskPhase.THREE then --阶段三,刷新BOSS DuplicateCommon.DupGenMonsterCommon(mapId, nextTaskId) --刷怪 end -- 设置下一个任务 local nextTaskInfo = DuplicateCommon.GenDupTaskInfoCommon(nextTaskId) table.insert(nextTaskInfo, 1, nowPhase) setenvirvar(mapId, DuplicateVarConst.BIG_SECRET_REALM_TASK_INFO, nextTaskInfo) end --- 发送钥匙升级与奖励弹窗信息 --- @param mapId number 副本id function this.sendKeyLevelUpPanelInfo(mapId) local dupInfo = getduplicate(mapId) local players = dupInfo["players"] local dupCfgId = dupInfo["dupcfgid"] local now = getbaseinfo("now") for _, actor in ipairs(players) do if not isofflineplay(actor) then -- 标识角色是否已经通关此次副本 setplaydef(actor, PlayerDefKey.bigSecretRealm.IS_PASSED_LEVEL, true) local startTime = getplaydef(actor, PlayerDefKey.bigSecretRealm.START_TIME) local dupTime = (now - startTime) local tableValue = ConfigDataManager.getTable("cfg_bigUncharted", "id", dupCfgId) local resLevelUp, currentScore = this.checkKeyLevelUpOrDown(actor, dupTime, tableValue) local keyLevel = getplaydef(actor, PlayerDefKey.bigSecretRealm.KEY_LEVEL) if resLevelUp < 0 then -- 钥匙降级发送邮件 this.keyLevelChange(actor, MailConfig.BIG_SECRET_REALM_KEY_LEVEL_DOWN, resLevelUp) end -- 响应客户端通关成功面板信息 sendluamsg(actor, LuaMessageIdToClient.RES_BIG_SECRET_REALM_CLEARANCE_PANEL_INFO, { ["keyLevel"] = keyLevel, ["score"] = currentScore, ["resLevelUp"] = resLevelUp, ["isReceiveReward"] = getplaydef(actor, PlayerDefKey.bigSecretRealm.IS_RECEIVE_REWARD), ["rewardCount"] = getplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT), ["rewardItems"] = string.toStringStringMap(tableValue[1]["reward"], "#", "|"), ["passedTime"] = dupTime, }) end end end --- 钥匙升级或降级 --- @param actor table 角色对象 --- @param dupTime number 副本通关时间 --- @param tableValue table 配置表数据 --- @return number 升级或降级等级 function this.checkKeyLevelUpOrDown(actor, dupTime, tableValue) -- 根据通关时间来计算评分、钥匙升降级 local minutes = math.ceil(dupTime / TimeUnit.MILLISECOND / TimeUnit.MINUTE) local time = tableValue[1]["time"] local score = tableValue[1]["score"] local levelUp = tableValue[1]["levelup"] local splitStr = string.split(time, "#") local strIndex for index, value in pairs(splitStr) do if tonumber(value) >= minutes then strIndex = index break end end if not strIndex then strIndex = #splitStr end -- 判断之前的评分是否优于此次,优于此次则不更新 local scoreKey = string.format(PlayerDefKey.bigSecretRealm.SCORE, getplaydef(actor, PlayerDefKey.bigSecretRealm.KEY_LEVEL)) local lastScore = getplaydef(actor, scoreKey) local scoreSplit = string.split(score, "#") setplaydef(actor, PlayerDefKey.bigSecretRealm.NEW_SCORE, scoreSplit[strIndex]) if lastScore then for index, value in pairs(scoreSplit) do if lastScore == value and index > strIndex then setplaydef(actor, scoreKey, scoreSplit[strIndex]) break end end else setplaydef(actor, scoreKey, scoreSplit[strIndex]) end local resLevelUp = string.split(levelUp, "#")[strIndex] return tonumber(resLevelUp), scoreSplit[strIndex] end --- 钥匙升降级发送邮件给玩家 --- @param actor table 角色对象 --- @param mailConfigId number 邮件配置id --- @param levelChange number 钥匙升降的等级 function this.keyLevelChange(actor, mailConfigId, levelChange) -- 此前发送过邮件则返回 local isSend = getplaydef(actor, PlayerDefKey.bigSecretRealm.IS_SEND_EMAIL) if isSend then return end -- 通关得分 local keyLevel = getplaydef(actor, PlayerDefKey.bigSecretRealm.KEY_LEVEL) local score = getplaydef(actor, PlayerDefKey.bigSecretRealm.NEW_SCORE) if tonumber(levelChange) ~= 0 then -- 钥匙等级处理 if (keyLevel + tonumber(levelChange)) > 0 then keyLevel = keyLevel + tonumber(levelChange) else keyLevel = 1 end end -- 获取钥匙itemConfigId local itemConfigId = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.bigSecretRealm.KEY_ID) local param = "" if mailConfigId == MailConfig.BIG_SECRET_REALM_QUIT_KEY_LEVEL_DOWN or mailConfigId == MailConfig.BIG_SECRET_REALM_CURRENT_KEY_LEVEL then param = keyLevel else param = score .. "#" .. keyLevel end -- 标识已经发送过邮件,避免重复发送 setplaydef(actor, PlayerDefKey.bigSecretRealm.IS_SEND_EMAIL, true) -- 设置钥匙等级 setplaydef(actor, PlayerDefKey.bigSecretRealm.KEY_LEVEL, keyLevel) -- 发送邮件 sendconfigmailbyrid(actor, getbaseinfo(actor, "rid"), mailConfigId, { [tonumber(itemConfigId)] = 1 }, param) end --- 离线处理 --- @param mapId number 副本id function this.offlineHandle(mapId) local dupInfo = getduplicate(mapId) local players = dupInfo["players"] local configId = dupInfo["dupcfgid"] local now = getbaseinfo("now") for _, actor in ipairs(players) do if isofflineplay(actor) then local startTime = getplaydef(actor, PlayerDefKey.bigSecretRealm.START_TIME) local levelUpOrDown if not startTime then levelUpOrDown = -1 else local dupTime = (now - startTime) local tableValue = ConfigDataManager.getTable("cfg_bigUncharted", "id", configId) levelUpOrDown, _ = this.checkKeyLevelUpOrDown(actor, dupTime, tableValue) end -- 根据钥匙升级还是降级发送不同的邮件 if levelUpOrDown > 0 then -- 执行钥匙升级操作 this.keyLevelChange(actor, MailConfig.BIG_SECRET_REALM_KEY_LEVEL_UP, levelUpOrDown) else -- 执行钥匙降级操作 this.keyLevelChange(actor, MailConfig.BIG_SECRET_REALM_KEY_LEVEL_DOWN, levelUpOrDown) end local isReceive = getplaydef(actor, PlayerDefKey.bigSecretRealm.IS_RECEIVE_REWARD) if isReceive then BigSecretRealm.receiveReward(actor, configId) end -- 清空副本开始时间 setplaydef(actor, PlayerDefKey.bigSecretRealm.START_TIME, nil) -- 调用退出副本接口 quitduplicate(actor) end end end --- 刷新奖励次数 --- @param incrementCount number 增加的次数 --- @param limit number 次数上限 function this.refreshCount(actor, incrementCount, limit) local rewardCount = getplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT) if not rewardCount then setplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT, incrementCount) elseif rewardCount + incrementCount > limit then setplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT, limit) else setplaydef(actor, PlayerDefKey.bigSecretRealm.REWARD_COUNT, rewardCount + incrementCount) end end --- 获取随机加成信息 --- @return number 加成id function this.getRandomBonusInfo() local tableInfo = ConfigDataManager.getTable("cfg_bigUncharted_buff") if table.isNullOrEmpty(tableInfo) then gameDebug.print("cfg_bigUncharted_buff is nil") return end local randomIndex = math.random(1, #tableInfo) local id = tableInfo[randomIndex]["id"] local attNumber = tableInfo[randomIndex]["attnumber"] local splits = string.split(attNumber, "#") local min = splits[1] local max = splits[2] local attValue = math.random(min, max) return { ["id"] = id, ["value"] = attValue } end --- 判断角色是否在大秘境副本中 --- @param actor table 角色对象 function this.isInBigSecretRealm(actor) local activityId = getbaseinfo(actor, "activityid") if string.isNullOrEmpty(activityId) then return false end return tonumber(activityId) == DuplicateType.BIG_SECRET_REALM end