add
This commit is contained in:
104
Assets/trCRM/upgradeRes4Dev/priority/lua/cfg/DBCfg.lua
Normal file
104
Assets/trCRM/upgradeRes4Dev/priority/lua/cfg/DBCfg.lua
Normal file
@@ -0,0 +1,104 @@
|
||||
--- - 管理数据配置
|
||||
do
|
||||
require("cfg.DBCfgTool")
|
||||
local bio2Int = NumEx.bio2Int;
|
||||
local int2Bio = NumEx.int2Bio;
|
||||
local db = {} -- 经过处理后的数据
|
||||
-- 数据的路径
|
||||
local upgradeRes = "/upgradeRes"
|
||||
if (CLCfgBase.self.isEditMode) then
|
||||
upgradeRes = "/upgradeRes4Publish";
|
||||
end
|
||||
local priorityPath = PStr.b():a(CLPathCfg.persistentDataPath):a("/"):a(CLPathCfg.self.basePath):a(upgradeRes):a("/priority/"):e();
|
||||
local cfgBasePath = PStr.b():a(priorityPath):a("cfg/"):e();
|
||||
local cfgWorldBasePath = PStr.b():a(priorityPath):a("worldMap/"):e();
|
||||
|
||||
-- 大地图
|
||||
local cfgMapPath = PStr.b():a(cfgWorldBasePath):e();
|
||||
|
||||
-- 全局变量定义
|
||||
local cfgCfgPath = PStr.b():a(cfgBasePath):a("DBCFCfgData.cfg"):e();
|
||||
|
||||
--local cfgGoodsPath = PStr.b():a(cfgBasePath):a("DBCFGoodsData.cfg"):e();
|
||||
|
||||
DBCfg = {};
|
||||
|
||||
-- 取得数据列表
|
||||
function DBCfg.getData(path)
|
||||
local dbMap = db[path];
|
||||
if (dbMap == nil) then
|
||||
--if (path == cfgRolePath) then
|
||||
--dbMap = DBCfgTool.getRoleData(cfgRolePath, cfgRoleLevPath);
|
||||
--elseif (path == cfgSkillPath) then
|
||||
-- dbMap = DBCfgTool.pubGetBaseAndLevData(cfgSkillPath, cfgSkillLevPath);
|
||||
if path == cfgMapCellPath then
|
||||
dbMap = DBCfgTool.pubGet4GIDLev(path);
|
||||
elseif path == cfgTalkingPath or path == cfgCarbonPath then
|
||||
local gidList;
|
||||
gidList, dbMap = DBCfgTool.pubGetList4GID(path);
|
||||
if path == cfgCarbonPath then
|
||||
gidList[0] = nil; -- 把新手剧情的移除
|
||||
end
|
||||
dbMap.list = gidList;
|
||||
else
|
||||
-- 其它没有特殊处理的都以ID为key(dbList:下标连续的列表, dbMap:以ID为key的luatable)
|
||||
local dbList = nil;
|
||||
dbList, dbMap = DBCfgTool.getDatas(path, true);
|
||||
|
||||
if path == cfgGoodsPath then
|
||||
-- 商品
|
||||
local list = {};
|
||||
local chlCode = getChlCode();
|
||||
for i,v in ipairs(dbList) do
|
||||
if true or v.Channel == chlCode then
|
||||
table.insert(list, v);
|
||||
end
|
||||
end
|
||||
table.sort(list, function(a, n)
|
||||
return bio2Int(a.ListOrder) < bio2Int(n.ListOrder)
|
||||
end)
|
||||
|
||||
dbList = list;
|
||||
end
|
||||
|
||||
-- ====================================
|
||||
dbMap.list = dbList;
|
||||
end
|
||||
db[path] = dbMap;
|
||||
end
|
||||
return dbMap;
|
||||
end
|
||||
|
||||
-- 取得常量配置
|
||||
function DBCfg.getConstCfg(...)
|
||||
local datas = DBCfg.getData(cfgCfgPath);
|
||||
if (datas == nil) then
|
||||
return nil
|
||||
end
|
||||
return datas[1];
|
||||
end
|
||||
|
||||
-- 常量配置
|
||||
GConstCfg = DBCfg.getConstCfg();
|
||||
|
||||
|
||||
--function DBCfg.getGoodsList()
|
||||
-- local datas = DBCfg.getData(cfgGoodsPath);
|
||||
-- if (datas == nil) then
|
||||
-- return nil
|
||||
-- end
|
||||
-- return datas.list;
|
||||
--end
|
||||
--
|
||||
--function DBCfg.getGoodsByID(id)
|
||||
-- local datas = DBCfg.getData(cfgGoodsPath);
|
||||
-- if (datas == nil) then
|
||||
-- return nil
|
||||
-- end
|
||||
-- return datas[id]
|
||||
--end
|
||||
--------------------------------------------------
|
||||
return DBCfg;
|
||||
end
|
||||
|
||||
--module("DBCfg", package.seeall)
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0717d0bade9a648d0b3cdff7015eb88e
|
||||
timeCreated: 1498220629
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
137
Assets/trCRM/upgradeRes4Dev/priority/lua/cfg/DBCfgTool.lua
Normal file
137
Assets/trCRM/upgradeRes4Dev/priority/lua/cfg/DBCfgTool.lua
Normal file
@@ -0,0 +1,137 @@
|
||||
--- - 管理数据配置
|
||||
do
|
||||
local mdb = {} -- 原始数据
|
||||
local mMaps4ID = {}
|
||||
|
||||
DBCfgTool = {};
|
||||
|
||||
-- 把json数据转成对象
|
||||
function DBCfgTool.getDatas(cfgPath, isParseWithID)
|
||||
local list = mdb[cfgPath];
|
||||
local map4ID = {};
|
||||
if (list == nil) then
|
||||
list = {};
|
||||
local _list = Utl.fileToObj(cfgPath);
|
||||
if (_list == nil or _list.Count < 2) then
|
||||
mdb[cfgPath] = list;
|
||||
return list, map4ID;
|
||||
end
|
||||
|
||||
local count = _list.Count;
|
||||
local n = 0;
|
||||
local keys = _list[0];
|
||||
local cellList = nil;
|
||||
local cell = nil;
|
||||
local value = 0;
|
||||
for i = 1, count - 1 do
|
||||
cellList = _list[i];
|
||||
n = cellList.Count;
|
||||
cell = {};
|
||||
for j = 0, n - 1 do
|
||||
value = cellList[j];
|
||||
if (type(value) == "number") then
|
||||
cell[keys[j]] = int2Bio(value);
|
||||
else
|
||||
cell[keys[j]] = value;
|
||||
end
|
||||
end
|
||||
if (isParseWithID) then
|
||||
map4ID[bio2Int(cell.ID)] = cell;
|
||||
end
|
||||
table.insert(list, cell);
|
||||
end
|
||||
mdb[cfgPath] = list;
|
||||
mMaps4ID[cfgPath] = map4ID;
|
||||
else
|
||||
map4ID = mMaps4ID[cfgPath];
|
||||
end
|
||||
return list, map4ID;
|
||||
end
|
||||
|
||||
-- 取得角色的数据
|
||||
function DBCfgTool.getRoleData(cfgRolePath, cfgRoleLevPath)
|
||||
local tmp, roleBaseData = DBCfgTool.getDatas(cfgRolePath, true);
|
||||
local roleLevData = DBCfgTool.getDatas(cfgRoleLevPath);
|
||||
local key = "";
|
||||
local gid = 0;
|
||||
local lev = 0;
|
||||
local heros = {};
|
||||
|
||||
local list = {}
|
||||
for i, v in pairs(roleLevData) do
|
||||
gid = bio2Int(v.GID);
|
||||
lev = bio2Int(v.Lev);
|
||||
key = joinStr( gid , "_" , lev);
|
||||
local m = {}
|
||||
m.base = roleBaseData[gid];
|
||||
m.vals = v;
|
||||
list[key] = m;
|
||||
if (m.base.IsHero and lev == 1) then
|
||||
table.insert(heros, m);
|
||||
end
|
||||
end
|
||||
list.heros = heros;
|
||||
|
||||
return list;
|
||||
end
|
||||
|
||||
-- 通用取得有base数据和lev数据的表
|
||||
function DBCfgTool.pubGetBaseAndLevData(baseDataPath, levDataPath)
|
||||
local tmp, baseData = DBCfgTool.getDatas(baseDataPath, true);
|
||||
local levData = DBCfgTool.getDatas(levDataPath);
|
||||
local key = "";
|
||||
local gid = 0;
|
||||
local lev = 0;
|
||||
|
||||
local list = {}
|
||||
for i, v in pairs(levData) do
|
||||
gid = bio2Int(v.GID);
|
||||
lev = bio2Int(v.Lev);
|
||||
key = joinStr(gid , "_" , lev);
|
||||
local m = {}
|
||||
m.base = baseData[gid];
|
||||
m.vals = v;
|
||||
list[key] = m;
|
||||
end
|
||||
return list;
|
||||
end
|
||||
|
||||
function DBCfgTool.pubGetList4GID(dataPath, gidKey)
|
||||
local datas, map = DBCfgTool.getDatas(dataPath, true);
|
||||
local gid;
|
||||
local m = {};
|
||||
local list = {}
|
||||
gidKey = gidKey or "GID";
|
||||
for i, v in ipairs(datas) do
|
||||
gid = bio2Int(v[gidKey]);
|
||||
list = m[gid];
|
||||
if(list == nil) then
|
||||
list = {};
|
||||
end
|
||||
table.insert(list, v);
|
||||
m[gid] = list;
|
||||
end
|
||||
return m, map;
|
||||
end
|
||||
|
||||
function DBCfgTool.pubGet4GIDLev(dataPath)
|
||||
local datas = DBCfgTool.getDatas(dataPath);
|
||||
local gid;
|
||||
local lev;
|
||||
local key = "";
|
||||
local m = {};
|
||||
local list = {}
|
||||
local count = 0;
|
||||
for i, v in pairs(datas) do
|
||||
gid = bio2Int(v.GID);
|
||||
lev = bio2Int(v.Lev);
|
||||
key = PStr.b():a(tostring(gid)):a("_"):a(tostring(lev)):e();
|
||||
m[key] = v;
|
||||
end
|
||||
return m;
|
||||
end
|
||||
|
||||
return DBCfgTool;
|
||||
end
|
||||
|
||||
--module("DBCfgTool", package.seeall)
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6457f755fc2741d9a635ac10132247e
|
||||
timeCreated: 1498220629
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user