NewFirstChargeLogic.lua 20 KB

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