|
|
@@ -97,53 +97,98 @@ function dailyTaskQuery(human, isOnLogin)
|
|
|
Msg.send(msgRet, human.fd)
|
|
|
end
|
|
|
|
|
|
+--统计奖励
|
|
|
+local function calcReward(human, awardCfg)
|
|
|
+ for i = 1, #awardCfg do
|
|
|
+ local itemId = awardCfg[i][1]
|
|
|
+ local itemCnt = awardCfg[i][2]
|
|
|
+ if itemId == ItemDefine.ITME_HUOYUE_ID then
|
|
|
+ onDailyTaskHuoYue(human,itemCnt)
|
|
|
+ else
|
|
|
+ local newCnt = math.ceil(itemCnt)
|
|
|
+ --BagLogic.updateMomentItem(2, itemId, itemCnt)
|
|
|
+ BagLogic.updateMomentItem(2, itemId, newCnt)
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
-- 领取每日任务奖励
|
|
|
function dailyTaskGetReward(human, taskID)
|
|
|
if RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_801) ~= true then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- local dailyTaskConfig = DailyTaskExcel.dailyTask[taskID]
|
|
|
- if not dailyTaskConfig then return end
|
|
|
+ -- local dailyTaskConfig = DailyTaskExcel.dailyTask[taskID]
|
|
|
+ -- if not dailyTaskConfig then return end
|
|
|
|
|
|
-- 每日更新
|
|
|
ObjHuman.updateDaily(human)
|
|
|
|
|
|
- if human.db.dailyTask == nil or human.db.dailyTask.task == nil or human.db.dailyTask.task[taskID] == nil then
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
- -- 判断上限
|
|
|
- if human.db.dailyTask.task[taskID].isGet then
|
|
|
- return
|
|
|
- end
|
|
|
+ -- if human.db.dailyTask == nil or human.db.dailyTask.task == nil or human.db.dailyTask.task[taskID] == nil then
|
|
|
+ -- return
|
|
|
+ -- end
|
|
|
+
|
|
|
+ -- --判断上限
|
|
|
+ -- if human.db.dailyTask.task[taskID].isGet then
|
|
|
+ -- return
|
|
|
+ -- end
|
|
|
|
|
|
- if human.db.dailyTask.task[taskID].finishCnt == nil or human.db.dailyTask.task[taskID].finishCnt < dailyTaskConfig.taskCnt then
|
|
|
+ -- if human.db.dailyTask.task[taskID].finishCnt == nil or human.db.dailyTask.task[taskID].finishCnt < dailyTaskConfig.taskCnt then
|
|
|
+ -- return
|
|
|
+ -- end
|
|
|
+
|
|
|
+ -- --改db
|
|
|
+ -- human.db.dailyTask.task[taskID].isGet = true
|
|
|
+
|
|
|
+
|
|
|
+ -- --奖励倍数
|
|
|
+ -- BagLogic.cleanMomentItemList()
|
|
|
+ -- for i = 1, #dailyTaskConfig.reward do
|
|
|
+ -- local itemId = dailyTaskConfig.reward[i][1]
|
|
|
+ -- local itemCnt = dailyTaskConfig.reward[i][2]
|
|
|
+ -- if itemId == ItemDefine.ITME_HUOYUE_ID then
|
|
|
+ -- onDailyTaskHuoYue(human,itemCnt)
|
|
|
+ -- else
|
|
|
+ -- local newCnt = math.ceil(itemCnt)
|
|
|
+ -- BagLogic.updateMomentItem(2, itemId, itemCnt)
|
|
|
+ -- end
|
|
|
+ -- end
|
|
|
+ -- BagLogic.addMomentItemList(human, "daily_task")
|
|
|
+-- ChatPaoMaLogic.trigger(human, ChatPaoMaLogic.TRIGGER_TYPE_2, rewardID, rewardCnt)
|
|
|
+ -- 通知客户端
|
|
|
+ -- dailyTaskQuery(human)
|
|
|
+
|
|
|
+ -- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_801)
|
|
|
+
|
|
|
+
|
|
|
+ ------------------------------------新改为: 一键领取所有能领取的奖励---------------------------------------------
|
|
|
+ if human.db.dailyTask == nil or human.db.dailyTask.task == nil then
|
|
|
return
|
|
|
end
|
|
|
-
|
|
|
- -- 改db
|
|
|
- human.db.dailyTask.task[taskID].isGet = true
|
|
|
|
|
|
+ local isClean = false
|
|
|
+ local taskData = human.db.dailyTask.task
|
|
|
|
|
|
- -- 奖励倍数
|
|
|
- BagLogic.cleanMomentItemList()
|
|
|
- for i = 1, #dailyTaskConfig.reward do
|
|
|
- local itemId = dailyTaskConfig.reward[i][1]
|
|
|
- local itemCnt = dailyTaskConfig.reward[i][2]
|
|
|
- if itemId == ItemDefine.ITME_HUOYUE_ID then
|
|
|
- onDailyTaskHuoYue(human,itemCnt)
|
|
|
- else
|
|
|
- local newCnt = math.ceil(itemCnt)
|
|
|
- BagLogic.updateMomentItem(2, itemId, itemCnt)
|
|
|
- end
|
|
|
+ for taskId, data in pairs(taskData) do
|
|
|
+ if not data.isGet then
|
|
|
+ local dailyTaskConfig = DailyTaskExcel.dailyTask[taskId]
|
|
|
+ if data.finishCnt and data.finishCnt >= dailyTaskConfig.taskCnt then
|
|
|
+ if not isClean then
|
|
|
+ BagLogic.cleanMomentItemList()
|
|
|
+ isClean = true
|
|
|
+ end
|
|
|
+ calcReward(human, dailyTaskConfig.reward)
|
|
|
+ data.isGet = true
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ if isClean then
|
|
|
+ BagLogic.addMomentItemList(human, "daily_task")
|
|
|
+ dailyTaskQuery(human)
|
|
|
+ RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_801)
|
|
|
end
|
|
|
- BagLogic.addMomentItemList(human, "daily_task")
|
|
|
--- ChatPaoMaLogic.trigger(human, ChatPaoMaLogic.TRIGGER_TYPE_2, rewardID, rewardCnt)
|
|
|
- -- 通知客户端
|
|
|
- dailyTaskQuery(human)
|
|
|
-
|
|
|
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_801)
|
|
|
end
|
|
|
|
|
|
-- 记录每个任务的完成次数
|
|
|
@@ -198,43 +243,100 @@ local function huoYueBoxCanGet(human,boxID)
|
|
|
end
|
|
|
|
|
|
function CG_DAILYTASK_GET_HUOYUEBOX(human,boxID)
|
|
|
- local huoYueBoxConfig = DailyTaskExcel.huoYueBox[boxID]
|
|
|
- if not huoYueBoxConfig then return end
|
|
|
+ -- local huoYueBoxConfig = DailyTaskExcel.huoYueBox[boxID]
|
|
|
+ -- if not huoYueBoxConfig then return end
|
|
|
|
|
|
- if not huoYueBoxCanGet(human,boxID) then return end
|
|
|
+ -- if not huoYueBoxCanGet(human,boxID) then return end
|
|
|
|
|
|
- human.db.dailyTask.huoYueBox = human.db.dailyTask.huoYueBox or {}
|
|
|
- human.db.dailyTask.huoYueBox[boxID] = 1
|
|
|
+ -- human.db.dailyTask.huoYueBox = human.db.dailyTask.huoYueBox or {}
|
|
|
+ -- human.db.dailyTask.huoYueBox[boxID] = 1
|
|
|
|
|
|
- local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_801)
|
|
|
+ -- local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_801)
|
|
|
+ -- local rewardCnt = double and 2 or 1
|
|
|
+ -- local cjPrivilege = ChengjiuLogic.checkPrivilege(human,ChengjiuDefine.PRIVILEGE_TYPE_2)
|
|
|
+ -- local item = Util.copyTable(huoYueBoxConfig.reward)
|
|
|
+ -- if cjPrivilege then
|
|
|
+ -- local random = math.random(1,100)
|
|
|
+ -- if random <= 1 then
|
|
|
+ -- local len = #item
|
|
|
+ -- for i = 1,len do
|
|
|
+ -- item[i][2] = item[i][2] * 2
|
|
|
+ -- end
|
|
|
+ -- end
|
|
|
+
|
|
|
+
|
|
|
+ -- end
|
|
|
+
|
|
|
+ -- if double then
|
|
|
+ -- local len = #item
|
|
|
+ -- for i = 1,len do
|
|
|
+ -- item[i][2] = item[i][2] * rewardCnt
|
|
|
+ -- end
|
|
|
+ -- end
|
|
|
+
|
|
|
+ -- local msgRet = Msg.gc.GC_DAILYTASK_GET_HUOYUEBOX
|
|
|
+ -- msgRet.boxID = boxID
|
|
|
+ -- msgRet.double = double and 1 or 0
|
|
|
+ -- Msg.send(msgRet,human.fd)
|
|
|
+ -- BagLogic.addItemList(human, item, "daily_task")
|
|
|
+ -- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_801)
|
|
|
+
|
|
|
+ -------------------------------新修改为:一键领取所有能领取的宝箱奖励------------------------------------
|
|
|
+
|
|
|
+ local dailyTaskDB = human.db.dailyTask
|
|
|
+ if not dailyTaskDB then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local nowHuoYue = dailyTaskDB.nowHuoYue
|
|
|
+ if not nowHuoYue then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+ local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_801)
|
|
|
local rewardCnt = double and 2 or 1
|
|
|
local cjPrivilege = ChengjiuLogic.checkPrivilege(human,ChengjiuDefine.PRIVILEGE_TYPE_2)
|
|
|
- local item = Util.copyTable(huoYueBoxConfig.reward)
|
|
|
- if cjPrivilege then
|
|
|
- local random = math.random(1,100)
|
|
|
- if random <= 1 then
|
|
|
- local len = #item
|
|
|
- for i = 1,len do
|
|
|
- item[i][2] = item[i][2] * 2
|
|
|
- end
|
|
|
- end
|
|
|
|
|
|
-
|
|
|
- end
|
|
|
+ local len = 0
|
|
|
+ local randRate = 1
|
|
|
+ local awardList = {}
|
|
|
+ local boxData = dailyTaskDB.huoYueBox
|
|
|
+ local boxConfig = DailyTaskExcel.huoYueBox
|
|
|
|
|
|
- if double then
|
|
|
- local len = #item
|
|
|
- for i = 1,len do
|
|
|
- item[i][2] = item[i][2] * rewardCnt
|
|
|
- end
|
|
|
+
|
|
|
+ for boxId, v in ipairs(boxConfig) do
|
|
|
+ if nowHuoYue >= v.needHuoYue and (not boxData or not boxData[boxId]) then
|
|
|
+ dailyTaskDB.huoYueBox = dailyTaskDB.huoYueBox or {}
|
|
|
+ boxData = dailyTaskDB.huoYueBox
|
|
|
+ boxData[boxId] = 1
|
|
|
+
|
|
|
+ randRate = 1
|
|
|
+ if cjPrivilege then
|
|
|
+ local random = math.random(1,100)
|
|
|
+ if random <= 1 then
|
|
|
+ randRate = 2
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ for _, itemInfo in ipairs(v.reward) do
|
|
|
+ len = len + 1
|
|
|
+ awardList[len] = {itemInfo[1], itemInfo[2] * randRate * rewardCnt}
|
|
|
+ end
|
|
|
+
|
|
|
+ --更新
|
|
|
+ local msgRet = Msg.gc.GC_DAILYTASK_GET_HUOYUEBOX
|
|
|
+ msgRet.boxID = boxId
|
|
|
+ msgRet.double = double and 1 or 0
|
|
|
+ Msg.send(msgRet,human.fd)
|
|
|
+ end
|
|
|
end
|
|
|
-
|
|
|
- local msgRet = Msg.gc.GC_DAILYTASK_GET_HUOYUEBOX
|
|
|
- msgRet.boxID = boxID
|
|
|
- msgRet.double = double and 1 or 0
|
|
|
- Msg.send(msgRet,human.fd)
|
|
|
- BagLogic.addItemList(human, item, "daily_task")
|
|
|
- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_801)
|
|
|
+
|
|
|
+ if len > 0 then
|
|
|
+ BagLogic.addItemList(human, awardList, "daily_task")
|
|
|
+ RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_801)
|
|
|
+ end
|
|
|
+
|
|
|
end
|
|
|
|
|
|
function isDot(human)
|