RoleOpenPrize.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. local RoleSystemExcel = require("excel.roleSystem")
  2. local Msg = require("core.Msg")
  3. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  4. local CommonDefine = require("common.CommonDefine")
  5. local Grid = require("bag.Grid")
  6. local BagLogic = require("bag.BagLogic")
  7. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  8. local function RoleSystem_InitPrizeDB(human)
  9. human.db.roleSystemPrize = {}
  10. for id, conf in pairs(RoleSystemExcel.roleSystem) do
  11. if conf.isdisplay == 1 then
  12. human.db.roleSystemPrize[id] = CommonDefine.COMMON_PRIZE_STATE_NOGET
  13. end
  14. end
  15. end
  16. function RoleSystem_CheckPrize(human)
  17. if not human.db.roleSystemPrize then
  18. RoleSystem_InitPrizeDB(human)
  19. end
  20. local bSendDot = false
  21. for id, conf in pairs(RoleSystemExcel.roleSystem) do
  22. if conf.isdisplay == 1 then
  23. if not human.db.roleSystemPrize[id] then
  24. human.db.roleSystemPrize[id] = CommonDefine.COMMON_PRIZE_STATE_NOGET
  25. end
  26. if true == RoleSystemLogic.isOpen(human,conf.id) then
  27. local nState = human.db.roleSystemPrize[id]
  28. if CommonDefine.COMMON_PRIZE_STATE_NOGET == nState then
  29. human.db.roleSystemPrize[id] = CommonDefine.COMMON_PRIZE_STATE_CANGET
  30. bSendDot = true
  31. end
  32. end
  33. end
  34. end
  35. if true == bSendDot then
  36. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_110)
  37. end
  38. end
  39. function RoleSystem_QueryPrize(human)
  40. if not human.db.roleSystemPrize then
  41. RoleSystem_InitPrizeDB(human)
  42. end
  43. local tMsgData = Msg.gc.GC_ROLESYSTEM_PRIZE_QUERY
  44. tMsgData.tList[0] = 0
  45. local nLen = 0
  46. for id, conf in pairs(RoleSystemExcel.roleSystem) do
  47. if conf.isdisplay == 1 then
  48. nLen = nLen + 1
  49. local tData = tMsgData.tList[nLen]
  50. tData.nID = id
  51. if not human.db.roleSystemPrize[id] then
  52. human.db.roleSystemPrize[id] = CommonDefine.COMMON_PRIZE_STATE_NOGET
  53. end
  54. tData.nStatus = human.db.roleSystemPrize[id]
  55. tData.tItemList[0] = #conf.reward
  56. for i, value in ipairs(conf.reward) do
  57. local tItemData = tData.tItemList[i]
  58. Grid.makeItem(tItemData, value[1], value[2])
  59. end
  60. end
  61. end
  62. tMsgData.tList[0] = nLen
  63. Msg.send(tMsgData, human.fd)
  64. print("[RoleSystem_QueryPrize] 下发活动预告奖励结束")
  65. end
  66. function RoleSystem_GetPrize(human)
  67. local tItem = {}
  68. for id, conf in pairs(RoleSystemExcel.roleSystem) do
  69. if conf.isdisplay == 1 then
  70. local nStatus = human.db.roleSystemPrize[id] or CommonDefine.COMMON_PRIZE_STATE_NOGET
  71. if CommonDefine.COMMON_PRIZE_STATE_CANGET == nStatus then
  72. for _, v in ipairs(conf.reward) do
  73. if not tItem[v[1]] then
  74. tItem[v[1]] = 0
  75. end
  76. tItem[v[1]] = tItem[v[1]] + v[2]
  77. end
  78. human.db.roleSystemPrize[id] = CommonDefine.COMMON_PRIZE_STATE_GET
  79. end
  80. end
  81. end
  82. if nil ~= _G.next(tItem) then
  83. local tGoods = {}
  84. for nID, nNum in pairs(tItem) do
  85. table.insert(tGoods, {nID, nNum})
  86. end
  87. BagLogic.addItemList(human, tItem, "rolesystemprize")
  88. RoleSystem_QueryPrize(human)
  89. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_110)
  90. end
  91. end
  92. function isDot(human)
  93. if not human.db.roleSystemPrize then
  94. return false
  95. end
  96. for id, conf in pairs(RoleSystemExcel.roleSystem) do
  97. if conf.isdisplay == 1 then
  98. if human.db.roleSystemPrize[id] and CommonDefine.COMMON_PRIZE_STATE_CANGET == human.db.roleSystemPrize[id] then
  99. return true
  100. end
  101. end
  102. end
  103. return false
  104. end