NoviceGiftPack.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. NoviceGiftPack = {}
  2. NoviceGiftPack.__index = NoviceGiftPack
  3. local function _rechargeType()
  4. return "9"
  5. end
  6. function NoviceGiftPack.rechargeEvent(actor, cfg, count, amount, ext, outRewards)
  7. local cfg = ConfigDataManager.getById("cfg_Starterpack", cfg["parameter"])
  8. gameDebug.assertNil(cfg, "cfg_Starterpack表找不到配置:", cfg["parameter"])
  9. string.putIntIntMap(outRewards, cfg.rewards, "#", "|")
  10. end
  11. function NoviceGiftPack.reqAction(actor, type, action, reqParameter)
  12. if action == "panel" then
  13. NoviceGiftPack.sendPanel(actor, type, action)
  14. end
  15. end
  16. function NoviceGiftPack.zero(actor)
  17. NoviceGiftPack.sendPanel(actor, _rechargeType(), "panel")
  18. end
  19. function NoviceGiftPack.login(actor)
  20. NoviceGiftPack.sendPanel(actor, _rechargeType(), "panel")
  21. end
  22. function NoviceGiftPack.sendPanel(actor, type, action)
  23. local data = {}
  24. local list = ConfigDataManager.getList("cfg_Starterpack")
  25. for _, cfg in pairs(list) do
  26. if ConditionManager.Check(actor, cfg.condition) then
  27. -- 充值项
  28. local rechargeId = ConfigDataManager.getTableValue("cfg_recharge", "id", "parameter", cfg.id, "type", type)
  29. if not string.isNullOrEmpty(rechargeId) then
  30. table.insert(data, rechargeId)
  31. end
  32. end
  33. end
  34. if not table.isNullOrEmpty(data) then
  35. Recharge.resAction(actor, type, action, data)
  36. end
  37. end
  38. -- 注册请求消息监听
  39. EventListerTable.registerType("新手礼包", _rechargeType())
  40. ZeroEventListerTable:eventLister("0", "新手礼包", NoviceGiftPack.zero)
  41. LoginEventListerTable:eventLister("0", "新手礼包", NoviceGiftPack.login)
  42. RechargeMessageEventListerTable:eventLister(_rechargeType(), "新手礼包", NoviceGiftPack.reqAction)
  43. RechargeEventListerTable:eventLister(_rechargeType(), "新手礼包", NoviceGiftPack.rechargeEvent)