LevelReward_1.lua 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. LevelReward ={}
  2. local this = {}
  3. LevelReward.var ={
  4. HAD_RECEIVE_REWARD = "T$hadreceivereward",
  5. SERVER_LIMIT_LEVEL_REWARD = "R$serverlimitlevelreward"
  6. }
  7. --活动是否开启
  8. function LevelReward.isActivityOpen(actor)
  9. local config = ConfigDataManager.getTable("sub_mainActivity","id",7)
  10. if config == nil then
  11. return false
  12. end
  13. return ConditionManager.Check(actor, config[1].actualcondition)
  14. end
  15. --是否页签关闭后的第一天
  16. function LevelReward.tableOpen(actor)
  17. local config = ConfigDataManager.getTable("sub_mainActivity","id",7)
  18. if config == nil then
  19. return nil
  20. end
  21. if config then
  22. local condition = config[1].showcondition
  23. local map = string.putIntIntMap({},condition,"#","&")
  24. local time = map[903]
  25. local serverOpenDays = getbaseinfo(actor, "serveropendays")
  26. if time + 1 == tonumber(serverOpenDays) then
  27. return true
  28. end
  29. end
  30. return nil
  31. end
  32. function LevelReward.login(actor)
  33. LevelReward.getLevelRewardInfo(actor)
  34. end
  35. ---请求当前已领取信息
  36. function LevelReward.getLevelRewardInfo(actor)
  37. if not LevelReward.isActivityOpen(actor) then
  38. return
  39. end
  40. local result = {}
  41. local rewardInfo = getplaydef(actor,LevelReward.var.HAD_RECEIVE_REWARD) or {}
  42. result.personInfo = rewardInfo
  43. local serverInfo = getsysvar(LevelReward.var.SERVER_LIMIT_LEVEL_REWARD)
  44. if not serverInfo then
  45. setsysvar(LevelReward.var.SERVER_LIMIT_LEVEL_REWARD,{})
  46. serverInfo = getsysvar(LevelReward.var.SERVER_LIMIT_LEVEL_REWARD)
  47. end
  48. result.serverInfo = serverInfo
  49. sendluamsg(actor,LuaMessageIdToClient.RES_PERSONAL_LEVEL_REWARD_INFO,table.valueConvertToString(result))
  50. end
  51. --请求领取等级奖励
  52. function LevelReward.receiveLevelReward(actor,msgData)
  53. local id = msgData.id
  54. callonserial(actor, "level_reward_receive", id)
  55. end
  56. function level_reward_receive(actor,id)
  57. -- local config = ConfigDataManager.getTable("cfg_activity_levelUp","id",id)
  58. -- if config == nil then
  59. -- return
  60. -- end
  61. -- local level = getbaseinfo(actor,"level")
  62. -- local cfgLv = config[1].level
  63. -- if tonumber(level) < tonumber(cfgLv) then
  64. -- tipinfo(actor,"等级不足!")
  65. -- return
  66. -- end
  67. -- local reward = {}
  68. -- local rewardInfo = getplaydef(actor,LevelReward.var.HAD_RECEIVE_REWARD) or {}
  69. -- local result = rewardInfo[tostring(id)] or {}
  70. -- if not result.basicItem then
  71. -- --增加限量判定
  72. -- local limitNum= config[1].places
  73. -- if not (limitNum == nil or limitNum == "" or limitNum == "0") then
  74. -- local nowInfo = getsysvar(LevelReward.var.SERVER_LIMIT_LEVEL_REWARD) or {}
  75. -- local nowNum = nowInfo[tostring(id)] or 0
  76. -- if nowNum >= tonumber(limitNum) then
  77. -- tipinfo(actor,"已达到领取上限!")
  78. -- return
  79. -- else
  80. -- nowNum = nowNum + 1
  81. -- nowInfo[tostring(id)] = nowNum
  82. -- setsysvar(LevelReward.var.SERVER_LIMIT_LEVEL_REWARD,nowInfo)
  83. -- end
  84. -- end
  85. -- string.putIntIntMap(reward,config[1].basicitem,"#","|")
  86. -- result.basicItem = true
  87. -- end
  88. -- if not result.specialItem then
  89. -- local condition = config[1].conditions
  90. -- if ConditionManager.Check(actor,condition) then
  91. -- string.putIntIntMap(reward,config[1].specialitem,"#","|")
  92. -- result.specialItem = true
  93. -- else
  94. -- result.specialItem = false
  95. -- end
  96. -- end
  97. -- --发奖励
  98. -- if table.count(reward) == 0 then
  99. -- return
  100. -- end
  101. -- for itemCfgId, count in pairs(reward) do
  102. -- additemtobag(actor, itemCfgId, count,0,9999,'等级奖励')
  103. -- end
  104. -- --奖励弹框
  105. -- sendluamsg(actor, LuaMessageIdToClient.COMMON_REWARD_PANEL, reward)
  106. -- rewardInfo[tostring(id)] = result
  107. -- setplaydef(actor,LevelReward.var.HAD_RECEIVE_REWARD,rewardInfo)
  108. -- --通知客户端
  109. -- sendluamsg(actor,LuaMessageIdToClient.RES_RECEIVE_LEVEL_REWARD,table.valueConvertToString(rewardInfo))
  110. -- LevelReward.getLevelRewardInfo(actor)
  111. end
  112. --活动结束时发放所有奖励
  113. function LevelReward.sendAllReward()
  114. -- local nowInfo = getsysvar(LevelReward.var.SERVER_LIMIT_LEVEL_REWARD)
  115. -- if nowInfo == nil or nowInfo == "" then
  116. -- return
  117. -- end
  118. -- local allRoleInfos = getallrolesummaryinfos()
  119. -- if allRoleInfos == nil or next(allRoleInfos) == nil then
  120. -- return
  121. -- end
  122. -- local tab = ConfigDataManager.getTable("cfg_activity_levelUp")
  123. -- for _, roleInfo in pairs(allRoleInfos) do
  124. -- local reward = {}
  125. -- local actor = roleInfo["actor"]
  126. -- if not LevelReward.tableOpen(actor) then
  127. -- return
  128. -- end
  129. -- local hadReward = getplaydef(actor, LevelReward.var.HAD_RECEIVE_REWARD) or {}
  130. -- if hadReward.lastReward then
  131. -- return
  132. -- end
  133. -- for i = 1,#tab,1 do
  134. -- local config = tab[i]
  135. -- local level = getbaseinfo(actor,"level")
  136. -- local id = config.id
  137. -- local cfgReward = hadReward[tostring(id)] or {}
  138. -- if table.count(cfgReward) > 0 then
  139. -- if cfgReward.specialItem == false and ConditionManager.Check(actor,config.conditions) then
  140. -- string.putIntIntMap(reward, config.specialitem)
  141. -- cfgReward.specialItem = true
  142. -- end
  143. -- hadReward[tostring(id)] = cfgReward
  144. -- else
  145. -- local cfgLv = config.level
  146. -- if tonumber(level) >= tonumber(cfgLv) then
  147. -- --判断限定数量
  148. -- local limitNum= config.places
  149. -- if not (limitNum == nil or limitNum == "" or limitNum == "0") then
  150. -- local nowNum = nowInfo[tostring(config.id)] or 0
  151. -- if nowNum < tonumber(limitNum) then
  152. -- nowNum = nowNum + 1
  153. -- nowInfo[tostring(config.id)] = nowNum
  154. -- setsysvar(LevelReward.var.SERVER_LIMIT_LEVEL_REWARD,nowInfo)
  155. -- string.putIntIntMap(reward, config.basicitem)
  156. -- cfgReward.basicItem = true
  157. -- if ConditionManager.Check(actor,config.conditions) then
  158. -- string.putIntIntMap(reward, config.specialitem)
  159. -- cfgReward.specialitem = true
  160. -- end
  161. -- end
  162. -- else
  163. -- string.putIntIntMap(reward, config.basicitem)
  164. -- cfgReward.basicItem = true
  165. -- if ConditionManager.Check(actor,config.conditions) then
  166. -- string.putIntIntMap(reward, config.specialitem)
  167. -- cfgReward.specialitem = true
  168. -- end
  169. -- end
  170. -- end
  171. -- end
  172. -- end
  173. -- --发邮件
  174. -- if table.count(reward) > 0 then
  175. -- sendconfigmailbyrid(actor,getbaseinfo(actor,"rid"), MailConfig.END_TIME_LEVEL_REWARD, reward, "")
  176. -- end
  177. -- hadReward.lastReward = true
  178. -- setplaydef(actor, LevelReward.var.HAD_RECEIVE_REWARD,hadReward)
  179. -- end
  180. -- setsysvar(LevelReward.var.SERVER_LIMIT_LEVEL_REWARD,nil)
  181. -- jprint("补发等级奖励邮件结束")
  182. end