red_point.lua 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. local schema = require "model.schema"
  2. local logger = require "logger"
  3. local stringify = require "stringify"
  4. local module_name = "red_point"
  5. local _M = schema.new(module_name)
  6. local REQUEST = {}
  7. local CMD = {}
  8. local MODULE = {}
  9. local THIS = {}
  10. local register_list = {
  11. -- require "model.draw",
  12. }
  13. local function func_ret(fname, character, args)
  14. local f = THIS[fname]
  15. if not f then
  16. logger.error("func_ret not fname:%s !!!", fname)
  17. return {errno = STD_ERR.COMMON_SYS_ERR}
  18. end
  19. local errno, ret = f(character, args)
  20. if errno ~= 0 then
  21. return {errno = errno}
  22. end
  23. ret = ret or {}
  24. ret.errno = 0
  25. return ret
  26. end
  27. function MODULE.list_request_interests() return REQUEST end
  28. function MODULE.list_command_interests() return CMD end
  29. -- TODO: 解析/升级模块数据 在这里把数据初始化好
  30. function MODULE.parse(character)
  31. end
  32. -- TODO: 侦听事件
  33. function MODULE.monitor(character)
  34. end
  35. -- TODO: 类似泰利的 prepare 接口
  36. function MODULE.launch(character)
  37. end
  38. -- TODO: 与客户端同步数据
  39. function MODULE.ready(character)
  40. end
  41. -- TODO: 玩家下线时的处理
  42. function MODULE.saybye(character)
  43. end
  44. function THIS.get_red_point_list(character)
  45. local list = {}
  46. for _, model in ipairs(register_list) do
  47. local f = model.get_red_point
  48. if f then
  49. local ok, p1, p2 = pcall(f, character)
  50. if ok then
  51. if p1 and p2 then
  52. table.insert(list, {id = p2, red = p1})
  53. end
  54. else
  55. logger.warn(p1)
  56. end
  57. end
  58. end
  59. return 0, {list = list}
  60. end
  61. function REQUEST.get_red_point_list(character)
  62. return func_ret("get_red_point_list", character)
  63. end
  64. return MODULE