CardShapeShiftInfo.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ---@class CardShapeShiftInfo @注释
  2. CardShapeShiftInfo = class()
  3. local this = CardShapeShiftInfo
  4. function this:ctor()
  5. end
  6. function this:Reset()
  7. end
  8. function this:Init()
  9. self:InitData()
  10. self:RegistMessages()
  11. end
  12. function this:InitData()
  13. end
  14. function this:RegistMessages()
  15. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_FSPREVIEW_LIST, self.RES_FSPREVIEW_LIST, self)
  16. end
  17. ---判断是否有满足条件拍脸图
  18. function this:LUA_EVENT_ENTER_MAP()
  19. self.needOpenUI = {}
  20. self.open_server_day = 0
  21. if SL:GetEnterRoleRes() and SL:GetEnterRoleRes().openServerTime then
  22. local defTime = os.time() - SL:GetEnterRoleRes().openServerTime / 1000
  23. if defTime > 0 then
  24. self.open_server_day = math.ceil(defTime / 86400)
  25. end
  26. end
  27. local level = SL:GetMetaValue("LEVEL")
  28. ---@type cfg_system_foreshow_column[]
  29. local cfg_system_foreshow = SL:GetConfigTable("cfg_system_foreshow")
  30. for i, v in pairs(cfg_system_foreshow) do
  31. local needShow = true
  32. if v.needLevel == 0 then
  33. needShow = false
  34. else
  35. if v.needLevel and v.needLevel > level then
  36. needShow = false
  37. end
  38. end
  39. if v.needDay == 0 then
  40. needShow = false
  41. else
  42. if needShow and ((v.needDay and v.needDay > self.open_server_day) or (v.endTime and v.endTime < self.open_server_day)) then
  43. --needShow = false
  44. end
  45. end
  46. if needShow and self.needShowPanel[v.id] then
  47. self.needOpenUI[#self.needOpenUI + 1] = v.id
  48. end
  49. end
  50. if #self.needOpenUI > 0 then
  51. GUI:CloseAllUIWithoutMainUI()
  52. local uiID = table.remove(self.needOpenUI, 1)
  53. local tbl = SL:GetConfig("cfg_system_foreshow", uiID)
  54. GUI:UIPanel_Open(tbl.screenName, nil, nil, uiID)
  55. end
  56. end
  57. function this:REFRESH_NEXT_CARD_SHAPE_UI()
  58. if self.needOpenUI and #self.needOpenUI > 0 then
  59. GUI:CloseAllUIWithoutMainUI()
  60. local uiID = table.remove(self.needOpenUI, 1)
  61. local tbl = SL:GetConfig("cfg_system_foreshow", uiID)
  62. GUI:UIPanel_Open(tbl.screenName, nil, nil, uiID)
  63. end
  64. end
  65. function this:RES_FSPREVIEW_LIST(_, message)
  66. self.needShowPanel = {}
  67. for i, v in pairs(message) do
  68. self.needShowPanel[v] = true
  69. end
  70. self:LUA_EVENT_ENTER_MAP()
  71. end
  72. ---@param pool TablePool
  73. function this:DeepCopy(t,pool)
  74. --local InTable = {};
  75. local function Func(t)
  76. if type(t) ~= "table" then
  77. return t;
  78. end
  79. local NewTable =pool and pool:Pop() or {}
  80. --InTable[t] = NewTable
  81. for k,v in pairs(t) do
  82. NewTable[Func(k)] = Func(v)
  83. end
  84. return setmetatable(NewTable, getmetatable(t))
  85. end
  86. return Func(t)
  87. end