ReinAttrProxy.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local ReinAttrProxy = class("ReinAttrProxy", RemoteProxy)
  3. ReinAttrProxy.NAME = global.ProxyTable.ReinAttrProxy
  4. local cjson = require("cjson")
  5. function ReinAttrProxy:ctor()
  6. ReinAttrProxy.super.ctor(self)
  7. self.m_nBonusPoint = nil
  8. self._data = {}
  9. self._nData = {} -- 新版各属性加点数据
  10. self._isNewBouns = false -- 是否启用新版
  11. self._bounsConfig = {} -- 新版属性点配置表
  12. end
  13. function ReinAttrProxy:RespReinData(msg)
  14. local jsonData = ParseRawMsgToJson(msg)
  15. if not jsonData then
  16. return false
  17. end
  18. -- dump(jsonData)
  19. self._data = jsonData
  20. self.m_nBonusPoint = jsonData.m_nBonusPoint
  21. global.Facade:sendNotification(global.NoticeTable.Player_Rein_Attr_Change)
  22. SLBridge:onLUAEvent(LUA_EVENT_REIN_ATTR_CHANGE)
  23. end
  24. function ReinAttrProxy:ResAddReinAttr(data, m_nBonusPoint)
  25. local jsonStr = cjson.encode(data)
  26. if not jsonStr then
  27. return nil
  28. end
  29. LuaSendMsg(global.MsgType.MSG_CS_REIN_ATTR_CONFIRM, m_nBonusPoint, 0, 0, 0, jsonStr, string.len(jsonStr))
  30. end
  31. function ReinAttrProxy:GetData()
  32. return self._data
  33. end
  34. function ReinAttrProxy:GetBonusAbilData()
  35. return self._data.BonusAbil
  36. end
  37. function ReinAttrProxy:GetBonusTickData()
  38. return self._data.BonusTick
  39. end
  40. function ReinAttrProxy:GetNakedAbilData()
  41. return self._data.NakedAbil
  42. end
  43. function ReinAttrProxy:GetAdjustAbilData()
  44. return self._data.m_AdjustAbil
  45. end
  46. function ReinAttrProxy:GetBonusPoint()
  47. return self.m_nBonusPoint
  48. end
  49. ------------------------------------- 新版 --------------------------------
  50. function ReinAttrProxy:SetIsNewBouns(value)
  51. self._isNewBouns = value == true
  52. end
  53. function ReinAttrProxy:IsNewBouns()
  54. return self._isNewBouns
  55. end
  56. function ReinAttrProxy:LoadConfig()
  57. local GameConfigMgrProxy = global.Facade:retrieveProxy(global.ProxyTable.GameConfigMgrProxy)
  58. self._bounsConfig = GameConfigMgrProxy:getConfigByKey("cfg_bonus") or {}
  59. end
  60. function ReinAttrProxy:GetConfig()
  61. return self._bounsConfig
  62. end
  63. function ReinAttrProxy:GetNewAddData()
  64. return self._nData
  65. end
  66. function ReinAttrProxy:GetNewAddPointsById(id)
  67. if not self._nData or not id then
  68. return 0
  69. end
  70. for _, data in ipairs(self._nData) do
  71. if data.id == id then
  72. return data.value or 0
  73. end
  74. end
  75. return 0
  76. end
  77. function ReinAttrProxy:RespAddAttrData(msg)
  78. local msgHdr = msg:GetHeader()
  79. self.m_nBonusPoint = msgHdr.recog
  80. local jsonData = ParseRawMsgToJson(msg)
  81. if jsonData then
  82. dump(jsonData, "______RespAddAttrData")
  83. self._nData = jsonData
  84. end
  85. SLBridge:onLUAEvent(LUA_EVENT_REIN_ATTR_CHANGE)
  86. end
  87. function ReinAttrProxy:RequestAddReinAttr_N(data, m_nBonusPoint)
  88. local jsonStr = cjson.encode(data)
  89. if not jsonStr then
  90. return nil
  91. end
  92. print(jsonStr, "_____RequestAddReinAttr_N")
  93. LuaSendMsg(global.MsgType.MSG_CS_ADD_ATTR_CONFIRM, m_nBonusPoint, 0, 0, 0, jsonStr, string.len(jsonStr))
  94. end
  95. ---------------------------------------------------------------------------
  96. function ReinAttrProxy:RegisterMsgHandler()
  97. ReinAttrProxy.super.RegisterMsgHandler(self)
  98. local msgType = global.MsgType
  99. LuaRegisterMsgHandler( msgType.MSG_SC_REIN_ATTR_RESPONSE, handler(self, self.RespReinData))
  100. LuaRegisterMsgHandler( msgType.MSG_SC_ADD_ATTR_RESPONSE, handler(self, self.RespAddAttrData))
  101. end
  102. return ReinAttrProxy