MailInfo.lua 806 Bytes
cc.exports.MailInfo = {}

local xml = require("core.utils.pl.xml")

local mail_hash = {};

--道具配置表信息
local function init()
    local configStr = cc.FileUtils:getInstance():getStringFromFile("res/config/mail.xml");
    local data = xml.parse(configStr, false, true);

    for k,v in pairs(data) do
        if k ~= "attr" and k ~= "tag" then
            local info = {};
            info.id = tonumber(v.attr.id);
            info.title = v.attr.title;
            info.writer = v.attr.writer;
            info.desc = string.gsub(v.attr.desc,"@br@","\n");
            info.item = v.attr.item;
            mail_hash[tostring(info.id)] = info;
        end
    end
end
init();

--通过ID获取邮件信息
function MailInfo.getMailInfo(id)
    return mail_hash[tostring(id)];
end

return MailInfo