1. 程式人生 > >資料讀取之key(多個欄位決定一個key),value模式

資料讀取之key(多個欄位決定一個key),value模式

-- isMaxLevel, updateStarDict, startLevel, endLevel 
function ShipService:getWeaponUpdateStarDictInner( shipDictId, weaponLevel, weaponIndex, need_levelmax_name )

    -- 取等級所在的段,
    -- 如果是該段的最大級,且星級達到,顯示下一段
    -- 否則顯示本段

    local updateStarDict =  DictManager.getWeaponUpdateStarDict( shipDictId, weaponIndex )

    local nextUpdateStarDict = DictManager.getWeaponUpdateStarDict( shipDictId, weaponIndex + 1 )

    local shipBreakBoolMap = {  Weapon_need_levelmax = "main_weapon_overfulfil",
        Secondaryweapon_need_levelmax = "vice_weapon_overfulfil",
        Ship_need_levelmax = "ship_body_overfulfil" }

    if weaponIndex == 15 and not ServerData.shipMap[ shipDictId ][ shipBreakBoolMap[need_levelmax_name] ] then
        nextUpdateStarDict = nil -- 未被突破
    end

    local minMax
    local startLevel
    local endLevel

    if not updateStarDict then
        minMax = LuaUtils.Split2( nextUpdateStarDict[ need_levelmax_name ], ","  )
        startLevel = tonumber( minMax[1] )
        endLevel = tonumber( minMax[2] )
        return false, nextUpdateStarDict, startLevel, endLevel
    end

    if not nextUpdateStarDict then
        minMax = LuaUtils.Split2( updateStarDict[ need_levelmax_name ], ","  )
        startLevel = tonumber( minMax[1] )
        endLevel = tonumber( minMax[2] )
        if weaponLevel > endLevel then
            return true, nil, nil, nil
        else
            return false, updateStarDict, startLevel, endLevel
        end

    end

    minMax = LuaUtils.Split2( updateStarDict[ need_levelmax_name ], ","  )
    startLevel = tonumber( minMax[1] )
    endLevel = tonumber( minMax[2] )

    --如果還有升級機會
    if weaponLevel >= startLevel and weaponLevel < endLevel  then  --處於前一階段
        return false, updateStarDict, startLevel, endLevel
    else -- 處於階段2
        minMax = LuaUtils.Split2( nextUpdateStarDict[ need_levelmax_name ], ","  )
        startLevel = tonumber( minMax[1] )
        endLevel = tonumber( minMax[2] )
        return false, nextUpdateStarDict, startLevel, endLevel
    end

end

注意這個,讀取下一個升級的資訊:local nextUpdateStarDict = DictManager.getWeaponUpdateStarDict( shipDictId, weaponIndex + 1 )  這樣武器等級+1,再配合船id,就可以得到下一個等級船的資訊。