|
|
@@ -39,6 +39,48 @@ local CARD_POOL_REFRESH = 2 -- ˢ�¿����������
|
|
|
local AUTO_GET_MONEY_TS = 300 -- �Զ��ظ�����ʱ��
|
|
|
CARD_POOL = CARD_POOL or {}
|
|
|
|
|
|
+--初始时hand拥有的数量
|
|
|
+local INITIALHANDCNT = 4
|
|
|
+--hand最大拥有的数量
|
|
|
+local MAXHANDCNT = 7
|
|
|
+
|
|
|
+
|
|
|
+--获取来自秘宝的加成
|
|
|
+local function getTalismanAdd(human, addType)
|
|
|
+ local addValue = TalismanLogic.getTalismanAdd(human, addType) or 0
|
|
|
+ return addValue
|
|
|
+end
|
|
|
+
|
|
|
+local function getHandInfo(human)
|
|
|
+ local isUnlock = false
|
|
|
+ local extraPosList = {}
|
|
|
+ local realyHandCnt = INITIALHANDCNT
|
|
|
+
|
|
|
+ for i=INITIALHANDCNT+1, MAXHANDCNT do
|
|
|
+ isUnlock = false
|
|
|
+ if i == 5 then
|
|
|
+ if ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_7) then
|
|
|
+ isUnlock = true
|
|
|
+ end
|
|
|
+ elseif i == 6 then
|
|
|
+ if getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_POS6) > 0 then
|
|
|
+ isUnlock = true
|
|
|
+ end
|
|
|
+ elseif i == 7 then
|
|
|
+ if getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_POS7) > 0 then
|
|
|
+ isUnlock = true
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ if isUnlock then
|
|
|
+ extraPosList[i] = i
|
|
|
+ realyHandCnt = realyHandCnt + 1
|
|
|
+ end
|
|
|
+ end
|
|
|
+ return realyHandCnt, extraPosList
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
function initAfterStart()
|
|
|
for i = 1,#ZhanbuExcel.pool do
|
|
|
local grade = ZhanbuExcel.pool[i].grade
|
|
|
@@ -52,28 +94,28 @@ function initAfterStart()
|
|
|
end
|
|
|
end
|
|
|
|
|
|
---获取最大占卜积分的加成值
|
|
|
-local function getMaxPointsAdd(human)
|
|
|
- local maxPointsAdd = TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_MAX_POINTS) or 0
|
|
|
- return maxPointsAdd
|
|
|
-end
|
|
|
-
|
|
|
|
|
|
local function initDB(human)
|
|
|
if human.db.zhanbu == nil then
|
|
|
- local maxPointsAdd = getMaxPointsAdd(human)
|
|
|
+ local maxPointsAdd = getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_MAX_POINTS)
|
|
|
human.db.zhanbu = {}
|
|
|
local zhanbu = human.db.zhanbu
|
|
|
zhanbu.hand = {}
|
|
|
zhanbu.handCnt = 0
|
|
|
- zhanbu.handMaxCnt = 4 -- ���������Ϊ4��
|
|
|
+ --zhanbu.handMaxCnt = 4 -- ���������Ϊ4��
|
|
|
+ zhanbu.handMaxCnt = MAXHANDCNT --直接改成最大值方便一点
|
|
|
zhanbu.money = AUTO_GET_MONEY_MAX + maxPointsAdd
|
|
|
zhanbu.lv = 1
|
|
|
zhanbu.isGuide = 1
|
|
|
zhanbu.refreshCnt = 0
|
|
|
zhanbu.heartHero = {}
|
|
|
zhanbu.pool = {}
|
|
|
- refreshPool(human)
|
|
|
+ refreshPool(human)
|
|
|
+ end
|
|
|
+
|
|
|
+ --处理老号
|
|
|
+ if human.db.zhanbu and human.db.zhanbu.handMaxCnt < MAXHANDCNT then
|
|
|
+ human.db.zhanbu.handMaxCnt = MAXHANDCNT
|
|
|
end
|
|
|
|
|
|
-- ���û�û��heartHero
|
|
|
@@ -81,18 +123,19 @@ local function initDB(human)
|
|
|
human.db.zhanbu.heartHero = {}
|
|
|
end
|
|
|
|
|
|
- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_7)
|
|
|
- if cjPrivilege then
|
|
|
- -- �Ѽ������Ȩ����Ϊ5��
|
|
|
- human.db.zhanbu.handMaxCnt = 5
|
|
|
- else
|
|
|
- if human.db.zhanbu.hand[5] ~= nil then
|
|
|
- -- ������ҵ��������������ߣ�Ĭ�ϼ���
|
|
|
- human.db.zhanbu.handMaxCnt = 5
|
|
|
- else
|
|
|
- human.db.zhanbu.handMaxCnt = 4
|
|
|
- end
|
|
|
- end
|
|
|
+ --屏蔽这里的判断, 改为通过 getHandInfo() 获取数据后进行判断
|
|
|
+ -- local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_7)
|
|
|
+ -- if cjPrivilege then
|
|
|
+ -- -- �Ѽ������Ȩ����Ϊ5��
|
|
|
+ -- human.db.zhanbu.handMaxCnt = 5
|
|
|
+ -- else
|
|
|
+ -- if human.db.zhanbu.hand[5] ~= nil then
|
|
|
+ -- -- ������ҵ��������������ߣ�Ĭ�ϼ���
|
|
|
+ -- human.db.zhanbu.handMaxCnt = 5
|
|
|
+ -- else
|
|
|
+ -- human.db.zhanbu.handMaxCnt = 4
|
|
|
+ -- end
|
|
|
+ -- end
|
|
|
end
|
|
|
|
|
|
function refreshPool(human)
|
|
|
@@ -170,10 +213,25 @@ function zhanbuQuery(human)
|
|
|
human.db.zhanbu.isGuide = 0
|
|
|
end
|
|
|
msgRet.heroPool[0] = len
|
|
|
- msgRet.isLock = 1
|
|
|
- if human.db.zhanbu.handMaxCnt == 5 then
|
|
|
- msgRet.isLock = 0
|
|
|
+
|
|
|
+ -- msgRet.isLock = 1
|
|
|
+ -- if human.db.zhanbu.handMaxCnt == 5 then
|
|
|
+ -- msgRet.isLock = 0
|
|
|
+ -- end
|
|
|
+
|
|
|
+ len = MAXHANDCNT - INITIALHANDCNT
|
|
|
+ msgRet.isLock[0] = len
|
|
|
+ local _, extraPosList = getHandInfo(human)
|
|
|
+
|
|
|
+ for i=MAXHANDCNT, INITIALHANDCNT+1, -1 do
|
|
|
+ msgRet.isLock[len] = 1
|
|
|
+ if extraPosList[i] then
|
|
|
+ msgRet.isLock[len] = 0
|
|
|
+ end
|
|
|
+ len = len - 1
|
|
|
end
|
|
|
+
|
|
|
+
|
|
|
len = 0
|
|
|
for i = 1,human.db.zhanbu.handMaxCnt do
|
|
|
if human.db.zhanbu.hand[i] ~= nil then
|
|
|
@@ -187,7 +245,7 @@ function zhanbuQuery(human)
|
|
|
end
|
|
|
msgRet.hand[0] = len
|
|
|
|
|
|
- local maxPointsAdd = getMaxPointsAdd(human)
|
|
|
+ local maxPointsAdd = getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_MAX_POINTS)
|
|
|
msgRet.cardRate = Util.copyTable(ZhanbuExcel.poolLv[human.db.zhanbu.lv].weight)
|
|
|
msgRet.cardRate[0] = 3
|
|
|
|
|
|
@@ -240,7 +298,7 @@ function buyCard(human,index,heroID)
|
|
|
local msgRet = Msg.gc.GC_ZHANBU_BUY_CARD
|
|
|
|
|
|
-- �ɺϳ���Ƭ
|
|
|
- local maxPointsAdd = getMaxPointsAdd(human)
|
|
|
+ local maxPointsAdd = getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_MAX_POINTS)
|
|
|
if sameCnt >= 2 then
|
|
|
-- �۳�����
|
|
|
human.db.zhanbu.money = human.db.zhanbu.money - config.price
|
|
|
@@ -264,6 +322,8 @@ function buyCard(human,index,heroID)
|
|
|
|
|
|
-- ������Ƭ
|
|
|
local randomCnt = math.random(config.chipCnt[1],config.chipCnt[2])
|
|
|
+ randomCnt = randomCnt + getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_FRAGMENT)
|
|
|
+
|
|
|
local item = {}
|
|
|
item[config.heroID] = randomCnt
|
|
|
BagLogic.addItem(human, config.heroID, randomCnt, "zhanbu")
|
|
|
@@ -284,7 +344,12 @@ function buyCard(human,index,heroID)
|
|
|
MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_6,1)
|
|
|
else
|
|
|
-- �ж������Ƿ�����
|
|
|
- if human.db.zhanbu.handCnt >= human.db.zhanbu.handMaxCnt then
|
|
|
+ -- if human.db.zhanbu.handCnt >= human.db.zhanbu.handMaxCnt then
|
|
|
+ -- return Broadcast.sendErr(human,Lang.ZHANBU_HAND_CARD_FULL)
|
|
|
+ -- end
|
|
|
+
|
|
|
+ local realyHandCnt, extraPosList = getHandInfo(human)
|
|
|
+ if human.db.zhanbu.handCnt >= realyHandCnt then
|
|
|
return Broadcast.sendErr(human,Lang.ZHANBU_HAND_CARD_FULL)
|
|
|
end
|
|
|
|
|
|
@@ -300,16 +365,24 @@ function buyCard(human,index,heroID)
|
|
|
-- �ӿ�����ɾ��
|
|
|
human.db.zhanbu.pool[index] = nil
|
|
|
|
|
|
+ local bl = true
|
|
|
for i = 1,human.db.zhanbu.handMaxCnt do
|
|
|
if human.db.zhanbu.hand[i] == nil then
|
|
|
- human.db.zhanbu.handCnt = human.db.zhanbu.handCnt + 1
|
|
|
- human.db.zhanbu.hand[i] = heroIndex
|
|
|
- msgRet.index = i
|
|
|
- break
|
|
|
+ bl = true
|
|
|
+ if i >= INITIALHANDCNT + 1 and not extraPosList[i] then
|
|
|
+ bl = false
|
|
|
+ end
|
|
|
+
|
|
|
+ if bl then
|
|
|
+ human.db.zhanbu.handCnt = human.db.zhanbu.handCnt + 1
|
|
|
+ human.db.zhanbu.hand[i] = heroIndex
|
|
|
+ msgRet.index = i
|
|
|
+ break
|
|
|
+ end
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
-
|
|
|
+
|
|
|
-- ֪ͨ�ͻ��˹���ɹ�
|
|
|
Msg.send(msgRet,human.fd)
|
|
|
|
|
|
@@ -343,7 +416,7 @@ function sellCard(human,index,heroID)
|
|
|
RoleSystemLogic.onDot(human,RoleSystemDefine.ROLE_SYS_ID_502)
|
|
|
|
|
|
-- �Զ��ظ���ʱ
|
|
|
- local maxPointsAdd = getMaxPointsAdd(human)
|
|
|
+ local maxPointsAdd = getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_MAX_POINTS)
|
|
|
if human.db.zhanbu.money >= AUTO_GET_MONEY_MAX + maxPointsAdd then
|
|
|
human.db.zhanbu.ts = nil
|
|
|
end
|
|
|
@@ -364,20 +437,27 @@ function changePos(human,posList)
|
|
|
|
|
|
-- ��������λ���Ƿ�Ϸ�
|
|
|
local tb = Util.split(posList, "|")
|
|
|
-
|
|
|
-- ���Ȳ��ԣ����Ϸ�
|
|
|
if #tb > human.db.zhanbu.handMaxCnt then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
+ local _, extraPosList = getHandInfo(human)
|
|
|
+
|
|
|
for i = 1,#tb do
|
|
|
-- ���ܽ���ɾ��
|
|
|
tb[i] = tonumber(tb[i])
|
|
|
- if tb[i] == 0 and human.db.zhanbu.hand[i] ~= nil then
|
|
|
+ local pos = tb[i]
|
|
|
+
|
|
|
+ if pos == 0 and human.db.zhanbu.hand[i] ~= nil then
|
|
|
return
|
|
|
end
|
|
|
-- ��λ�ò��Ϸ�
|
|
|
- if tb[i] > human.db.zhanbu.handMaxCnt then
|
|
|
+ if pos > human.db.zhanbu.handMaxCnt then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ if pos >= INITIALHANDCNT + 1 and not extraPosList[pos] then
|
|
|
return
|
|
|
end
|
|
|
end
|
|
|
@@ -386,7 +466,7 @@ function changePos(human,posList)
|
|
|
local dataList = Util.copyTable(human.db.zhanbu.hand)
|
|
|
human.db.zhanbu.hand = {}
|
|
|
for i = 1,human.db.zhanbu.handMaxCnt do
|
|
|
- if tb[i] ~= 0 then
|
|
|
+ if tb[i] and tb[i] ~= 0 then
|
|
|
human.db.zhanbu.hand[tb[i]] = dataList[i]
|
|
|
end
|
|
|
end
|
|
|
@@ -411,7 +491,7 @@ function refreshCardPool(human)
|
|
|
RoleSystemLogic.onDot(human,RoleSystemDefine.ROLE_SYS_ID_502)
|
|
|
|
|
|
-- �Զ��ظ���ʱ
|
|
|
- local maxPointsAdd = getMaxPointsAdd(human)
|
|
|
+ local maxPointsAdd = getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_MAX_POINTS)
|
|
|
if human.db.zhanbu.money < AUTO_GET_MONEY_MAX + maxPointsAdd then
|
|
|
human.db.zhanbu.ts = human.db.zhanbu.ts or os.time()
|
|
|
end
|
|
|
@@ -519,7 +599,7 @@ function checkRecover()
|
|
|
local now = os.time()
|
|
|
for _,human in pairs(ObjHuman.onlineUuid) do
|
|
|
if human.db.zhanbu and human.db.zhanbu.ts then
|
|
|
- local maxPointsAdd = getMaxPointsAdd(human)
|
|
|
+ local maxPointsAdd = getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_MAX_POINTS)
|
|
|
local finalMaxPoints = maxPointsAdd + AUTO_GET_MONEY_MAX
|
|
|
local ts = now - human.db.zhanbu.ts
|
|
|
local cnt = math.floor(ts/AUTO_GET_MONEY_TS)
|
|
|
@@ -563,7 +643,7 @@ function updateDaily(human)
|
|
|
|
|
|
if human.db.zhanbu and human.db.zhanbu.money then
|
|
|
local ts = human.db.zhanbu.ts
|
|
|
- local maxPointsAdd = getMaxPointsAdd(human)
|
|
|
+ local maxPointsAdd = getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_MAX_POINTS)
|
|
|
if not ts and human.db.zhanbu.money < AUTO_GET_MONEY_MAX + maxPointsAdd then
|
|
|
human.db.zhanbu.ts = os.time()
|
|
|
end
|
|
|
@@ -574,7 +654,7 @@ function onLogin(human)
|
|
|
--处理mone达到老的上限值后, human.db.zhanbu.ts为nil,导致后面获得秘宝时,无法获得秘宝加成情况
|
|
|
if human.db.zhanbu and human.db.zhanbu.money then
|
|
|
local ts = human.db.zhanbu.ts
|
|
|
- local maxPointsAdd = getMaxPointsAdd(human)
|
|
|
+ local maxPointsAdd = getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.ZHANBU_MAX_POINTS)
|
|
|
if not ts and human.db.zhanbu.money < AUTO_GET_MONEY_MAX + maxPointsAdd then
|
|
|
human.db.zhanbu.ts = os.time()
|
|
|
end
|