presence.lua 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. local schema = require "model.schema"
  2. local skynet = require "skynet"
  3. local embattle = require "model.embattle"
  4. local module_fun = require "model.module_fun"
  5. -- local rankinglist
  6. local module_name = "presence"
  7. local _M = schema.new(module_name)
  8. local function update(character)
  9. if character.ban_rank ~= 0 then
  10. return
  11. end
  12. if character.level <= 1 then
  13. return
  14. end
  15. local power = embattle.battle_power(character)
  16. local data = {
  17. num = power,
  18. num2 = 0,
  19. role = module_fun.simple_role(character),
  20. }
  21. -- skynet.call(rankinglist, "lua", "update", RANKING_POWER, data)
  22. character.set_power(power)
  23. character.dispatch("power_update", power)
  24. end
  25. local MODULE = {}
  26. -- TODO: 解析/升级模块数据 在这里把数据初始化好
  27. function MODULE.parse(character)
  28. end
  29. -- TODO: 侦听事件
  30. function MODULE.monitor(character)
  31. end
  32. -- TODO: 类似泰利的 prepare 接口
  33. function MODULE.launch(character)
  34. -- rankinglist = skynet.localname(".rankinglist")
  35. end
  36. -- TODO: 玩家下线时的处理
  37. function MODULE.saybye(character)
  38. update(character)
  39. end
  40. -- TODO: 与客户端同步数据
  41. function MODULE.ready(character)
  42. skynet.fork(
  43. function()
  44. while(true) do
  45. update(character)
  46. skynet.sleep(100*60*3)
  47. end
  48. end
  49. )
  50. end
  51. return MODULE