-- 工具函数--第一象限 < 10000 < 第二象限 < 20000 < 第四象限 < 30000 < 第三象限 local AdvCommon = {} function AdvCommon.getIdByCr(c, r) local crId = math.abs(r) + math.abs(c) * 100 -- row + column * 100 if c < 0 then crId = crId + 10000 end if r < 0 then crId = crId + 20000 end return crId end function AdvCommon.getCrById(crId) local c = math.floor(crId % 10000 / 100) local r = crId % 100 local last = math.floor(crId / 10000) if last == 3 then c, r = -c, -r elseif last == 1 then c = -c elseif last == 2 then r = -r end return c, r end --检查 是否满足层数限制条件 -- if checktype == 1 then check value in range a=b else check value in array a=b=c function AdvCommon.checkIsIn(checkValue, checkType, checkRange) if not checkValue then return end if checkType == 1 then local limits = checkRange:toNumMap() for min, max in pairs(limits) do if checkValue >= min and checkValue <= max then return true end end else local limit = checkRange:toArray(true, "=") for _, _l in ipairs(limit) do if _l == checkValue then return true end end end end function AdvCommon.isEndless(chapterId) return math.floor(chapterId / 100) == 2 end function AdvCommon.getEndlessDataLv(chapterId, level) local chapterData = csvdb["adv_chapterCsv"][chapterId] if level > globalCsv.adv_endless_custom_layer then level = (level - globalCsv.adv_endless_custom_layer) % chapterData.limitlevel if level == 0 then level = chapterData.limitlevel end level = level + globalCsv.adv_endless_custom_layer end return level end return AdvCommon