| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- --------------------------------
- -- 文件名 : QQBigShot.lua
- -- 文件说明 : QQ大咖相关
- -- 创建时间 : 2025/05/19
- -- 创建人 : FC
- --------------------------------
- local Msg = require("core.Msg")
- local Util = require("common.Util")
- local Grid = require("bag.Grid")
- local BagLogic = require("bag.BagLogic")
- local BuyLogic = require("topup.BuyLogic")
- local QQBigShouCong = require("excel.qqbigshot")
- local CommonDefine = require("common.CommonDefine")
- local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
- local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
- local tLvID2ConfID =
- {
- [1] = 3,
- [2] = 4,
- [3] = 1,
- [4] = 2,
- }
- local tNextLv =
- {
- [0] = 3,
- [3] = 4,
- [4] = 1,
- [1] = 2
- }
- ----------------------------------------- 内部处理开始 -------------------------------------
- -- 初始化玩家qq大咖数据
- local function QQBigShot_CreatDB(human)
- if not human.db.qqBigShot then
- human.db.qqBigShot = {}
- end
- human.db.qqBigShot = {
- nQQLv = 0,
- nResetTime = os.time(),
- tPrizeInfo = {
- --[[
- [nID] = { -- 可以用位运算,但是没必要
- [1] = 0/1/2 -- 首次
- [2] = 0/1/2 -- 免费
- }
- ]]
- }
- }
- local tPrize = human.db.qqBigShot.tPrizeInfo
- for nID, v in ipairs(QQBigShouCong.Sheet1) do
- if not tPrize[nID] then
- tPrize[nID] = {}
- end
- tPrize[nID][1] = CommonDefine.COMMON_PRIZE_STATE_NOGET
- tPrize[nID][2] = CommonDefine.COMMON_PRIZE_STATE_NOGET
- end
- end
- -- 设置玩家大咖等级
- local function QQBigShot_SetLv(human, nLv)
- human.db.qqBigShot.nQQLv = nLv
- end
- -- 获取玩家大咖等级
- local function QQBigShot_GetLv(human)
- return human.db.qqBigShot.nQQLv
- end
- -- 获取首次礼包状态
- local function QQBigShot_GetPrizeFirst(human, nID)
- return human.db.qqBigShot.tPrizeInfo[nID][1]
- end
- -- 设置首次礼包状态
- local function QQBigShot_SetPrizeFirst(human, nID, nValue)
- human.db.qqBigShot.tPrizeInfo[nID][1] = nValue
- end
- -- 获取周礼包状态
- local function QQBigShot_GetPrizeWeek(human, nID)
- return human.db.qqBigShot.tPrizeInfo[nID][2]
- end
- -- 设置首次礼包状态
- local function QQBigShot_SetPrizeWeek(human, nID, nValue)
- human.db.qqBigShot.tPrizeInfo[nID][2] = nValue
- end
- local function QQBigShot_CheckCreate(human)
- if human.db.qqBigShot then
- return
- end
- QQBigShot_CreatDB(human)
- end
- -- 重置对应等级的周礼包
- local function QQBigShot_ResetWeekPrize(human, nID)
- QQBigShot_SetPrizeWeek(human, nID, CommonDefine.COMMON_PRIZE_STATE_CANGET)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_109)
- end
- ----------------------------------------- 客户端请求开始 -------------------------------------
- -- 请求数据
- function QQBigShot_Query(human)
- QQBigShot_CheckCreate(human)
- local tMsgData = Msg.gc.GC_QQ_BIGSHOT_QUERY
- tMsgData.tItemData[0] = 0
- for nID, v in ipairs(QQBigShouCong.Sheet1) do
- tMsgData.tItemData[0] = tMsgData.tItemData[0] + 1
- local tPrizeInfo = tMsgData.tItemData[tMsgData.tItemData[0]]
- tPrizeInfo.nID = v.nValue
- tPrizeInfo.nFirstStatus = QQBigShot_GetPrizeFirst(human, nID)
- tPrizeInfo.nWeekStatus = QQBigShot_GetPrizeWeek(human, nID)
-
- tPrizeInfo.tFirstlist[0] = #v.tFirstPrize
- for nIndex, tGoods in ipairs(v.tFirstPrize) do
- local itemId = tGoods[1]
- local itemCnt = tGoods[2]
- Grid.makeItem(tPrizeInfo.tFirstlist[nIndex], itemId, itemCnt)
- end
- tPrizeInfo.tWeeklist[0] = #v.tWeekPrize
- for nIndex, tGoods in ipairs(v.tWeekPrize) do
- local itemId = tGoods[1]
- local itemCnt = tGoods[2]
- Grid.makeItem(tPrizeInfo.tWeeklist[nIndex], itemId, itemCnt)
- end
- end
- Msg.send(tMsgData, human.fd)
- end
- -- 请求领取数据
- function QQBigShot_GetPrize(human, nLv)
- nID = tLvID2ConfID[nLv]
- if not QQBigShouCong.Sheet1[nID] then
- return
- end
- local nNowLv = QQBigShot_GetLv(human)
- if nLv ~= nNowLv then
- print("[QQBigShot_GetPrize] 当前大咖等级不匹配 nLv = "..nLv.." nNowLv = "..nNowLv)
- return
- end
- local tConfig = QQBigShouCong.Sheet1[nID]
- local nFirstStatus = QQBigShot_GetPrizeFirst(human, nID)
- local nWeekStatus = QQBigShot_GetPrizeWeek(human, nID)
- local tGoods = {}
- if nFirstStatus == CommonDefine.COMMON_PRIZE_STATE_CANGET then
- QQBigShot_SetPrizeFirst(human, nID, CommonDefine.COMMON_PRIZE_STATE_GET)
- for _, v in ipairs(tConfig.tFirstPrize) do
- if not tGoods[v[1]] then
- tGoods[v[1]] = 0
- end
- tGoods[v[1]] = tGoods[v[1]] + v[2]
- end
- end
- if nWeekStatus == CommonDefine.COMMON_PRIZE_STATE_CANGET then
- QQBigShot_SetPrizeWeek(human, nID, CommonDefine.COMMON_PRIZE_STATE_GET)
- for _, v in ipairs(tConfig.tWeekPrize) do
- if not tGoods[v[1]] then
- tGoods[v[1]] = 0
- end
- tGoods[v[1]] = tGoods[v[1]] + v[2]
- end
- end
- if nil ~= _G.next(tGoods) then
- local tItem = {}
- for nGoodID, nGoodNum in pairs(tGoods) do
- table.insert(tItem, {nGoodID, nGoodNum})
- end
- BagLogic.addItemList(human, tItem, "qqbigshot")
- QQBigShot_Query(human)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_109)
- end
- end
- function QQBigShot_UpdateLv(human, nLv)
- QQBigShot_CheckCreate(human)
- local nOldLv = QQBigShot_GetLv(human)
- -- local nNextLv = tNextLv[nOldLv]
- -- if not nNextLv then
- -- print("[QQBigShot_UpdateLv] 不存在对应的下一等级的大咖等级 nOldLv = "..nOldLv)
- -- return
- -- end
- -- if nLv ~= nNextLv then
- -- print("[QQBigShot_UpdateLv] 要提升的等级和下一等级的配置不同 nOldLv = "..nOldLv.." nLv = "..nLv.." nNextLv = "..nNextLv)
- -- return
- -- end
- print("[QQBigShot_UpdateLv] 收到的nLv = "..nLv.." nOldLv = "..nOldLv)
- if nOldLv ~= nLv then
- local nID = tLvID2ConfID[nLv]
- if not nID then
- print("[QQBigShot_UpdateLv] 不正确的等级 nLv = "..nLv.." nOldLv = "..nOldLv)
- return
- end
- QQBigShot_SetLv(human, nLv)
- local nFirstStatus = QQBigShot_GetPrizeFirst(human, nID)
- if CommonDefine.COMMON_PRIZE_STATE_CANGET == nFirstStatus then
- QQBigShot_SetPrizeFirst(human, nID, CommonDefine.COMMON_PRIZE_STATE_CANGET)
- end
- QQBigShot_SetPrizeWeek(human, nID, CommonDefine.COMMON_PRIZE_STATE_CANGET)
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_109)
- QQBigShot_Query(human)
- end
- end
- ----------------------------------------- 外部调用开始 -------------------------------------
- function onLogin(human)
- QQBigShot_CheckCreate(human)
- local nLv = QQBigShot_GetLv(human)
- if 0 == nLv then
- return
- end
- local bRet = Util.isSameWeek(human.db.qqBigShot.nResetTime, os.time())
- if false == bRet then
- local nID = tLvID2ConfID[nLv]
- QQBigShot_ResetWeekPrize(human, nID)
- end
- end
- function updateDaily(human)
- onLogin(human)
- end
- function isDot(human)
- QQBigShot_CheckCreate(human)
-
- local bRet = false
- for nID, v in ipairs(QQBigShouCong.Sheet1) do
- local nFirstStatus = QQBigShot_GetPrizeFirst(human, nID)
- local nWeekStatus = QQBigShot_GetPrizeWeek(human, nID)
- if CommonDefine.COMMON_PRIZE_STATE_CANGET == nFirstStatus or CommonDefine.COMMON_PRIZE_STATE_CANGET == nWeekStatus then
- bRet = true
- break
- end
- end
- return bRet
- end
- function QQBigShot_HumanLoginHandle(human, nLv)
- print("[QQBigShot_HumanLoginHandle] 收到数据进行处理")
- if not human then
- print("[QQBigShot_HumanLoginHandle] 不存在对应的人物")
- return
- end
- if not human.db then
- print("[QQBigShot_HumanLoginHandle] 不存在对应的人物DB数据")
- return
- end
- if not nLv then
- print("[QQBigShot_HumanLoginHandle] 不存在对应的等级")
- return
- end
- QQBigShot_CheckCreate(human)
- print("[QQBigShot_HumanLoginHandle] 获取到nLv = "..nLv)
- QQBigShot_UpdateLv(human, nLv)
- end
- function QQBigShot_GMReset(human)
- local nOldLv = QQBigShot_GetLv(human)
- QQBigShot_CreatDB(human)
- QQBigShot_UpdateLv(human, nOldLv)
- end
|