|
|
@@ -42,9 +42,64 @@ BARTASK_DAY_FREE = 2 -- 玩家每日免费刷新次数
|
|
|
BARTASK_QUICK_FINISH_TIME = 60 * 60 -- 玩家免费完成时间
|
|
|
BARTASK_TASK_NEED_ISR = 2200 -- 接取任务所需要的情报
|
|
|
|
|
|
+local PURPLE_TASK_STAR = 4 -- 紫色任务的star
|
|
|
+
|
|
|
+
|
|
|
GUIDE_DEFAUT_STAR = {[1] = 4}
|
|
|
GUIDE_DEFAUT_ITEM = {[1]= {ItemDefine.ITEM_DRAWCARD_GAOCHOU_ID, 1}}
|
|
|
|
|
|
+-- 是否拥有特权 (首充后会获得一定特权)
|
|
|
+local function isHavePrivilege(human)
|
|
|
+ if not human.db.topupAcount or human.db.topupAcount <= 0 then
|
|
|
+ return false
|
|
|
+ end
|
|
|
+
|
|
|
+ return true
|
|
|
+end
|
|
|
+
|
|
|
+-- 领取任务所需消耗
|
|
|
+local function getTaskCost(human)
|
|
|
+ local needIsr = BARTASK_TASK_NEED_ISR
|
|
|
+ local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_5)
|
|
|
+ if cjPrivilege then
|
|
|
+ local rate =(100 - cjPrivilege) / 100
|
|
|
+ needIsr = needIsr * rate
|
|
|
+ end
|
|
|
+
|
|
|
+ return needIsr
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+-- 自动领取紫色以上任务
|
|
|
+local function autoGetSpeTasks(human)
|
|
|
+ if not human.db.bar.autoGetTask or human.db.bar.autoGetTask ~= 1 then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local isGet = false
|
|
|
+
|
|
|
+ local itemCnt = getTaskCost(human)
|
|
|
+
|
|
|
+ for key, value in pairs(human.db.bar) do
|
|
|
+ if type(key) == "number" and type(value) == "table" then
|
|
|
+
|
|
|
+ if human.db.bar.qingbao < itemCnt then
|
|
|
+ break
|
|
|
+ end
|
|
|
+
|
|
|
+ if value.star >= PURPLE_TASK_STAR and not value.isLock then
|
|
|
+ getDo(human, key, nil, nil, true)
|
|
|
+ isGet = true
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ end
|
|
|
+
|
|
|
+ return isGet
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
function setBarTaskData(msgData, taskID, human, dbData, now)
|
|
|
if type(taskID) ~= "number" then
|
|
|
@@ -115,9 +170,13 @@ function query(human)
|
|
|
if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1104, true) then
|
|
|
return
|
|
|
end
|
|
|
+
|
|
|
ObjHuman.updateDaily(human)
|
|
|
initDB(human)
|
|
|
guideBar(human)
|
|
|
+
|
|
|
+ local isGet = autoGetSpeTasks(human)
|
|
|
+
|
|
|
local needIsr = BARTASK_TASK_NEED_ISR
|
|
|
local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_5)
|
|
|
if cjPrivilege then
|
|
|
@@ -139,6 +198,10 @@ function query(human)
|
|
|
msgRet.freeCnt = msgRet.freeCnt > 0 and msgRet.freeCnt or 0
|
|
|
msgRet.doubleCnt = 0
|
|
|
|
|
|
+ msgRet.hasCharge = isHavePrivilege(human) and 1 or 0
|
|
|
+ msgRet.isAutoTask = human.db.bar.autoGetTask or 0
|
|
|
+ msgRet.AutoTaskTips = isGet and 1 or 0
|
|
|
+
|
|
|
--秘宝对悬赏情报上限加成
|
|
|
local qingBaoAdd = TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.XUANSHANG_QB_MAX) or 0
|
|
|
msgRet.qingBaoMax = msgRet.qingBaoMax + qingBaoAdd
|
|
|
@@ -164,6 +227,7 @@ function query(human)
|
|
|
msgRet.list[0] = cnt
|
|
|
-- Msg.trace(msgRet)
|
|
|
Msg.send(msgRet, human.fd)
|
|
|
+
|
|
|
end
|
|
|
|
|
|
-- 刷新酒吧任务
|
|
|
@@ -251,10 +315,11 @@ end
|
|
|
|
|
|
|
|
|
-- 领取任务
|
|
|
-function getDo(human, taskID, heroIndexList, heroIDList)
|
|
|
+function getDo(human, taskID, heroIndexList, heroIDList, noSend)
|
|
|
if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1104, true) then
|
|
|
return
|
|
|
end
|
|
|
+
|
|
|
ObjHuman.updateDaily(human)
|
|
|
initDB(human)
|
|
|
|
|
|
@@ -265,10 +330,20 @@ function getDo(human, taskID, heroIndexList, heroIDList)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
+ local isNeedCkeck = true
|
|
|
+ if isHavePrivilege(human) then
|
|
|
+ isNeedCkeck = false
|
|
|
+ end
|
|
|
|
|
|
local barTaskConfig = BarTaskExcel.barTask[taskData.star]
|
|
|
+
|
|
|
-- 判断数量
|
|
|
- if heroIDList[0] ~= heroIndexList[0] then
|
|
|
+ -- if heroIDList[0] ~= heroIndexList[0] then
|
|
|
+ -- return
|
|
|
+ -- end
|
|
|
+
|
|
|
+
|
|
|
+ if isNeedCkeck and heroIDList[0] ~= heroIndexList[0] then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
@@ -283,51 +358,115 @@ function getDo(human, taskID, heroIndexList, heroIDList)
|
|
|
return Broadcast.sendErr(human, Lang.BAR_TASK_GET_ERR_ISR)
|
|
|
end
|
|
|
|
|
|
- local needStar = barTaskConfig.starNeed[1]
|
|
|
- local needStarCnt = barTaskConfig.starNeed[2]
|
|
|
- local nowStarCnt = 0
|
|
|
- local camp2Cnt = { }
|
|
|
-
|
|
|
-- 判断英雄
|
|
|
- local indexTable = { }
|
|
|
- for i = 1, heroIDList[0] do
|
|
|
- local tempIndex = heroIndexList[i]
|
|
|
- local heroGird = human.db.heroBag[tempIndex]
|
|
|
- if type(heroGird) ~= "table" then
|
|
|
- -- 没有这个英雄
|
|
|
- return
|
|
|
- end
|
|
|
- if heroGird.id ~= heroIDList[i] then
|
|
|
- -- 没对应上
|
|
|
- return
|
|
|
- end
|
|
|
- if indexTable[tempIndex] then
|
|
|
- -- 发了重复id
|
|
|
- return
|
|
|
+ -- local indexTable = { }
|
|
|
+ -- for i = 1, heroIDList[0] do
|
|
|
+ -- local tempIndex = heroIndexList[i]
|
|
|
+ -- local heroGird = human.db.heroBag[tempIndex]
|
|
|
+ -- if type(heroGird) ~= "table" then
|
|
|
+ -- -- 没有这个英雄
|
|
|
+ -- return
|
|
|
+ -- end
|
|
|
+ -- if heroGird.id ~= heroIDList[i] then
|
|
|
+ -- -- 没对应上
|
|
|
+ -- return
|
|
|
+ -- end
|
|
|
+ -- if indexTable[tempIndex] then
|
|
|
+ -- -- 发了重复id
|
|
|
+ -- return
|
|
|
+ -- end
|
|
|
+ -- if isSelectForBarTask(human, tempIndex) then
|
|
|
+ -- -- 已经在其它悬赏中选择了
|
|
|
+ -- return
|
|
|
+ -- end
|
|
|
+ -- indexTable[tempIndex] = true
|
|
|
+ -- local heroConfig = HeroExcel.hero[heroGird.id]
|
|
|
+ -- if heroGird.star >= needStar then
|
|
|
+ -- nowStarCnt = nowStarCnt + 1
|
|
|
+ -- end
|
|
|
+ -- camp2Cnt[heroConfig.camp] =(camp2Cnt[heroConfig.camp] or 0) + 1
|
|
|
+ -- end
|
|
|
+ -- -- 判断条件
|
|
|
+ -- if nowStarCnt < needStarCnt then
|
|
|
+ -- return Broadcast.sendErr(human, Util.format(Lang.BAR_TASK_GET_ERR_STAR, needStar, needStarCnt))
|
|
|
+ -- end
|
|
|
+ -- local campLen = taskData.camp and #taskData.camp or 0
|
|
|
+ -- for i = 1, campLen do
|
|
|
+ -- local needCamp = taskData.camp[i]
|
|
|
+ -- local nowCampCnt = camp2Cnt[needCamp] or 0
|
|
|
+ -- if nowCampCnt < 1 then
|
|
|
+ -- return Broadcast.sendErr(human, Lang.BAR_TASK_GET_ERR_CAMP)
|
|
|
+ -- end
|
|
|
+ -- camp2Cnt[needCamp] = nowCampCnt - 1
|
|
|
+ -- end
|
|
|
+
|
|
|
+ -- -- 扣除情报点
|
|
|
+ -- human.db.bar.qingbao = human.db.bar.qingbao - needIsr
|
|
|
+
|
|
|
+ -- -- 改db
|
|
|
+ -- human.db.bar[taskID].isLock = true
|
|
|
+ -- -- 因为:领取任务后,马上就去query查询,间隔太短
|
|
|
+ -- -- 导致:时间间隔为0,此时剩下的时间和需要花费的时间相等,导致客户端无法判断
|
|
|
+ -- -- 所以:领取时间要减去1秒,用来区分
|
|
|
+ -- -- 链接至:query(human)查看
|
|
|
+ -- human.db.bar[taskID].ts = os.time() -1
|
|
|
+ -- human.db.bar[taskID].hero = { }
|
|
|
+ -- for i = 1, heroIDList[0] do
|
|
|
+ -- human.db.bar[taskID].hero[i] = heroIndexList[i]
|
|
|
+ -- end
|
|
|
+
|
|
|
+ if isNeedCkeck then
|
|
|
+ local needStar = barTaskConfig.starNeed[1]
|
|
|
+ local needStarCnt = barTaskConfig.starNeed[2]
|
|
|
+ local nowStarCnt = 0
|
|
|
+ local camp2Cnt = { }
|
|
|
+ local indexTable = { }
|
|
|
+
|
|
|
+ for i = 1, heroIDList[0] do
|
|
|
+ local tempIndex = heroIndexList[i]
|
|
|
+ local heroGird = human.db.heroBag[tempIndex]
|
|
|
+ if type(heroGird) ~= "table" then
|
|
|
+ -- 没有这个英雄
|
|
|
+ return
|
|
|
+ end
|
|
|
+ if heroGird.id ~= heroIDList[i] then
|
|
|
+ -- 没对应上
|
|
|
+ return
|
|
|
+ end
|
|
|
+ if indexTable[tempIndex] then
|
|
|
+ -- 发了重复id
|
|
|
+ return
|
|
|
+ end
|
|
|
+ if isSelectForBarTask(human, tempIndex) then
|
|
|
+ -- 已经在其它悬赏中选择了
|
|
|
+ return
|
|
|
+ end
|
|
|
+ indexTable[tempIndex] = true
|
|
|
+ local heroConfig = HeroExcel.hero[heroGird.id]
|
|
|
+ if heroGird.star >= needStar then
|
|
|
+ nowStarCnt = nowStarCnt + 1
|
|
|
+ end
|
|
|
+ camp2Cnt[heroConfig.camp] =(camp2Cnt[heroConfig.camp] or 0) + 1
|
|
|
end
|
|
|
- if isSelectForBarTask(human, tempIndex) then
|
|
|
- -- 已经在其它悬赏中选择了
|
|
|
- return
|
|
|
+ -- 判断条件
|
|
|
+ if nowStarCnt < needStarCnt then
|
|
|
+ return Broadcast.sendErr(human, Util.format(Lang.BAR_TASK_GET_ERR_STAR, needStar, needStarCnt))
|
|
|
end
|
|
|
- indexTable[tempIndex] = true
|
|
|
- local heroConfig = HeroExcel.hero[heroGird.id]
|
|
|
- if heroGird.star >= needStar then
|
|
|
- nowStarCnt = nowStarCnt + 1
|
|
|
+ local campLen = taskData.camp and #taskData.camp or 0
|
|
|
+ for i = 1, campLen do
|
|
|
+ local needCamp = taskData.camp[i]
|
|
|
+ local nowCampCnt = camp2Cnt[needCamp] or 0
|
|
|
+ if nowCampCnt < 1 then
|
|
|
+ return Broadcast.sendErr(human, Lang.BAR_TASK_GET_ERR_CAMP)
|
|
|
+ end
|
|
|
+ camp2Cnt[needCamp] = nowCampCnt - 1
|
|
|
end
|
|
|
- camp2Cnt[heroConfig.camp] =(camp2Cnt[heroConfig.camp] or 0) + 1
|
|
|
- end
|
|
|
- -- 判断条件
|
|
|
- if nowStarCnt < needStarCnt then
|
|
|
- return Broadcast.sendErr(human, Util.format(Lang.BAR_TASK_GET_ERR_STAR, needStar, needStarCnt))
|
|
|
- end
|
|
|
- local campLen = taskData.camp and #taskData.camp or 0
|
|
|
- for i = 1, campLen do
|
|
|
- local needCamp = taskData.camp[i]
|
|
|
- local nowCampCnt = camp2Cnt[needCamp] or 0
|
|
|
- if nowCampCnt < 1 then
|
|
|
- return Broadcast.sendErr(human, Lang.BAR_TASK_GET_ERR_CAMP)
|
|
|
+
|
|
|
+
|
|
|
+ human.db.bar[taskID].hero = { }
|
|
|
+ for i = 1, heroIDList[0] do
|
|
|
+ human.db.bar[taskID].hero[i] = heroIndexList[i]
|
|
|
end
|
|
|
- camp2Cnt[needCamp] = nowCampCnt - 1
|
|
|
end
|
|
|
|
|
|
-- 扣除情报点
|
|
|
@@ -340,13 +479,13 @@ function getDo(human, taskID, heroIndexList, heroIDList)
|
|
|
-- 所以:领取时间要减去1秒,用来区分
|
|
|
-- 链接至:query(human)查看
|
|
|
human.db.bar[taskID].ts = os.time() -1
|
|
|
- human.db.bar[taskID].hero = { }
|
|
|
- for i = 1, heroIDList[0] do
|
|
|
- human.db.bar[taskID].hero[i] = heroIndexList[i]
|
|
|
- end
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-- 通知客户端
|
|
|
- sendBarTaskUpdate(human, taskID, BARTASK_OP_3)
|
|
|
+ if not noSend then
|
|
|
+ sendBarTaskUpdate(human, taskID, BARTASK_OP_3)
|
|
|
+ end
|
|
|
|
|
|
DailyTaskLogic.recordDailyTaskFinishCnt(human, DailyTaskLogic.DAILY_TASK_ID_9, 1)
|
|
|
ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_7, 1)
|
|
|
@@ -887,4 +1026,28 @@ function isDot(human)
|
|
|
end
|
|
|
end
|
|
|
return false
|
|
|
+end
|
|
|
+
|
|
|
+-- 更新勾选 "自动领取紫色以上任务"
|
|
|
+function UpdateOP(human, state)
|
|
|
+ if not human.db.bar then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ if state ~= 0 and state ~= 1 then
|
|
|
+ return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
|
|
|
+ end
|
|
|
+
|
|
|
+ human.db.bar.autoGetTask = state
|
|
|
+
|
|
|
+ SendOPState(human)
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+function SendOPState(human)
|
|
|
+ local msgRet = Msg.gc.GC_BARTASK_SET_OP
|
|
|
+
|
|
|
+ msgRet.op = human.db.bar.autoGetTask or 0
|
|
|
+
|
|
|
+ Msg.send(msgRet, human.fd)
|
|
|
end
|