| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- --[[
- absAct[id] = {
- count = 1000
- reward[id] = {
- state = 1
- }
- }
- ]]
- local AbsActLogic = require("absAct.AbsActLogic")
- local AbsActExcel = require("excel.absAct")
- local BuyExcel = require("excel.buy")
- local Util = require("common.Util")
- local Msg = require("core.Msg")
- local Grid = require("bag.Grid")
- local BagLogic = require("bag.BagLogic")
- local BuyLogic = require("topup.BuyLogic")
- local ObjHuman = require("core.ObjHuman")
- local Lang = require("common.Lang")
- local Broadcast = require("broadcast.Broadcast")
- local YunYingLogic = require("yunying.YunYingLogic")
- TOTAL_REACH_TYPE_1 = 1 -- 高抽
- TOTAL_REACH_TYPE_2 = 2 -- 充值
- TOTAL_REACH_TYPE_3 = 3 -- 天命召唤
- TOTAL_REACH_TYPE_4 = 4 -- 钻石消耗
- function isOpen(human, YYInfo, funcConfig)
- local state, endTime, startTime = AbsActLogic.isStarted(human, funcConfig.funcID)
- if not state then return end
- local absAct = human.db.absAct[funcConfig.funcID]
- if absAct and absAct.dayCnt and absAct.dayCnt <= 0 and #absAct.item <= 0 then
- return false
- end
- return true, endTime, startTime
- end
- function isActive(human, YYInfo, funcConfig)
- return not isOpen(human, YYInfo, funcConfig)
- end
- local function fontDabiaoNet(db,net,config,id)
- net.id = id
- net.needCnt = config.needCnt
- net.desc = Util.format(config.desc, config.needCnt)
- net.state = db.reward and (db.reward[id] or 0) or 0
- local len = #config.item
- for i = 1,len do
- Grid.makeItem(net.item[i],config.item[i][1],config.item[i][2])
- end
- net.item[0] = len
- end
- function getAndSendMsg(human,id)
- -- 判断活动是否开起
- local state, endTime, starTime = AbsActLogic.isStarted(human, id)
- if not state then return end
- local absConfig = AbsActExcel.absActivity[id]
- if not absConfig then return end
- local absAct = human.db.absAct[id]
- if not absAct then
- return
- end
- local config = AbsActExcel.totalReach
- local msgRet = Msg.gc.GC_ABS_XS_REACH_QUERY
- msgRet.nowCnt = absAct.count or 0
- local len = #config
- local count = 0
- for i = 1,len do
- local v = config[i]
- if v.actId == absConfig.actId and v.mainId == id then
- count = count + 1
- local net = msgRet.dabiaoList[count]
- fontDabiaoNet(absAct,net,v,i)
- end
- end
- msgRet.dabiaoList[0] = count
- Msg.send(msgRet,human.fd)
- end
- -- 高抽
- function onDrawCard(human,funcID, parameter)
- changeReach(human,funcID,TOTAL_REACH_TYPE_1,parameter)
- end
- -- 天命
- function onTMDrawCard(human,funcID, parameter)
- changeReach(human,funcID,TOTAL_REACH_TYPE_3,parameter)
- end
- -- 充值
- function onCharge(human, parameter,funcID)
- changeReach(human,funcID,TOTAL_REACH_TYPE_2,parameter)
- end
- -- 消耗钻石
- function onDecZuanshi(human,funcID,parameter)
- changeReach(human,funcID,TOTAL_REACH_TYPE_4,parameter)
- end
- function changeReach(human,id,type,param)
- local absConfig = AbsActExcel.absActivity[id]
- if not absConfig then return end
- if type ~= absConfig.param[1] then
- return
- end
-
- AbsActLogic.checkAbsActClean(human, id)
- local absAct = human.db.absAct[id]
- if not absAct then
- return
- end
- --增加数量
- absAct.count = absAct.count or 0
- absAct.count = absAct.count + param
- absAct.reward = absAct.reward or {}
- local config = AbsActExcel.totalReach
- local len = #config
- for i = 1,len do
- if config[i].actId == absConfig.actId and config[i].mainId == id then
- -- 判断数量是否达标了
- if not absAct.reward[i] and absAct.count >= config[i].needCnt then
- absAct.reward[i] = 1
- end
- end
- end
- YunYingLogic.updateIcon(YYInfo[id], human)
- YunYingLogic.sendGroupUpdate(YYInfo[id], human, absConfig.panelID)
- end
- function getTotalReachReward(human,id,giftId)
- -- 判断活动是否开启
- local state, endTime, starTime = AbsActLogic.isStarted(human, id)
- if not state then return end
- local absConfig = AbsActExcel.absActivity[id]
- if not absConfig then return end
-
- AbsActLogic.checkAbsActClean(human, id)
- local absAct = human.db.absAct[id]
- if not absAct then
- return
- end
- -- 状态不为可领,返回
- absAct.reward = absAct.reward or {}
- if absAct.reward[giftId] ~= 1 then
- return
- end
- local config = AbsActExcel.totalReach[giftId]
- if config.mainId ~= id or config.actId ~= absConfig.actId then
- return
- end
- -- 设置状态为已领取
- absAct.reward[giftId] = 2
- -- 发奖励
- BagLogic.addItemList(human, config.item, "abs_totalReach")
- getAndSendMsg(human,id)
- YunYingLogic.updateIcon(YYInfo[id], human)
- YunYingLogic.sendGroupUpdate(YYInfo[id], human, absConfig.panelID)
- end
- function isRed(human, YYInfo, funcConfig)
- local state,endTime,starTime = AbsActLogic.isStarted(human, funcConfig.funcID)
- if not state then return end
- local absConfig = AbsActExcel.absActivity[funcConfig.funcID]
- local absAct = human.db.absAct[funcConfig.funcID]
- if not absAct then return end
-
- absAct.reward = absAct.reward or {}
- for k,v in pairs(absAct.reward) do
- if v == 1 then
- return true
- end
- end
- return false
- end
|