ZhanbuLogic.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. local ZhanbuExcel = require("excel.zhanbu")
  2. local Msg = require("core.Msg")
  3. local BagLogic = require("bag.BagLogic")
  4. local HeroGrid = require("hero.HeroGrid")
  5. local Util = require("common.Util")
  6. local ObjHuman = require("core.ObjHuman")
  7. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  8. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  9. local Lang = require("common.Lang")
  10. local Broadcast = require("broadcast.Broadcast")
  11. local SysParameter = require("common.SysParameter")
  12. local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
  13. local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
  14. local HeroExcel = require("excel.hero")
  15. local HeroBook = require("hero.HeroBook")
  16. local DropExchangeLogic = require("absAct.DropExchangeLogic")
  17. local HeroGrowUp = require("absAct.HeroGrowUp")
  18. local MengxinLogic = require("present.MengxinLogic")
  19. local AbsZhanbuLunpanLogic = require("absAct.AbsZhanbuLunpanLogic")
  20. local YunYingLogic = require("yunying.YunYingLogic")
  21. local TalismanLogic = require("talisman.TalismanLogic")
  22. --[[
  23. pool ����
  24. hand ����
  25. handCnt ��������
  26. money ӵ�е�������
  27. lv ���صȼ�
  28. refreshCnt ˢ�´���
  29. ts ���߻ظ���ʱ
  30. isGuide �Ƿ���������
  31. handMaxCnt ���Ƹ���
  32. heartHero ����Ӣ��
  33. ]]
  34. local CARD_POOL_MAX_CNT = 5 -- ����Ӣ������
  35. local AUTO_GET_MONEY_MAX = 99 -- �Զ��ظ�����������
  36. local CARD_POOL_REFRESH = 2 -- ˢ�¿������������
  37. local AUTO_GET_MONEY_TS = 300 -- �Զ��ظ�����ʱ��
  38. CARD_POOL = CARD_POOL or {}
  39. function initAfterStart()
  40. for i = 1,#ZhanbuExcel.pool do
  41. local grade = ZhanbuExcel.pool[i].grade
  42. local heroID = ZhanbuExcel.pool[i].heroID
  43. local weight = ZhanbuExcel.pool[i].weight
  44. CARD_POOL[grade] = CARD_POOL[grade] or {}
  45. CARD_POOL[grade].weight = CARD_POOL[grade].weight or 0
  46. CARD_POOL[grade].weight = CARD_POOL[grade].weight + ZhanbuExcel.pool[i].weight
  47. CARD_POOL[grade].pool = CARD_POOL[grade].pool or {}
  48. CARD_POOL[grade].pool[#CARD_POOL[grade].pool + 1] = {heroID,weight,i}
  49. end
  50. end
  51. --获取最大占卜积分的加成值
  52. local function getMaxPointsAdd(human)
  53. local maxPointsAdd = TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_MAX_POINTS) or 0
  54. return maxPointsAdd
  55. end
  56. local function initDB(human)
  57. if human.db.zhanbu == nil then
  58. local maxPointsAdd = getMaxPointsAdd(human)
  59. human.db.zhanbu = {}
  60. local zhanbu = human.db.zhanbu
  61. zhanbu.hand = {}
  62. zhanbu.handCnt = 0
  63. zhanbu.handMaxCnt = 4 -- ���������Ϊ4��
  64. zhanbu.money = AUTO_GET_MONEY_MAX + maxPointsAdd
  65. zhanbu.lv = 1
  66. zhanbu.isGuide = 1
  67. zhanbu.refreshCnt = 0
  68. zhanbu.heartHero = {}
  69. zhanbu.pool = {}
  70. refreshPool(human)
  71. end
  72. -- ���û�û��heartHero
  73. if human.db.zhanbu.heartHero == nil then
  74. human.db.zhanbu.heartHero = {}
  75. end
  76. local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_7)
  77. if cjPrivilege then
  78. -- �Ѽ������Ȩ����Ϊ5��
  79. human.db.zhanbu.handMaxCnt = 5
  80. else
  81. if human.db.zhanbu.hand[5] ~= nil then
  82. -- ������ҵ��������������ߣ�Ĭ�ϼ���
  83. human.db.zhanbu.handMaxCnt = 5
  84. else
  85. human.db.zhanbu.handMaxCnt = 4
  86. end
  87. end
  88. end
  89. function refreshPool(human)
  90. -- ��ʼ������
  91. initDB(human)
  92. local totalWeight = 0
  93. local weightConfig = ZhanbuExcel.poolLv[human.db.zhanbu.lv]
  94. for i = 1,#weightConfig.weight do
  95. totalWeight = totalWeight + weightConfig.weight[i]
  96. end
  97. -- ����һ��
  98. local cardPoolTb = Util.copyTable(CARD_POOL)
  99. for i = 1,#cardPoolTb[3].pool do
  100. if cardPoolTb[3].pool[i][1] == human.db.zhanbu.heartHero[1] or
  101. cardPoolTb[3].pool[i][1] == human.db.zhanbu.heartHero[2] or
  102. cardPoolTb[3].pool[i][1] == human.db.zhanbu.heartHero[3] then
  103. local newWeight = math.floor(cardPoolTb[3].pool[i][2] * 20 / 100)
  104. cardPoolTb[3].weight = cardPoolTb[3].weight + newWeight
  105. cardPoolTb[3].pool[i][2] = cardPoolTb[3].pool[i][2] + newWeight
  106. end
  107. end
  108. -- �������ſ�
  109. for i = 1,CARD_POOL_MAX_CNT do
  110. local randomGrade = math.random(1,totalWeight)
  111. -- ��ȡ���� R or SR or SSR
  112. for j = 1,#weightConfig.weight do
  113. if randomGrade <= weightConfig.weight[j] then
  114. local randomCard = math.random(1,cardPoolTb[j].weight)
  115. -- ��ȡ��
  116. for k = 1,#cardPoolTb[j].pool do
  117. if randomCard <= cardPoolTb[j].pool[k][2] then
  118. human.db.zhanbu.pool[i] = cardPoolTb[j].pool[k][3]
  119. break
  120. end
  121. randomCard = randomCard - cardPoolTb[j].pool[k][2]
  122. end
  123. break
  124. end
  125. randomGrade = randomGrade - weightConfig.weight[j]
  126. end
  127. end
  128. end
  129. function zhanbuQuery(human)
  130. -- ��ʼ������
  131. initDB(human)
  132. local msgRet = Msg.gc.GC_ZHANBU_QUERY
  133. local len = 0
  134. for i = 1,CARD_POOL_MAX_CNT do
  135. if human.db.zhanbu.pool[i] ~= nil then
  136. len = len + 1
  137. local index = human.db.zhanbu.pool[i]
  138. local config = ZhanbuExcel.pool[index]
  139. HeroGrid.makeHeroSimpleByID(msgRet.heroPool[len].heroInfo, config.heroID)
  140. msgRet.heroPool[len].price = config.price
  141. msgRet.heroPool[len].index = i
  142. end
  143. end
  144. msgRet.isGuide = human.db.zhanbu.isGuide or 0
  145. -- ��������������������ݷŵ�������
  146. if human.db.zhanbu.isGuide == 1 then
  147. len = 0
  148. sysHeroList = SysParameter.getSysParameterTb(SysParameter.PARAMETER_16)
  149. for i = 1,#sysHeroList do
  150. len = len + 1
  151. local index = sysHeroList[i]
  152. local config = ZhanbuExcel.pool[index]
  153. human.db.zhanbu.pool[i] = index
  154. HeroGrid.makeHeroSimpleByID(msgRet.heroPool[len].heroInfo, config.heroID)
  155. msgRet.heroPool[len].price = config.price
  156. msgRet.heroPool[len].index = i
  157. end
  158. human.db.zhanbu.isGuide = 0
  159. end
  160. msgRet.heroPool[0] = len
  161. msgRet.isLock = 1
  162. if human.db.zhanbu.handMaxCnt == 5 then
  163. msgRet.isLock = 0
  164. end
  165. len = 0
  166. for i = 1,human.db.zhanbu.handMaxCnt do
  167. if human.db.zhanbu.hand[i] ~= nil then
  168. len = len + 1
  169. local index = human.db.zhanbu.hand[i]
  170. local config = ZhanbuExcel.pool[index]
  171. HeroGrid.makeHeroSimpleByID(msgRet.hand[len].heroInfo, config.heroID)
  172. msgRet.hand[len].price = config.price
  173. msgRet.hand[len].index = i
  174. end
  175. end
  176. msgRet.hand[0] = len
  177. local maxPointsAdd = getMaxPointsAdd(human)
  178. msgRet.cardRate = Util.copyTable(ZhanbuExcel.poolLv[human.db.zhanbu.lv].weight)
  179. msgRet.cardRate[0] = 3
  180. msgRet.lv = human.db.zhanbu.lv
  181. msgRet.money = human.db.zhanbu.money
  182. msgRet.moneyMax = AUTO_GET_MONEY_MAX + maxPointsAdd
  183. msgRet.moneyCost = 1
  184. msgRet.nextRecover = AUTO_GET_MONEY_TS
  185. msgRet.recoverTs = AUTO_GET_MONEY_TS
  186. if human.db.zhanbu.ts then
  187. local now = os.time()
  188. msgRet.nextRecover = human.db.zhanbu.ts + AUTO_GET_MONEY_TS - now
  189. if msgRet.nextRecover < 0 then
  190. msgRet.nextRecover = 0
  191. end
  192. end
  193. msgRet.hasRed = xinyiDot(human) and 1 or 0
  194. Msg.send(msgRet,human.fd)
  195. end
  196. function buyCard(human,index,heroID)
  197. -- �������ݶ�û�У��Ҹ�
  198. if human.db.zhanbu == nil or human.db.zhanbu.pool == nil then
  199. return
  200. end
  201. local heroIndex = human.db.zhanbu.pool[index]
  202. -- �������ݶԲ���
  203. local config = ZhanbuExcel.pool[heroIndex]
  204. if not config or config.heroID ~= heroID then
  205. return
  206. end
  207. -- �ж��Ƿ�ɺϳ���Ƭ
  208. local sameCnt = 0
  209. for i = 1,human.db.zhanbu.handMaxCnt do
  210. if human.db.zhanbu.hand[i] ~= nil and
  211. human.db.zhanbu.hand[i] == heroIndex then
  212. sameCnt = sameCnt + 1
  213. end
  214. end
  215. -- �ж������Ƿ�
  216. if human.db.zhanbu.money < config.price then
  217. return Broadcast.sendErr(human,Lang.ABS_ITEM_ERR)
  218. end
  219. local msgRet = Msg.gc.GC_ZHANBU_BUY_CARD
  220. -- �ɺϳ���Ƭ
  221. local maxPointsAdd = getMaxPointsAdd(human)
  222. if sameCnt >= 2 then
  223. -- �۳�����
  224. human.db.zhanbu.money = human.db.zhanbu.money - config.price
  225. RoleSystemLogic.onDot(human,RoleSystemDefine.ROLE_SYS_ID_502)
  226. -- �Զ��ظ���ʱ
  227. if human.db.zhanbu.money < AUTO_GET_MONEY_MAX + maxPointsAdd then
  228. human.db.zhanbu.ts = human.db.zhanbu.ts or os.time()
  229. end
  230. -- �۳�����
  231. for i = 1,human.db.zhanbu.handMaxCnt do
  232. if human.db.zhanbu.hand[i] ~= nil and
  233. human.db.zhanbu.hand[i] == heroIndex then
  234. human.db.zhanbu.hand[i] = nil
  235. human.db.zhanbu.handCnt = human.db.zhanbu.handCnt - 1
  236. end
  237. end
  238. -- �ӿ�����ɾ��
  239. human.db.zhanbu.pool[index] = nil
  240. -- ������Ƭ
  241. local randomCnt = math.random(config.chipCnt[1],config.chipCnt[2])
  242. local item = {}
  243. item[config.heroID] = randomCnt
  244. BagLogic.addItem(human, config.heroID, randomCnt, "zhanbu")
  245. if config.grade == 3 then
  246. DropExchangeLogic.drawSSR(human, item, 1)
  247. end
  248. local zhanbuActItemID,zhanbuActCnt = AbsZhanbuLunpanLogic.getZhanbuComposeCnt(human, config.grade)
  249. if zhanbuActCnt and zhanbuActCnt > 0 then
  250. item[zhanbuActItemID] = zhanbuActCnt
  251. BagLogic.addItem(human, zhanbuActItemID, zhanbuActCnt, "zhanbu")
  252. end
  253. BagLogic.sendItemGetList(human, item, "zhanbu")
  254. msgRet.index = 0
  255. HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE3, 1)
  256. MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_6,1)
  257. else
  258. -- �ж������Ƿ�����
  259. if human.db.zhanbu.handCnt >= human.db.zhanbu.handMaxCnt then
  260. return Broadcast.sendErr(human,Lang.ZHANBU_HAND_CARD_FULL)
  261. end
  262. -- �۳�����
  263. human.db.zhanbu.money = human.db.zhanbu.money - config.price
  264. RoleSystemLogic.onDot(human,RoleSystemDefine.ROLE_SYS_ID_502)
  265. -- �Զ��ظ���ʱ
  266. if human.db.zhanbu.money < AUTO_GET_MONEY_MAX + maxPointsAdd then
  267. human.db.zhanbu.ts = human.db.zhanbu.ts or os.time()
  268. end
  269. -- �ӿ�����ɾ��
  270. human.db.zhanbu.pool[index] = nil
  271. for i = 1,human.db.zhanbu.handMaxCnt do
  272. if human.db.zhanbu.hand[i] == nil then
  273. human.db.zhanbu.handCnt = human.db.zhanbu.handCnt + 1
  274. human.db.zhanbu.hand[i] = heroIndex
  275. msgRet.index = i
  276. break
  277. end
  278. end
  279. end
  280. -- ֪ͨ�ͻ��˹���ɹ�
  281. Msg.send(msgRet,human.fd)
  282. -- ˢ�½���
  283. zhanbuQuery(human)
  284. YunYingLogic.onCallBack(human, "onZhanBuBuyCard", config.price)
  285. end
  286. function sellCard(human,index,heroID)
  287. -- �������ݶ�û�У��Ҹ�
  288. if human.db.zhanbu == nil or human.db.zhanbu.hand == nil then
  289. return
  290. end
  291. -- У�鿨�ĺϷ���
  292. local heroIndex = human.db.zhanbu.hand[index]
  293. local config = ZhanbuExcel.pool[heroIndex]
  294. if heroIndex == nil or config == nil then
  295. return
  296. end
  297. -- ɾ������
  298. human.db.zhanbu.hand[index] = nil
  299. human.db.zhanbu.handCnt = human.db.zhanbu.handCnt - 1
  300. -- ���ӵ���
  301. human.db.zhanbu.money = human.db.zhanbu.money + config.price
  302. RoleSystemLogic.onDot(human,RoleSystemDefine.ROLE_SYS_ID_502)
  303. -- �Զ��ظ���ʱ
  304. local maxPointsAdd = getMaxPointsAdd(human)
  305. if human.db.zhanbu.money >= AUTO_GET_MONEY_MAX + maxPointsAdd then
  306. human.db.zhanbu.ts = nil
  307. end
  308. -- ֪ͨ�ͻ����۳��ɹ�
  309. Msg.send(Msg.gc.GC_ZHANBU_SELL_CARD,human.fd)
  310. -- ˢ�½���
  311. zhanbuQuery(human)
  312. YunYingLogic.onCallBack(human, "onZhanBuBuyCard", -config.price)
  313. end
  314. function changePos(human,posList)
  315. -- �������ݶ�û�У��Ҹ�
  316. if human.db.zhanbu == nil or human.db.zhanbu.hand == nil then
  317. return
  318. end
  319. -- ��������λ���Ƿ�Ϸ�
  320. local tb = Util.split(posList, "|")
  321. -- ���Ȳ��ԣ����Ϸ�
  322. if #tb > human.db.zhanbu.handMaxCnt then
  323. return
  324. end
  325. for i = 1,#tb do
  326. -- ���ܽ���ɾ��
  327. tb[i] = tonumber(tb[i])
  328. if tb[i] == 0 and human.db.zhanbu.hand[i] ~= nil then
  329. return
  330. end
  331. -- ��λ�ò��Ϸ�
  332. if tb[i] > human.db.zhanbu.handMaxCnt then
  333. return
  334. end
  335. end
  336. -- �����
  337. local dataList = Util.copyTable(human.db.zhanbu.hand)
  338. human.db.zhanbu.hand = {}
  339. for i = 1,human.db.zhanbu.handMaxCnt do
  340. if tb[i] ~= 0 then
  341. human.db.zhanbu.hand[tb[i]] = dataList[i]
  342. end
  343. end
  344. zhanbuQuery(human)
  345. end
  346. function refreshCardPool(human)
  347. -- �������ݶ�û�У��Ҹ�
  348. if human.db.zhanbu == nil or human.db.zhanbu.hand == nil then
  349. return
  350. end
  351. -- У����ϲ���
  352. if human.db.zhanbu.money < CARD_POOL_REFRESH then
  353. return Broadcast.sendErr(human,Lang.ABS_ITEM_ERR)
  354. end
  355. -- �۳�����
  356. human.db.zhanbu.money = human.db.zhanbu.money - CARD_POOL_REFRESH
  357. RoleSystemLogic.onDot(human,RoleSystemDefine.ROLE_SYS_ID_502)
  358. -- �Զ��ظ���ʱ
  359. local maxPointsAdd = getMaxPointsAdd(human)
  360. if human.db.zhanbu.money < AUTO_GET_MONEY_MAX + maxPointsAdd then
  361. human.db.zhanbu.ts = human.db.zhanbu.ts or os.time()
  362. end
  363. -- ˢ��
  364. refreshPool(human)
  365. -- ˢ�³ɹ�������+1
  366. onLv(human)
  367. -- ˢ�½���
  368. zhanbuQuery(human)
  369. --ռ�����̻ ˢ�º�ص�
  370. AbsZhanbuLunpanLogic.onZhanbuRefresh(human)
  371. YunYingLogic.onCallBack(human, "onZhanBuBuyCard", CARD_POOL_REFRESH)
  372. end
  373. -- ����Ӣ��
  374. function zhanbuHeartHeroQuery(human)
  375. -- �������ݶ�û�У��Ҹ�
  376. if human.db.zhanbu == nil or human.db.zhanbu.hand == nil then
  377. return
  378. end
  379. local msgRet = Msg.gc.GC_ZHANBU_HEART_HERO_QUERY
  380. for i = 1,3 do
  381. local heroID = human.db.zhanbu.heartHero[i]
  382. msgRet.heroInfo[i] = heroID or 0
  383. end
  384. msgRet.heroInfo[0] = 3
  385. local len = 0
  386. for heroID,v in pairs(human.db.heroBook) do
  387. local heroConfig = HeroExcel.hero[heroID]
  388. if heroConfig and heroConfig.grade >= 4 then
  389. len = len + 1
  390. msgRet.heroList[len] = heroID
  391. end
  392. end
  393. msgRet.heroList[0] = len
  394. Msg.send(msgRet,human.fd)
  395. end
  396. -- ��������Ӣ��
  397. function setHeartHero(human,heroList)
  398. -- �������ݶ�û�У��Ҹ�
  399. if human.db.zhanbu == nil or human.db.zhanbu.hand == nil then
  400. return
  401. end
  402. -- ��������λ���Ƿ�Ϸ�
  403. local tb = Util.split(heroList, "|")
  404. -- ���Ȳ��ԣ����Ϸ�
  405. local len = #tb
  406. if len > 3 then
  407. return
  408. end
  409. -- У��Ӣ���Ƿ���ͼ���У��Ƿ���SSR
  410. for i = 1,len do
  411. tb[i] = tonumber(tb[i])
  412. local heroID = tb[i]
  413. if heroID ~= 0 then
  414. local heroConfig = HeroExcel.hero[heroID]
  415. -- �����Ѽ���ͼ���У�����
  416. if not HeroBook.isGet(human, heroID,heroConfig.star) then
  417. return
  418. end
  419. -- ����SSR������
  420. if heroConfig.grade < 4 then
  421. return
  422. end
  423. end
  424. end
  425. -- �������������
  426. human.db.zhanbu.heartHero = {}
  427. for i = 1,len do
  428. if tb[i] ~= 0 then
  429. human.db.zhanbu.heartHero[i] = tb[i]
  430. end
  431. end
  432. -- ˢ������Ӣ������
  433. zhanbuHeartHeroQuery(human)
  434. end
  435. function onLv(human)
  436. human.db.zhanbu.refreshCnt = human.db.zhanbu.refreshCnt + 1
  437. if human.db.zhanbu.refreshCnt >= ZhanbuExcel.poolLv[human.db.zhanbu.lv].cnt and
  438. human.db.zhanbu.lv < #ZhanbuExcel.poolLv then
  439. human.db.zhanbu.lv = human.db.zhanbu.lv + 1
  440. local msgRet = Msg.gc.GC_ZHANBU_LVUP
  441. msgRet.cardRate = Util.copyTable(ZhanbuExcel.poolLv[human.db.zhanbu.lv].weight)
  442. msgRet.cardRate[0] = 3
  443. msgRet.lv = human.db.zhanbu.lv
  444. Msg.send(msgRet,human.fd)
  445. end
  446. end
  447. function checkRecover()
  448. local now = os.time()
  449. for _,human in pairs(ObjHuman.onlineUuid) do
  450. if human.db.zhanbu and human.db.zhanbu.ts then
  451. local maxPointsAdd = getMaxPointsAdd(human)
  452. local finalMaxPoints = maxPointsAdd + AUTO_GET_MONEY_MAX
  453. local ts = now - human.db.zhanbu.ts
  454. local cnt = math.floor(ts/AUTO_GET_MONEY_TS)
  455. if cnt >= 1 and human.db.zhanbu.money < finalMaxPoints then
  456. human.db.zhanbu.money = human.db.zhanbu.money + cnt
  457. human.db.zhanbu.ts = human.db.zhanbu.ts + AUTO_GET_MONEY_TS * cnt
  458. if human.db.zhanbu.money >= finalMaxPoints then
  459. human.db.zhanbu.ts = nil
  460. human.db.zhanbu.money = finalMaxPoints
  461. end
  462. RoleSystemLogic.onDot(human,RoleSystemDefine.ROLE_SYS_ID_502)
  463. elseif human.db.zhanbu.money >= finalMaxPoints then
  464. human.db.zhanbu.ts = nil
  465. end
  466. end
  467. end
  468. end
  469. function isDot(human)
  470. if human.db.lv < 14 then
  471. return
  472. end
  473. initDB(human)
  474. if human.db.zhanbu and human.db.zhanbu.money >= 30 then
  475. return true
  476. end
  477. if xinyiDot(human) then
  478. return true
  479. end
  480. return
  481. end
  482. function updateDaily(human)
  483. if human.db.zhanbu == nil then
  484. return
  485. end
  486. human.db.zhanbu.lv = 1
  487. human.db.zhanbu.refreshCnt = 0
  488. if human.db.zhanbu and human.db.zhanbu.money then
  489. local ts = human.db.zhanbu.ts
  490. local maxPointsAdd = getMaxPointsAdd(human)
  491. if not ts and human.db.zhanbu.money < AUTO_GET_MONEY_MAX + maxPointsAdd then
  492. human.db.zhanbu.ts = os.time()
  493. end
  494. end
  495. end
  496. function onLogin(human)
  497. --处理mone达到老的上限值后, human.db.zhanbu.ts为nil,导致后面获得秘宝时,无法获得秘宝加成情况
  498. if human.db.zhanbu and human.db.zhanbu.money then
  499. local ts = human.db.zhanbu.ts
  500. local maxPointsAdd = getMaxPointsAdd(human)
  501. if not ts and human.db.zhanbu.money < AUTO_GET_MONEY_MAX + maxPointsAdd then
  502. human.db.zhanbu.ts = os.time()
  503. end
  504. end
  505. end
  506. function addZhanbuItem(human,cnt)
  507. -- ��ʼ������
  508. initDB(human)
  509. human.db.zhanbu.money = human.db.zhanbu.money + cnt
  510. end
  511. function xinyiDot(human)
  512. if human.db.heroBook == nil then return end
  513. local count = 0
  514. for k ,v in pairs(human.db.heroBook) do
  515. if type(k) == "number" then
  516. if HeroExcel.hero[k].grade >= 4 then
  517. count = count + 1
  518. end
  519. end
  520. end
  521. local xinyiCount = 0
  522. for i = 1, 3 do
  523. if human.db.zhanbu.heartHero[i] ~= nil then
  524. xinyiCount = xinyiCount + 1
  525. end
  526. end
  527. if xinyiCount < count and xinyiCount < 3 then
  528. return true
  529. end
  530. end