| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- local AbsActExcel = require("excel.absAct")
- local Lang = require("common.Lang")
- local ObjHuman = require("core.ObjHuman")
- local Msg = require("core.Msg")
- local Broadcast = require("broadcast.Broadcast")
- local Grid = require("bag.Grid")
- local BagLogic = require("bag.BagLogic")
- local ItemDefine = require("bag.ItemDefine")
- local BuyLogic = require("topup.BuyLogic")
- local AbsActDefine = require("absAct.AbsActDefine")
- local AbsActLogic = require("absAct.AbsActLogic")
- local Log = require("common.Log")
- local YunYingLogic = require("yunying.YunYingLogic")
- ABS_ACT_ID = 9001
- --
- function initAfterHot()
-
- end
- --
- function isActive(human, YYInfo, funcConfig)
- return not isOpen(human, YYInfo, funcConfig)
- end
- --
- function isOpen(human, YYInfo, funcConfig)
- return AbsActLogic.isStarted(human, funcConfig.funcID)
- end
- --
- function isRed(human, YYInfo, funcConfig)
- return false
- end
- --
- function getLeftTime(human, YInfo, funcConfig)
- local ret, endTime, startTime = AbsActLogic.isStarted(human, ABS_ACT_ID)
- if ret == true then
- return endTime - os.time()
- else
- return 0
- end
- end
- function getNewHeroID(human)
- local startedFlag, endTime, startTime = AbsActLogic.isStarted(human, ABS_ACT_ID)
- if not startedFlag then return 0 end
- local absActConfig = AbsActExcel.absActivity[ABS_ACT_ID]
- if not absActConfig then return 0 end
- return absActConfig.icon
- end
- function getAndSendMsg(human, id, actId)
- local now = os.time()
- local startedFlag, endTime, startTime = AbsActLogic.isStarted(human, id)
- if not startedFlag then return end
- local absActConfig = AbsActExcel.absActivity[id]
- if not absActConfig then return end
- local absAct = human.db.absAct[id]
- if not absAct then return end
- local msgRet = Msg.gc.GC_ABS_NEWHERO
- msgRet.id = absActConfig.icon
- msgRet.startTime = startTime
- msgRet.endTime = endTime
- local index = 0
- for giftId, v in ipairs(AbsActExcel.absEva) do
- index = index + 1
- for j = 1, #v.reward do
- Grid.makeItem(msgRet.giftlist[index].item[j], v.reward[j][1], v.reward[j][2])
- end
- msgRet.giftlist[index].item[0] = #v.reward
- msgRet.giftlist[index].cnt = absAct.newheroCnt and absAct.newheroCnt[giftId] or 0
- msgRet.giftlist[index].id = giftId
- msgRet.giftlist[index].maxCnt = v.limit
- local buyID = v.buyID
- msgRet.giftlist[index].buyMsg[0] = 1
- if v.buyID == 0 then
- msgRet.giftlist[index].buyMsg[1] = {
- buyID = buyID,
- region = "zuanshi",
- cost = v.price,
- icon = 0,
- name = "",
- isFirst = 0,
- desc = "",
- doubleCnt = 0,
- actDoubleCnt = 0,
- useDoubleCnt = 0,
- buyCnt = 0,
- vipExp = 0,
- yuanjia = 0,
- zhekou = 0,
- }
- else
- BuyLogic.fontBuyItem(human, msgRet.giftlist[index].buyMsg[1], buyID)
- end
- end
- msgRet.giftlist[0] = index
- Msg.send(msgRet, human.fd)
- end
- function getgiftbybuyid(buyid)
- for giftId, v in ipairs(AbsActExcel.absEva) do
- if v.buyID == buyid then
- return giftId
- end
- end
- end
- function newheroGift(human, id, buyConf, isFirst, cnt)
- local state = AbsActLogic.isStarted(human, id)
- local absConfig = AbsActExcel.absActivity[id]
- if absConfig == nil or not state then return end
- -- 存在多个特惠礼包 同时 开放
- local giftid = getgiftbybuyid(buyConf.id)
- if not giftid then return end
- local config = AbsActExcel.absEva[giftid]
- if not config then return end
- AbsActLogic.checkAbsActClean(human, id)
- human.db.absAct[id].newheroCnt = human.db.absAct[id].newheroCnt or { }
- local nowBuyCnt = human.db.absAct[id].newheroCnt[giftid] or 0
- -- 判断是否达到购买上限
- if nowBuyCnt >= config.limit then
- Broadcast.sendErr(human, Lang.HERO_BAG_BUY_CAP_NO_CNT)
- return
- end
- -- 当金币购买之后超过最大金币时,不允许购买
- for j = 1, #config.reward do
- local itemID = config.reward[j][1]
- local itemCnt = config.reward[j][2]
- if itemID == ItemDefine.ITEM_JINBI_ID then
- if not ObjHuman.canAddJinbi(human, itemCnt) then
- return
- end
- end
- end
- -- 增加已购买次数
- human.db.absAct[id].newheroCnt[giftid] = nowBuyCnt + 1
- -- 发放物品
- -- local items = { }
- BagLogic.addItemList(human, config.reward, "newhero_reward")
- Broadcast.sendErr(human, Lang.ITEM_BUY_SUCCESS)
- AbsActLogic.actDetailQuery(human, id)
- end
- function giftBuy(human, giftid)
- local state = AbsActLogic.isStarted(human, ABS_ACT_ID)
- if state ~= true then return end
- local absConfig = AbsActExcel.absActivity[ABS_ACT_ID]
- if not absConfig then return end
- AbsActLogic.checkAbsActClean(human, ABS_ACT_ID)
- -- 存在多个特惠礼包 同时 开放
- local config = AbsActExcel.absEva[giftid]
- if config.buyID ~= 0 then return end
- -- 初始化已购买次数
- human.db.absAct[ABS_ACT_ID].newheroCnt = human.db.absAct[ABS_ACT_ID].newheroCnt or { }
- local nowBuyCnt = human.db.absAct[ABS_ACT_ID].newheroCnt[giftid] or 0
- -- 判断是否达到购买上限
- if nowBuyCnt >= config.limit then
- Broadcast.sendErr(human, Lang.HERO_BAG_BUY_CAP_NO_CNT)
- return
- end
- local itemID = ItemDefine.ITEM_ZUANSHI_ID
- local itemCnt = config.price
- if not BagLogic.checkItemCnt(human, itemID, itemCnt) then
- Broadcast.sendErr(human, Lang.COMMON_NO_ZUANSHI)
- return
- end
- -- 当金币购买之后超过最大金币时,不允许购买
- for j = 1, #config.reward do
- local itemID = config.reward[j][1]
- local itemCnt = config.reward[j][2]
- if itemID == ItemDefine.ITEM_JINBI_ID then
- if not ObjHuman.canAddJinbi(human, itemCnt) then
- return
- end
- end
- end
- BagLogic.delItem(human, itemID, itemCnt, "newhero_reward")
- -- 增加已购买次数
- human.db.absAct[ABS_ACT_ID].newheroCnt[giftid] = nowBuyCnt + 1
- -- 发放物品
- -- local items = { }
- BagLogic.addItemList(human, AbsActExcel.absEva[giftid].reward, "newhero_reward")
- Broadcast.sendErr(human, Lang.ITEM_BUY_SUCCESS)
- AbsActLogic.actDetailQuery(human, ABS_ACT_ID)
- end
- function updateDaily(human, id)
- if human.db.absAct[ABS_ACT_ID] then
- human.db.absAct[ABS_ACT_ID] = {}
- end
- local state = AbsActLogic.isStarted(human, ABS_ACT_ID)
- if state ~= true then
- human.db.drawCard.list[8] = {}
- end
- AbsActLogic.actDetailQuery(human, ABS_ACT_ID)
- end
|