1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- local schema = require "model.schema"
- local logger = require "logger"
- local stringify = require "stringify"
- local module_name = "red_point"
- local _M = schema.new(module_name)
- local REQUEST = {}
- local CMD = {}
- local MODULE = {}
- local THIS = {}
- local register_list = {
- -- require "model.draw",
- }
- local function func_ret(fname, character, args)
- local f = THIS[fname]
- if not f then
- logger.error("func_ret not fname:%s !!!", fname)
- return {errno = STD_ERR.COMMON_SYS_ERR}
- end
- local errno, ret = f(character, args)
- if errno ~= 0 then
- return {errno = errno}
- end
- ret = ret or {}
- ret.errno = 0
- return ret
- end
- function MODULE.list_request_interests() return REQUEST end
- function MODULE.list_command_interests() return CMD end
- -- TODO: 解析/升级模块数据 在这里把数据初始化好
- function MODULE.parse(character)
- end
- -- TODO: 侦听事件
- function MODULE.monitor(character)
- end
- -- TODO: 类似泰利的 prepare 接口
- function MODULE.launch(character)
- end
- -- TODO: 与客户端同步数据
- function MODULE.ready(character)
- end
- -- TODO: 玩家下线时的处理
- function MODULE.saybye(character)
- end
- function THIS.get_red_point_list(character)
- local list = {}
- for _, model in ipairs(register_list) do
- local f = model.get_red_point
- if f then
- local ok, p1, p2 = pcall(f, character)
- if ok then
- if p1 and p2 then
- table.insert(list, {id = p2, red = p1})
- end
- else
- logger.warn(p1)
- end
- end
- end
- return 0, {list = list}
- end
- function REQUEST.get_red_point_list(character)
- return func_ret("get_red_point_list", character)
- end
- return MODULE
|