SevenLogin_1.lua 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. SevenLogin ={}
  2. local this = {}
  3. SevenLogin.var ={
  4. LOGIN_ACTIVITY_INFO = "T$loginactivityinfo",
  5. }
  6. --活动是否开启
  7. function SevenLogin.isActivityOpen(actor)
  8. local config = ConfigDataManager.getTable("sub_mainActivity","id",6)
  9. if config == nil then
  10. return false
  11. end
  12. return ConditionManager.Check(actor, config[1].actualcondition)
  13. end
  14. --页签是否开启
  15. function SevenLogin.tableOpen(actor)
  16. local config = ConfigDataManager.getTable("sub_mainActivity","id",6)
  17. if config == nil then
  18. return nil
  19. end
  20. if config then
  21. local condition = config[1].showcondition
  22. local map = string.putIntIntMap({},condition,"#","&")
  23. local time = map[903]
  24. local serverOpenDays = getbaseinfo(actor, "serveropendays")
  25. if time + 1 == tonumber(serverOpenDays) then
  26. return true
  27. end
  28. end
  29. return nil
  30. end
  31. function SevenLogin.login(actor)
  32. SevenLogin.updateLoginInfo(actor)
  33. end
  34. --玩家凌晨在线时需要更新一次
  35. function SevenLogin.midNightUpdate(actor)
  36. SevenLogin.updateLoginInfo(actor)
  37. end
  38. ---更新登录信息
  39. function SevenLogin.updateLoginInfo(actor)
  40. if not SevenLogin.isActivityOpen(actor) then
  41. return
  42. end
  43. local result = {}
  44. local rewardInfo = getplaydef(actor,SevenLogin.var.LOGIN_ACTIVITY_INFO)
  45. if not rewardInfo then
  46. rewardInfo = {}
  47. rewardInfo.countDay = 1
  48. rewardInfo.hadReceiveReward = {}
  49. rewardInfo.lastLoginTime = getbaseinfo("now")
  50. end
  51. --校验登录时间是否跨天
  52. local now = getbaseinfo("now")
  53. local lastLoginTime = rewardInfo.lastLoginTime
  54. if not TimeUtil.isSameDay4Millis(now, lastLoginTime) then
  55. rewardInfo.countDay = rewardInfo.countDay + 1
  56. rewardInfo.lastLoginTime = now
  57. end
  58. setplaydef(actor,SevenLogin.var.LOGIN_ACTIVITY_INFO,rewardInfo)
  59. --通知客户端
  60. result.countDay = rewardInfo.countDay
  61. result.hadReceiveReward = rewardInfo.hadReceiveReward
  62. sendluamsg(actor,LuaMessageIdToClient.RES_LOGIN_REWARD_INFO_CHANGE,result)
  63. end
  64. --请求领取登录奖励
  65. function SevenLogin.receiveLoginReward(actor,msgData)
  66. -- if not SevenLogin.isActivityOpen(actor) then
  67. -- tipinfo(actor,"活动未开启!")
  68. -- return
  69. -- end
  70. -- local id = msgData.id
  71. -- local config = ConfigDataManager.getTable("cfg_accumulateLogOn","id",id)
  72. -- if not config then
  73. -- return
  74. -- end
  75. -- local rewardInfo = getplaydef(actor,SevenLogin.var.LOGIN_ACTIVITY_INFO)
  76. -- if rewardInfo.countDay < tonumber(config[1].accumulateday) then
  77. -- tipinfo(actor, "登录天数不足!")
  78. -- return
  79. -- end
  80. -- if table.contains(rewardInfo.hadReceiveReward, tonumber(id)) then
  81. -- tipinfo(actor,"不要重复领取!")
  82. -- return
  83. -- end
  84. -- --发奖励
  85. -- local reward = string.putIntIntMap({},config[1].reward,"#","|")
  86. -- for itemCfgId, count in pairs(reward) do
  87. -- additemtobag(actor, itemCfgId, count, 0, 9999, '7日登录')
  88. -- end
  89. -- --奖励弹框
  90. -- sendluamsg(actor, LuaMessageIdToClient.COMMON_REWARD_PANEL, reward)
  91. -- table.insert(rewardInfo.hadReceiveReward,tonumber(id))
  92. -- setplaydef(actor,SevenLogin.var.LOGIN_ACTIVITY_INFO,rewardInfo)
  93. -- --通知客户端
  94. -- local result = {}
  95. -- result.countDay = rewardInfo.countDay
  96. -- result.hadReceiveReward = rewardInfo.hadReceiveReward
  97. -- sendluamsg(actor,LuaMessageIdToClient.RES_RECEIVE_LOGIN_REWARD,result)
  98. end
  99. --活动结束时邮件发放奖励
  100. function SevenLogin.sendReward()
  101. -- local allRoleInfos = getallrolesummaryinfos()
  102. -- if allRoleInfos == nil or next(allRoleInfos) == nil then
  103. -- return
  104. -- end
  105. -- for _, roleInfo in pairs(allRoleInfos) do
  106. -- local reward = {}
  107. -- local actor = roleInfo["actor"]
  108. -- if not SevenLogin.tableOpen(actor) then
  109. -- return
  110. -- end
  111. -- local rewardInfo = getplaydef(actor,SevenLogin.var.LOGIN_ACTIVITY_INFO)
  112. -- if rewardInfo == nil or rewardInfo == "" then
  113. -- rewardInfo = {}
  114. -- end
  115. -- local countDay = rewardInfo.countDay or 0
  116. -- if countDay > 0 then
  117. -- local config = ConfigDataManager.getTable("cfg_accumulateLogOn")
  118. -- for _, cfg in pairs(config) do
  119. -- if not table.contains(rewardInfo.hadReceiveReward, tonumber(cfg.id)) then
  120. -- if tonumber(cfg.accumulateday) <= countDay then
  121. -- string.putIntIntMap(reward, cfg.reward)
  122. -- end
  123. -- end
  124. -- end
  125. -- end
  126. -- if table.count(reward) > 0 then
  127. -- sendconfigmailbyrid(actor, getbaseinfo(actor, "rid"), MailConfig.END_TIME_LOGIN_REWARD, reward, "")
  128. -- end
  129. -- setplaydef(actor, SevenLogin.var.LOGIN_ACTIVITY_INFO, nil)
  130. -- end
  131. -- jprint("补发七日登录奖励邮件结束")
  132. end