| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- PrivilegeGift = {}
- local db_privilege_gift_buy_record = "T$_privilege_gift_buy_record" -- 角色特权礼包购买记录
- local function _rechargeType()
- return "21"
- end
- local function _playerDbKey()
- return "T$recharge_privilege_gift_data"
- end
- function PrivilegeGift.saveData(actor, giftId)
- end
- function PrivilegeGift.getData(actor)
- end
- function PrivilegeGift.CheckPrivilegeGift(actor)
- local configs = ConfigDataManager.getList("cfg_gift_preferential")
- local rechargeRecord = RechargeRecord.get(actor)
- local msg = {}
- for _, config in pairs(configs) do
- local giftId = config.id
- local result, endtime = PrivilegeGift.doCheck(actor, giftId, rechargeRecord, giftEndtimes)
- if result then
- table.insert(msg, { giftId = giftId, endtime = endtime })
- end
- end
- -- lg("特惠礼包检查:",msg)
- sendluamsg(actor, LuaMessageIdToClient.RES_PREFERENTIAL_BUTTON_PANEL_INFO, msg)
- end
- function PrivilegeGift.doCheck(actor, giftId, rechargeRecord, giftEndtimes)
- local nowSec = getbaseinfo(actor, "nowsec")
- local giftRecoed = rechargeRecord[giftId]
- if giftRecoed then
- return false, nil
- end
- local updateTime = false
- if giftEndtimes[tonumber(giftId)] and nowSec > giftEndtimes[tonumber(giftId)] then
- return false, nil
- elseif not giftEndtimes[tonumber(giftId)] then
- updateTime = true
- end
- local condition = ConfigDataManager.getTableValue("cfg_gift_preferential", "conditions", "id", giftId)
- if condition == '' then
- return false
- end
- local result = ConditionManager.Check(actor, condition)
- if result then
- local endtime
- if updateTime then
- local time = ConfigDataManager.getTableValue("cfg_gift_preferential", "time", "id", giftId)
- endtime = nowSec + tonumber(time) * oneHour
- giftEndtimes[tonumber(giftId)] = endtime
- else
- endtime = giftEndtimes[tonumber(giftId)]
- end
- return true, endtime
- end
- return false, nil
- end
- function checkgift(actor)
- PrivilegeGift.CheckPrivilegeGift(actor)
- end
- -- function PrivilegeGift.login(actor)
- -- local data = PrivilegeGift.getData(actor)
- -- end
- function PrivilegeGift.rechargeEvent(actor, cfg_recharge, count, amount, ext, outRewards)
- local giftId = cfg_recharge.parameter
- local cfg_PrivilegePack = ConfigDataManager.getById("cfg_PrivilegePack", giftId)
- gameDebug.assertTrue(table.notNullOrEmpty(cfg_PrivilegePack), "没有配置特权礼包", giftId)
- if not ConditionManager.Check(actor, cfg_PrivilegePack.conditionid) then
- tipinfo(actor, "购买条件不满足")
- return
- end
- -- 发放奖励,注意采用绑定的
- local tmp_rewardsArr = string.split(cfg_PrivilegePack.rewards, "|") string.toStringStringMap(cfg_PrivilegePack.rewards, "#", "|")
- local career = getbaseinfo(actor,"getbasecareer")
- local rewards = {}
- for _, item in pairs(tmp_rewardsArr) do
- local itemArr = string.split(item, "#")
- if #itemArr <= 2 or tonumber(itemArr[3]) == career then
- rewards[itemArr[1]] = itemArr[2]
- end
- end
- Bag.sendRewardsByBind(actor, rewards, "1", "特权礼包")
- -- 发放特权卡,发放并使用
- local privilegeItemArr = string.split(cfg_PrivilegePack.privilegecard, "#")
- PrivilegeMonth.usePrivilegeCard(actor, privilegeItemArr[1], privilegeItemArr[2]) -- 特权卡使用处理
- -- 记录使用状态
- -- PrivilegeGift.saveData(actor, giftId)
- end
- -- ------------------------------------------------------------- --
- --TODO 一定要放到文件最后
- EventListerTable.registerType("特权礼包", _rechargeType(), _playerDbKey())
- -- 注册登录事件
- -- LoginEventListerTable:eventLister("0", "特权礼包", PrivilegeGift.login)
- -- 礼包通用事件注册
- RechargeEventListerTable:eventLister(_rechargeType(), "特权礼包", PrivilegeGift.rechargeEvent)
|