Activity.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Activity = {}
  2. local this = {}
  3. function Activity.LogIn(actor)
  4. this.ResAllActivityInfo(actor)
  5. end
  6. -- @description 活动改变回包
  7. -- @param 玩家对象;活动id;1-开启,0-关闭
  8. -- @return
  9. function Activity.ActivityChange(actor, activityId, action)
  10. local open = tonumber(ConfigDataManager.getTableValue("cfg_activity_rule", "open", "id", activityId))
  11. if open == nil or open == 0 then
  12. return
  13. end
  14. if activityId == DuplicateType.ROLAND_SEIGE then
  15. if not RolandSeige.CanOpenActivity() then
  16. -- 罗兰峡谷未达到首次开启要求
  17. return
  18. end
  19. end
  20. local changeAct = getactivityinfo(activityId)
  21. local result = this.ActivityToMsg(changeAct)
  22. sendluamsg(actor, LuaMessageIdToClient.RES_ACTIVITY_CHANGE, result)
  23. end
  24. -- @description 发给客户端响应
  25. -- @param 玩家对象
  26. -- @return
  27. function this.ResAllActivityInfo(actor)
  28. local result = {}
  29. local allActivity = getallactivities()
  30. for index, value in ipairs(allActivity) do
  31. local activityId = value["activityid"]
  32. local open = tonumber(ConfigDataManager.getTableValue("cfg_activity_rule", "open", "id", activityId))
  33. if open == 1 then
  34. local innerData = this.ActivityToMsg(value)
  35. table.insert(result, innerData)
  36. end
  37. end
  38. sendluamsg(actor, LuaMessageIdToClient.RES_ACTIVITY_LIST, result)
  39. end
  40. function this.ActivityToMsg(activityInfo)
  41. local result = {}
  42. result["id"] = activityInfo["activityid"]
  43. result["open"] = activityInfo["open"]
  44. local leftTime
  45. if activityInfo["open"] then
  46. leftTime = activityInfo["closetime"]
  47. else
  48. leftTime = activityInfo["nextopentime"]
  49. end
  50. result["leftTime"] = tostring(leftTime)
  51. return result
  52. end