NewFirstChargeLogic.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. -----------------------------------------------------------------
  2. -- 文件名 : NewFirstChargeLogic.lua
  3. -- 文件说明 : 新首充
  4. -- 创建时间 : 2025/1/22
  5. -- 创建人 : FC
  6. -----------------------------------------------------------
  7. local Msg = require("core.Msg")
  8. local Util = require("common.Util")
  9. local PresentExcel = require("excel.present")
  10. local Grid = require("bag.Grid")
  11. local BagLogic = require("bag.BagLogic")
  12. local Broadcast = require("broadcast.Broadcast")
  13. local PanelDefine = require("broadcast.PanelDefine")
  14. local ChatPaoMaLogic = require("chat.ChatPaoMaLogic")
  15. local YunYingLogic = require("yunying.YunYingLogic")
  16. local SceneHandler = require("scene.Handler")
  17. local ObjHuman = require("core.ObjHuman")
  18. local BuyLogic = require("topup.BuyLogic")
  19. local CommonDefine = require("common.CommonDefine")
  20. local NEWFIRST_CHARGE_TYPE1 = 1 -- 1元
  21. local NEWFIRST_CHARGE_TYPE2 = 2 -- 8元
  22. local NEWFIRST_CHARGE_TYPE3 = 3 -- 18元
  23. local tMoneyToType =
  24. {
  25. [1] = NEWFIRST_CHARGE_TYPE1,
  26. [8] = NEWFIRST_CHARGE_TYPE2,
  27. [18] = NEWFIRST_CHARGE_TYPE3,
  28. }
  29. local tBuyID2Speed =
  30. {
  31. [1] = 1,
  32. [8] = 2,
  33. [18] = 3,
  34. [6] = 1,
  35. [68] = 2,
  36. [98] = 3,
  37. }
  38. local NEWFIRST_DAY = 3 -- 奖励天数,策划也没配置,直接写死吧
  39. local OPENNEWLV = 12 -- 等级9开
  40. -- 状态
  41. NEWFIRST_STATE_CANT_GET = 0 -- 不可领
  42. NEWFIRST_STATE_CAT_GET = 1 -- 可领
  43. NEWFIRST_STATE_HAD_GET = 2 -- 已领
  44. -- local tNewFirstChargeCof = nil -- 配置 Key = nBuyID
  45. -- local tPrizeDataByTypeDay = nil -- 具体奖励配置 [nType] = {[nDay] = v}
  46. local itemID2Type = {
  47. [92001] = 1,
  48. [92002] = 2,
  49. [92003] = 3,
  50. [92004] = 4,
  51. [92005] = 5,
  52. [92006] = 6,
  53. }
  54. -- 是否是正确的渠道
  55. local function isCorrectChanel(human)
  56. if not human then
  57. return false
  58. end
  59. if human.phpChanelID == CommonDefine.CHANNEL_TAG_MUZI or human.phpChanelID == CommonDefine.CHANNEL_TAG_SANLI_QQ then
  60. return true
  61. end
  62. return false
  63. end
  64. -- 是否使用新加的首充配置
  65. local function isUseNewCfg(human)
  66. if not isCorrectChanel(human) then
  67. return false
  68. end
  69. local newFirstChargeData = human.db.newFirstCharge
  70. -- 如果原来的首充礼包一个都没购买, 就只能购买新的首充礼包
  71. if not newFirstChargeData or not next(newFirstChargeData) then
  72. return true
  73. end
  74. local subNum = 0
  75. -- 如果购买了老的首充, 必须全部购买且领完, 才能开启下新夹首充礼包
  76. for i=NEWFIRST_CHARGE_TYPE1, NEWFIRST_CHARGE_TYPE3 do
  77. local data = newFirstChargeData[i]
  78. if data then
  79. for k = 1, NEWFIRST_DAY do
  80. if data.tDayStatus[k] ~= NEWFIRST_STATE_HAD_GET then
  81. return false
  82. end
  83. end
  84. subNum = subNum + 1
  85. end
  86. if i == NEWFIRST_CHARGE_TYPE3 and subNum > 0 and subNum < NEWFIRST_CHARGE_TYPE3 then
  87. return false
  88. end
  89. end
  90. return true
  91. end
  92. local function getFinalOffset(human)
  93. local startIdx, endIdx = NEWFIRST_CHARGE_TYPE1, NEWFIRST_CHARGE_TYPE3
  94. if isUseNewCfg(human) then
  95. startIdx = 4
  96. endIdx = 6
  97. end
  98. return startIdx, endIdx
  99. end
  100. local function getFinalType(nType, isUseNew)
  101. if isUseNew then
  102. nType = nType + 3
  103. end
  104. return nType
  105. end
  106. local function getNeedList(isNew)
  107. local startIdx, endIdx = 1, 3
  108. if isNew then
  109. startIdx, endIdx = 11, 13
  110. end
  111. local tNewFirstChargeCof = {}
  112. local tPrizeDataByTypeDay = {}
  113. -- for nID, tPrize in pairs(PresentExcel.newfirstcharge) do
  114. -- if type(tPrize) == "table" then
  115. -- --table.print_lua_table(tPrize)
  116. -- local nBuyID = tPrize.nBuyID
  117. -- tNewFirstChargeCof[nBuyID] = tPrize
  118. -- if tMoneyToType[tPrize.nMoney] then
  119. -- tNewFirstChargeCof[nBuyID].nType = tMoneyToType[tPrize.nMoney]
  120. -- else
  121. -- print("[getNeedList] 配置了不正确的金额 nMoney = "..tPrize.nMoney.." nID = "..nID)
  122. -- end
  123. -- else
  124. -- print("[getNeedList] tType = \n"..type(tPrize))
  125. -- end
  126. -- end
  127. for i = startIdx, endIdx do
  128. local singleCfg = PresentExcel.newfirstcharge[i]
  129. local nBuyID = singleCfg.nBuyID
  130. tNewFirstChargeCof[nBuyID] = singleCfg
  131. tNewFirstChargeCof[nBuyID].nType = itemID2Type[singleCfg.nBuyID]
  132. end
  133. for nID, tPrize in pairs(tNewFirstChargeCof) do
  134. local nType = tPrize.nType
  135. tPrizeDataByTypeDay[nType] = {}
  136. for i = 1, NEWFIRST_DAY, 1 do
  137. local tItem = i == 1 and tPrize.tPrize1 or ( i == 2 and tPrize.tPrize2 or tPrize.tPrize3)
  138. tPrizeDataByTypeDay[nType][i] = tItem
  139. end
  140. end
  141. return tNewFirstChargeCof, tPrizeDataByTypeDay
  142. end
  143. -- 初始化对应类型的DB类型数据
  144. local function NewFirstCharge_InitDBByType(human, nType)
  145. if not human.db.newFirstCharge then
  146. human.db.newFirstCharge = {}
  147. end
  148. human.db.newFirstCharge[nType] =
  149. {
  150. nBuyTime = 0,
  151. nSatus = NEWFIRST_STATE_CANT_GET,
  152. tDayStatus = {},
  153. }
  154. for i = 1, NEWFIRST_DAY, 1 do
  155. human.db.newFirstCharge[nType].tDayStatus[i] = NEWFIRST_STATE_CANT_GET
  156. end
  157. end
  158. -- 创建DB数据
  159. local function NewFirstCharge_CreateDB(human)
  160. if not human then
  161. return
  162. end
  163. if not human.db.newFirstCharge then
  164. human.db.newFirstCharge = {}
  165. end
  166. -- for i = NEWFIRST_CHARGE_TYPE1, NEWFIRST_CHARGE_TYPE3, 1 do
  167. -- if not human.db.newFirstCharge[i] then
  168. -- NewFirstCharge_InitDBByType(human, i)
  169. -- end
  170. -- end
  171. local startIdx, endIdx = getFinalOffset(human)
  172. for i = startIdx, endIdx do
  173. if not human.db.newFirstCharge[i] then
  174. NewFirstCharge_InitDBByType(human, i)
  175. end
  176. end
  177. --table.print_lua_table(human.db.newFirstCharge)
  178. print("[NewFirstCharge_CreateDB] \n")
  179. end
  180. -- 设置对应天数领取了奖励
  181. local function NewFirstCharge_SetPrizeStauts(human, nType, nDay, nValue)
  182. if not human.db.newFirstCharge or not human.db.newFirstCharge[nType] then
  183. return
  184. end
  185. human.db.newFirstCharge[nType].tDayStatus[nDay] = nValue
  186. end
  187. -- 获取对应类型对应天数奖励状态
  188. local function NewFirstCharge_GetPrizeStauts(human, nType, nDay)
  189. if not human.db.newFirstCharge or not human.db.newFirstCharge[nType] then
  190. return NEWFIRST_STATE_CANT_GET
  191. end
  192. --table.print_lua_table(human.db.newFirstCharge[nType])
  193. --print("\n")
  194. return human.db.newFirstCharge[nType].tDayStatus[nDay]
  195. end
  196. -- 设置购买状态
  197. local function NewFirstCharge_SetBuyStatus(human, nType)
  198. if not human.db.newFirstCharge then
  199. NewFirstCharge_InitDBByType(human, nType)
  200. end
  201. human.db.newFirstCharge[nType].nBuyTime = os.time()
  202. human.db.newFirstCharge[nType].nSatus = NEWFIRST_STATE_HAD_GET
  203. NewFirstCharge_SetPrizeStauts(human, nType, 1, NEWFIRST_STATE_CAT_GET)
  204. end
  205. -- 获取购买状态
  206. local function NewFirstCharge_GetBuyStatus(human, nType)
  207. if not human.db.newFirstCharge then
  208. NewFirstCharge_InitDBByType(human, nType)
  209. end
  210. return human.db.newFirstCharge[nType].nSatus
  211. end
  212. -- 设置时间
  213. local function NewFirstCharge_SetTime(human, nType, nTime)
  214. if not human.db.newFirstCharge then
  215. NewFirstCharge_InitDBByType(human, nType)
  216. end
  217. human.db.newFirstCharge[nType].nBuyTime = nTime
  218. end
  219. -- 获取时间
  220. local function NewFirstCharge_GetTime(human, nType)
  221. if not human.db.newFirstCharge then
  222. NewFirstCharge_InitDBByType(human, nType)
  223. end
  224. return human.db.newFirstCharge[nType].nBuyTime
  225. end
  226. local function isOpenByType(human,giftType)
  227. if not human.db.newFirstCharge or not human.db.newFirstCharge[giftType] then
  228. return true
  229. end
  230. -- 未购买,显示
  231. if NEWFIRST_STATE_CANT_GET == human.db.newFirstCharge[giftType].nSatus then
  232. return true
  233. end
  234. -- 购买了
  235. for nDay = 1, NEWFIRST_DAY, 1 do
  236. local nDayStatus = NewFirstCharge_GetPrizeStauts(human, giftType, nDay)
  237. -- 只要没领取,都是开启的
  238. if NEWFIRST_STATE_HAD_GET ~= nDayStatus then
  239. return true
  240. end
  241. end
  242. return false
  243. end
  244. -- 根据类型判断是否有红点
  245. local function isRedByType(human, giftType)
  246. if not human.db.newFirstCharge or not human.db.newFirstCharge[giftType] then
  247. return false
  248. end
  249. -- 未购买
  250. if NEWFIRST_STATE_CANT_GET == human.db.newFirstCharge[giftType].nSatus then
  251. return false
  252. end
  253. for i = 1, NEWFIRST_DAY, 1 do
  254. local nDayStatus = NewFirstCharge_GetPrizeStauts(human, giftType, i)
  255. if NEWFIRST_STATE_CAT_GET == nDayStatus then
  256. return true
  257. end
  258. end
  259. return false
  260. end
  261. function isOpen(human,YYInfo,funcConfig)
  262. if not SceneHandler.canCharge(human) then
  263. print("[NewFirstCharge- isOpen] 不能充值返回")
  264. return false
  265. end
  266. if OPENNEWLV > human.db.lv then
  267. print("[NewFirstCharge- isOpen] 等级不足 不够 lv = "..human.db.lv)
  268. return false
  269. end
  270. -- for i = NEWFIRST_CHARGE_TYPE1, NEWFIRST_CHARGE_TYPE3, 1 do
  271. -- if true == isOpenByType(human,i) then
  272. -- print("[NewFirstCharge- isOpen] 满足条件 ")
  273. -- return true
  274. -- end
  275. -- end
  276. local startIdx, endIdx = getFinalOffset(human)
  277. for i = startIdx, endIdx, 1 do
  278. if true == isOpenByType(human,i) then
  279. print("[NewFirstCharge- isOpen] 满足条件 ")
  280. return true
  281. end
  282. end
  283. print("[NewFirstCharge- isOpen] 不满足条件 ")
  284. return false
  285. end
  286. function isRed(human,YYInfo,funcConfig)
  287. -- for i = NEWFIRST_CHARGE_TYPE1, NEWFIRST_CHARGE_TYPE3, 1 do
  288. -- if true == isRedByType(human,i) then
  289. -- return true
  290. -- end
  291. -- end
  292. local startIdx, endIdx = getFinalOffset(human)
  293. for i = startIdx, endIdx, 1 do
  294. if true == isRedByType(human,i) then
  295. return true
  296. end
  297. end
  298. return false
  299. end
  300. function NewFirstCharge_Query(human, nType)
  301. local bl = isUseNewCfg(human)
  302. local tAllConf, tItemConfByType = getNeedList(bl)
  303. local tTypeConf = nil
  304. local finalType = getFinalType(nType, bl)
  305. for _, v in pairs(tAllConf) do
  306. if v.nType == finalType then
  307. tTypeConf = v
  308. break
  309. end
  310. end
  311. if not tTypeConf then
  312. print("[NewFirstCharge_Query] 不存在对应类型的配置 nType = "..finalType)
  313. return
  314. end
  315. if not human.db.newFirstCharge then
  316. NewFirstCharge_CreateDB(human)
  317. end
  318. local tMsgData = Msg.gc.GC_NEW_FIRST_CHARGE_QUERY
  319. tMsgData.nType = nType
  320. tMsgData.nState = NewFirstCharge_GetBuyStatus(human, finalType)
  321. print("[NewFirstCharge_Query] 购买状态 nSatus = "..tMsgData.nState)
  322. tMsgData.nMoney = tTypeConf.nMoney
  323. tMsgData.tRed[0] = NEWFIRST_CHARGE_TYPE3
  324. local len = 0
  325. local startIdx, endIdx = getFinalOffset(human)
  326. for i = startIdx, endIdx, 1 do
  327. len = len + 1
  328. tMsgData.tRed[len] = 0
  329. if true == isRedByType(human, i) then
  330. tMsgData.tRed[len] = 1
  331. end
  332. end
  333. BuyLogic.fontBuyItem(human, tMsgData.buyItem, tTypeConf.nBuyID)
  334. tMsgData.list[0] = 0
  335. for i = 1, NEWFIRST_DAY, 1 do
  336. tMsgData.list[0] = tMsgData.list[0] + 1
  337. local tNodeData = tMsgData.list[tMsgData.list[0]]
  338. tNodeData.nState = NewFirstCharge_GetPrizeStauts(human, finalType, i)
  339. print("[NewFirstCharge_Query] 奖励天数状态 nSatus = "..tNodeData.nState.." i = "..i)
  340. tNodeData.nDay = i
  341. tNodeData.item[0] = 0
  342. local tItemConf = tItemConfByType[finalType][i]
  343. if not tItemConf then
  344. print("[NewFirstCharge_Query] 居然不存在对应的奖励配置")
  345. else
  346. for _, v in ipairs(tItemConf) do
  347. tNodeData.item[0] = tNodeData.item[0] + 1
  348. Grid.makeItem(tNodeData.item[tNodeData.item[0]], v[1], v[2])
  349. if v[3] then
  350. tNodeData.item[tNodeData.item[0]].rare = v[3]
  351. end
  352. end
  353. end
  354. end
  355. Msg.send(tMsgData, human.fd)
  356. -- print("[NewFirstCharge_Query] 发送数据成功\n")
  357. -- if human.db.nSpeed and _G.next(human.db.nSpeed) then
  358. -- table.print_lua_table(human.db.nSpeed)
  359. -- end
  360. end
  361. function NewFirstCharge_Get(human, nType)
  362. local bl = isUseNewCfg(human)
  363. local tAllConf, tItemConfByType = getNeedList(bl)
  364. local tTypeConf = nil
  365. local finalType = getFinalType(nType, bl)
  366. for _, v in pairs(tAllConf) do
  367. if v.nType == finalType then
  368. tTypeConf = v
  369. break
  370. end
  371. end
  372. if not tTypeConf or not tItemConfByType[finalType] then
  373. print("[NewFirstCharge_Get] 不存在对应类型的配置 nType = "..finalType)
  374. return
  375. end
  376. local nMoney = tTypeConf.nMoney
  377. local bChange = false
  378. local tItems = {}
  379. for nDay, value in pairs(tItemConfByType[finalType]) do
  380. local nStatus = NewFirstCharge_GetPrizeStauts(human, finalType, nDay)
  381. if NEWFIRST_STATE_CAT_GET == nStatus then
  382. for _, v in pairs(value) do
  383. table.insert(tItems, v)
  384. end
  385. if nDay == 1 then
  386. bChange = true
  387. local nIndex = tBuyID2Speed[nMoney]
  388. if not human.db.nSpeed then
  389. human.db.nSpeed = {}
  390. end
  391. human.db.nSpeed[nIndex] = 1
  392. end
  393. NewFirstCharge_SetPrizeStauts(human, finalType, nDay, NEWFIRST_STATE_HAD_GET)
  394. end
  395. end
  396. if nil ~= _G.next(tItems) then
  397. BagLogic.addItemList(human, tItems, "shouchong")
  398. for k, v in pairs(funcID) do
  399. YunYingLogic.updateIcon(YYInfo[k], human)
  400. YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_3302)
  401. break
  402. end
  403. -- 如果购买了老的首充且全部领完, 开启新加的首充
  404. if isUseNewCfg(human) then
  405. NewFirstCharge_CreateDB(human)
  406. NewFirstCharge_GetPrice(human)
  407. end
  408. NewFirstCharge_Query(human, nType)
  409. if true == bChange then
  410. ObjHuman.sendHumanInfo(human)
  411. end
  412. end
  413. end
  414. -- 获取所有礼包价格
  415. function NewFirstCharge_GetPrice(human)
  416. local bl = isUseNewCfg(human)
  417. local tAllConf = getNeedList(bl)
  418. local len = 0
  419. local tMsgData = Msg.gc.GC_NEW_FIRST_PRIZE_QUERY
  420. local tbl = {}
  421. for _,v in pairs(tAllConf) do
  422. len = len + 1
  423. tbl[len] = v.nMoney
  424. end
  425. tMsgData.priceList[0] = len
  426. table.sort(tbl)
  427. for k, v in ipairs(tbl) do
  428. tMsgData.priceList[k] = v
  429. end
  430. Msg.send(tMsgData, human.fd)
  431. end
  432. -- 充值回调
  433. function onCharge(human, nBuyID)
  434. -- print("[NewFirstChargeLogic-onCharge] nBuyID = "..nBuyID)
  435. local bl = isUseNewCfg(human)
  436. local tConfByBuyid = getNeedList(bl)
  437. local isChange = false
  438. if tConfByBuyid[nBuyID] then
  439. --print("[onCharge] nType = ".. tConfByBuyid[nBuyID].nType.." nBuyID = "..nBuyID)
  440. NewFirstCharge_SetBuyStatus(human, tConfByBuyid[nBuyID].nType)
  441. isChange = true
  442. -- 客户端只传1 ~3
  443. local targetType = tConfByBuyid[nBuyID].nType
  444. if bl then
  445. targetType = targetType - 3
  446. end
  447. -- NewFirstCharge_Query(human, tConfByBuyid[nBuyID].nType)
  448. NewFirstCharge_Query(human, targetType)
  449. if IsBuyAllgift(human) then
  450. local CombatPosLogic = require("combat.CombatPosLogic")
  451. CombatPosLogic.sendAllCombatPos(human)
  452. end
  453. else
  454. print("[NewFirstChargeLogic-onCharge] 不存在对应的礼包id nBuyID = "..nBuyID)
  455. return
  456. end
  457. if isChange then
  458. for k, v in pairs(funcID) do
  459. print("[NewFirstChargeLogic - onCharge], k = "..k)
  460. YunYingLogic.updateIcon(YYInfo[k], human)
  461. break
  462. end
  463. end
  464. end
  465. function updateDaily(human, funcID)
  466. if human.db.newFirstCharge then
  467. local nNowTime = os.time()
  468. -- for i = NEWFIRST_CHARGE_TYPE1, NEWFIRST_CHARGE_TYPE3, 1 do
  469. -- local nBuyStatus = NewFirstCharge_GetBuyStatus(human, i)
  470. -- local nLastTime = NewFirstCharge_GetTime(human, i)
  471. -- local bIsDay = Util.isSameDayByTimes(nNowTime, nLastTime)
  472. -- -- 遍历该类型全部天数
  473. -- if NEWFIRST_STATE_HAD_GET == nBuyStatus and true ~= bIsDay then
  474. -- for nDay = 1, NEWFIRST_DAY, 1 do
  475. -- local nDayStatus = NewFirstCharge_GetPrizeStauts(human, i, nDay)
  476. -- -- 当天奖励未领取
  477. -- if NEWFIRST_STATE_CANT_GET == nDayStatus then
  478. -- NewFirstCharge_SetPrizeStauts(human, i, nDay, NEWFIRST_STATE_CAT_GET)
  479. -- NewFirstCharge_SetTime(human, i, nNowTime)
  480. -- print("[NewFirstChargeLogic - updateDaily] 隔天刷新 奖励 nType = "..i.." nDay = "..nDay)
  481. -- break
  482. -- end
  483. -- end
  484. -- end
  485. -- end
  486. local startIdx, endIdx = getFinalOffset(human)
  487. for i = startIdx, endIdx do
  488. local nBuyStatus = NewFirstCharge_GetBuyStatus(human, i)
  489. local nLastTime = NewFirstCharge_GetTime(human, i)
  490. local bIsDay = Util.isSameDayByTimes(nNowTime, nLastTime)
  491. -- 遍历该类型全部天数
  492. if NEWFIRST_STATE_HAD_GET == nBuyStatus and true ~= bIsDay then
  493. for nDay = 1, NEWFIRST_DAY, 1 do
  494. local nDayStatus = NewFirstCharge_GetPrizeStauts(human, i, nDay)
  495. -- 当天奖励未领取
  496. if NEWFIRST_STATE_CANT_GET == nDayStatus then
  497. NewFirstCharge_SetPrizeStauts(human, i, nDay, NEWFIRST_STATE_CAT_GET)
  498. NewFirstCharge_SetTime(human, i, nNowTime)
  499. print("[NewFirstChargeLogic - updateDaily] 隔天刷新 奖励 nType = "..i.." nDay = "..nDay)
  500. break
  501. end
  502. end
  503. end
  504. end
  505. end
  506. end
  507. -- 是否已激活首充
  508. function isActive(human, YYInfo, funcConfig)
  509. return not isOpen(human, YYInfo, funcConfig)
  510. end
  511. -- 玩家整点
  512. function onZero(human, funcID)
  513. updateDaily(human, funcID)
  514. end
  515. -- GM 命令
  516. function NewFirstCharge_GMClear(human)
  517. human.db.newFirstCharge = nil
  518. print("[NewFirstCharge_GMClear] 清空完成")
  519. end
  520. -- 是否购买了所有的新首充礼包
  521. function IsBuyAllgift(human)
  522. local newFirstChargeData = human.db.newFirstCharge
  523. if not newFirstChargeData or not next(newFirstChargeData) then
  524. return false
  525. end
  526. local bl = true
  527. -- 旧礼包判断,1~3为旧礼包的类型
  528. for i=1, 3 do
  529. if not newFirstChargeData[i] or newFirstChargeData[i].nBuyTime <= 0 then
  530. bl = false
  531. break
  532. end
  533. end
  534. if bl then
  535. return true
  536. end
  537. -- 新礼包判断, 4~6为新礼包的类型
  538. bl = true
  539. for i=4, 6 do
  540. if not newFirstChargeData[i] or newFirstChargeData[i].nBuyTime <= 0 then
  541. bl = false
  542. break
  543. end
  544. end
  545. return bl
  546. end