Efficiency = {} local redDotType = { efficiency = 1, efficiency_level = 2, } -- 校验激活状态 function Efficiency.CheckActive(actor, ids) local msg = {} for _, id in ipairs(ids) do local condition = ConfigDataManager.getTableValue("cfg_efficiency", "conditions", "id", id) if condition == '' then goto continue end -- 激活过的信息 -- local group = ConfigDataManager.getTableValue("cfg_efficiency", "group", "id", id) -- local actives = getplaydef(actor, "T$effcicency_active") -- if group ~= '1' then -- if actives then -- if actives[id] then -- table.insert(msg, id) -- goto continue -- end -- else -- actives = {} -- end -- end -- lg(condition) local result = ConditionManager.Check(actor, condition) if result then table.insert(msg, id) -- if group ~= '1' then -- -- actives[id] = true -- setplaydef(actor, "T$effcicency_active", actives) -- end end ::continue:: end -- lg(msg) sendluamsg(actor, LuaMessageIdToClient.RES_EFFECIENCY_TAB_ACTIVE, msg) end -- 领取奖励 function Efficiency.GetReward(actor, msgData) local rewardId = msgData.id local career_item_Count_Str = ConfigDataManager.getTableValue("cfg_efficiency_level", "item", "id", rewardId) if career_item_Count_Str == '' then return end local redDots = getplaydef(actor, "T$redDots") or {} local effciencyRedDots = redDots[redDotType.efficiency_level] or {} local has = table.contains(effciencyRedDots, rewardId) if has then return end local career_item_Counts = string.splitByAll(career_item_Count_Str, "|") for _, career_item_Count in ipairs(career_item_Counts) do local value = string.splitByAll(career_item_Count, "#") local career = tonumber(value[1]) local myCreer = getbaseinfo(actor, "getbasecareer") if myCreer == career then local itemCfgId = tonumber(value[2]) local itemCount = tonumber(value[3]) additemtobag(actor, itemCfgId, itemCount,0,9999,'效率') sendluamsg(actor, LuaMessageIdToClient.RES_EFFECIENCY_REWARD_RESULT, { id = rewardId, itemId = itemCfgId, count = itemCount }) break end end if msgData.type then -- 保存红点信息 Efficiency.SaveReDot(actor, msgData) end end -- 校验红点 function Efficiency.CheckRedDot(actor, level) level = level or getbaseinfo(actor, "level") local msg = {} msg[redDotType.efficiency] = {} msg[redDotType.efficiency_level] = {} local redDots = getplaydef(actor, "T$redDots") or {} local efficiencyConfigs = ConfigDataManager.getList("cfg_efficiency") local effciencyRedDots = redDots[redDotType.efficiency] or {} for _, cfg in ipairs(efficiencyConfigs) do local cfgLevel = tonumber(cfg.level) if cfgLevel <= level then local group = ConfigDataManager.getTableValue("cfg_efficiency", "group", "id", tonumber(cfg.id)) local hasShowEffciency = array.contains(effciencyRedDots, tonumber(group)) if not hasShowEffciency then if not table.contains(msg[redDotType.efficiency], tonumber(group)) then table.insert(msg[redDotType.efficiency], tonumber(group)) end end end end local levelConfigs = ConfigDataManager.getList("cfg_efficiency_level") local effciencyLevelRedDots = redDots[redDotType.efficiency_level] or {} if table.isNullOrEmpty(effciencyLevelRedDots) then local minLevel = 9999999 local targetId = 1 for _, cfg in ipairs(levelConfigs) do local cfgLevel = tonumber(cfg.level) if cfgLevel <= level and minLevel > cfgLevel then minLevel = cfgLevel targetId = tonumber(cfg.id) end end msg[redDotType.efficiency_level]["currId"] = 0 msg[redDotType.efficiency_level]["targetId"] = tonumber(targetId) else local maxLevel = 0 local currId = 0 local nextId for _, id in ipairs(effciencyLevelRedDots) do local cfg = ConfigDataManager.getById("cfg_efficiency_level", id) if cfg then local cfgLevel = tonumber(cfg.level) if maxLevel < cfgLevel then maxLevel = cfgLevel currId = id nextId = cfg.nextid end end end msg[redDotType.efficiency_level]["currId"] = tonumber(currId) if nextId ~= nil and nextId ~= '' then msg[redDotType.efficiency_level]["targetId"] = tonumber(nextId) else msg[redDotType.efficiency_level]["targetId"] = 0 end end -- lg("红点:", msg) sendluamsg(actor, LuaMessageIdToClient.RES_EFFECIENCY_RED_DOT, msg) end function Efficiency.SaveReDot(actor, msgData) local type = msgData.type local redDots = getplaydef(actor, "T$redDots") or {} local redDot = redDots[type] or {} if type == redDotType.efficiency then -- 效率红点 local group = msgData.group if not table.contains(redDot, group) then table.insert(redDot, group) end redDots[type] = redDot elseif type == redDotType.efficiency_level then -- 等级红点 local id = msgData.id local currCfgLevel = ConfigDataManager.getTableValue("cfg_efficiency_level", "level", "id", id) local configs = ConfigDataManager.getList("cfg_efficiency_level") for _, cfg in ipairs(configs) do local cfgLevel = tonumber(cfg.level) if cfgLevel <= tonumber(currCfgLevel) and not table.contains(redDot, tonumber(cfg.id)) then table.insert(redDot, tonumber(cfg.id)) end end redDots[type] = redDot end setplaydef(actor, "T$redDots", redDots) -- 重新发送红点信息 Efficiency.CheckRedDot(actor) end function testactive1(actor) setplaydef(actor, "T$_PLAYER_MONTH_PRIVILEGE_DATA_KEY", {}) end function clearactive1(actor) setplaydef(actor, "T$effcicency_active", {}) end