NewFirstChargeLogic.lua 20 KB

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