diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index 8d04609..e1fad09 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -1,7 +1,7 @@ XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" -RESET_TIME = 0 +RESET_TIME = 4 -START_RESET_TIME_BASE = 1584316800 -- 0时区 +START_RESET_TIME_BASE = 1584316800 + RESET_TIME * 3600 -- 0时区 DAY_SEC = 86400 TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区 @@ -256,7 +256,7 @@ SettingStatus = { }, } -EMAIL_LIMIT = 20 --邮件最大数量 +EMAIL_LIMIT = 50 --邮件最大数量 RedPointTags = { PvpCR = 1, diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index f7d3b6e..d864e92 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -208,6 +208,8 @@ actionCodes = { Activity_sudokuRewardRpc = 652, Activity_actSignRpc = 653, Activity_actPaySignRewardNtf = 654, + Activity_actCalendaTaskRpc = 655, + Activity_actPaySignRpc = 656, } rpcResponseBegin = 10000 diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index ea8eb58..af770e3 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -183,19 +183,21 @@ end function _M.actPaySignRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) + local dayIndex = msg.day local actGoodsFlag = role.storeData:getProperty("actGoodsFlag") local index = GetActGoodsIndex("paySignIn") - local flag = actGoodsFlag[index] or 0 - if flag == 0 then return 1 end + local ts = actGoodsFlag[index] or 0 + if ts == 0 then return 1 end - if not role.activity:isOpen("PaySignIn") then return 2 end + local open, actId = role.activity:isOpen("PaySignIn") + if not open then return 2 end - local diffDay = diffFromOpen() + 1 + local diffDay = diffFromTs(ts) + 1 local curData = role.activity:getActData("PaySignIn") local reward, change = {} for day, csvData in ipairs(csvdb["pay_signInCsv"]) do - if day <= diffDay then + if day <= diffDay and day == dayIndex then if not curData[day] then curData[day] = 1 -- 奖励 @@ -203,8 +205,8 @@ function _M.actPaySignRpc(agent, data) reward[itemId] = (reward[itemId] or 0) + count end end - else - break + --else + -- break end end if next(reward) then @@ -213,7 +215,7 @@ function _M.actPaySignRpc(agent, data) end role:log("activity", { - activity_id = curData[0], -- 活动ID(或活动指定任务的ID) + activity_id = actId, -- 活动ID(或活动指定任务的ID) activity_type = role.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} }) @@ -222,4 +224,42 @@ function _M.actPaySignRpc(agent, data) return true end +function _M.actCalendaTaskRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local taskId = msg.id + local calTask = role:getProperty("calTask") or {} + local record = calTask["r"] or {} + local flag = record[taskId] or 0 + if flag == 1 then return 1 end + local open, actId = role.activity:isOpen("CalendaTask") + local actData = csvdb["activity_ctrlCsv"][actId] + if not open then return 2 end + if not actData then return 3 end + + local taskList = csvdb["activity_taskCsv"][actData.condition] + if not taskList then return 4 end + local taskCfg = taskList[taskId] + if not taskCfg then return 5 end + if taskCfg.key ~= actData.condition then return 6 end + + if (calTask[taskId] or 0) < taskCfg.condition1 then return 7 end + + record[taskId] = 1 + calTask["r"] = record + + role:updateProperty({field = "calTask", value = calTask}) + + local reward, change = role:award(taskCfg.reward, {log = {desc = "calendaTask"}}) + + role:log("activity", { + activity_id = taskId, -- 活动ID(或活动指定任务的ID) + activity_type = role.activity.ActivityType.CalendaTask, -- 活动类型,见活动类型枚举表 + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + }) + + SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change))) + return true +end + return _M \ No newline at end of file diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index b349007..5308b88 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -250,7 +250,7 @@ function _M.startHangRpc(agent, data) if not role:getAdvData():isRunning() then role:updateProperty({field = "advTeam", value = {}}) end - + role:pushMsg({type = "adv", slot = chapterId, time = adv_idle_time}) role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) role:changeAdvCount(adv_idle_energy) @@ -295,6 +295,7 @@ function _M.quickHangRpc(agent, data) info.time = 0 role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) + role:pushCancel({type = "adv", slot = chapterId}) role:mylog("adv_action", {desc = "advQuickHang", int1 = chapterId}) SendPacket(actionCodes.Adv_quickHangRpc, '') @@ -371,6 +372,7 @@ function _M.endHangRpc(agent, data) -- else -- role:updateProperty({field = "advC", delta = -chapterData.limitlevel}) -- end + role:pushCancel({type = "adv", slot = chapterId}) else return end @@ -380,6 +382,8 @@ function _M.endHangRpc(agent, data) role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) + role:checkTaskEnter("AdvHang", {}) + SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull})) return true end diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index 646298d..f10bf53 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -75,6 +75,9 @@ function _M.addSellRpc( agent, data ) sells[slot].count = count sells[slot].time = skynet.timex() - calSell.deltaTime + local needTime = sells[slot].count * dishData.sell_time + sells[slot].time - skynet.timex() + role:pushMsg({type = "food", slot = slot, time = needTime}) + -- 检查解锁的顾客 local had = {} for _, sell in pairs(sells) do @@ -155,6 +158,7 @@ function _M.removeSellRpc( agent, data ) reward, change = role:award(reward, {log = {desc = "removeSell"}}) sells[slot].count = 0 + role:pushCancel({type = "food", slot = slot}) role:log("restaurant_sale", { item_id = dish, -- 售卖物品ID restaurant_sale_seat = slot, -- 售卖物品所在位置 diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 12c1ed9..2b56e2b 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -22,6 +22,7 @@ local function checkReward(role) return false end local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] + local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) @@ -39,9 +40,9 @@ local function checkReward(role) local items = role:getProperty("hangBag") coinCount = coinCount + coinDoubleCount - items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * carbonData.money) - items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * carbonData.exp) - items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) + items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * expCarbonData.money) + items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) + items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) local pool = {} for _, temp in pairs(carbonData.item:toArray()) do @@ -58,7 +59,8 @@ local function checkReward(role) -- 特权卡挂机额外栏位 local privExtraCnt = role.storeData:getHangSlotExtraCount() - local selfFC = role:getProperty("hangBagLimit") + privExtraCnt + --local selfFC = role:getProperty("hangBagLimit") + privExtraCnt + local selfFC = 50 local selfIC = selfFC * globalCsv.idle_field_limit local function randomItem() @@ -139,6 +141,7 @@ function _M.startRpc( agent, data ) local hangInfo = role:getProperty("hangInfo") local isNew = not hangInfo.carbonId hangInfo.carbonId = carbonId + hangInfo.expCarbonId = isNew and carbonId or hangInfo.expCarbonId local nowTime = skynet.timex() if isNew then hangInfo.coinTime = nowTime @@ -149,11 +152,14 @@ function _M.startRpc( agent, data ) hangInfo.coinTime = math.min(nowTime, hangInfo.endCoinTime) hangInfo.itemTime = math.min(nowTime, hangInfo.endItemTime) end + + role:pushMsg({type = "hang", time = math.min(hangInfo.endCoinTime - nowTime, hangInfo.endItemTime - nowTime)}) if not role:checkHangPass(carbonId) then hangInfo.bossTime = nowTime + carbonData.idle_time else hangInfo.bossTime = nil end + role:updateProperty({field = "hangInfo", value = hangInfo}) -- 指定当前引导的步骤 @@ -193,12 +199,12 @@ function _M.startBattleRpc(agent, data) return 1 end - local hangInfo = role:getProperty("hangInfo") - if curData.main ~= 1 then - if carbonId ~= hangInfo.carbonId then - return 2 - end - end + --local hangInfo = role:getProperty("hangInfo") or {} + --if curData.main ~= 1 then + -- if carbonId ~= hangInfo.carbonId then + -- return 2 + -- end + --end if role:checkHangPass(carbonId) then return 3 @@ -214,7 +220,7 @@ end function _M.endBattleRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) - local hangInfo = role:getProperty("hangInfo") + local hangInfo = role:getProperty("hangInfo") or {} if not msg.key or msg.key ~= _BattleKey then SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1})) return true @@ -225,11 +231,12 @@ function _M.endBattleRpc(agent, data) if not carbonData then return 2 end - if carbonData.main ~= 1 then - if carbonId ~= hangInfo.carbonId then - return 3 - end - end + + --if carbonData.main ~= 1 then + -- if carbonId ~= hangInfo.carbonId then + -- return 3 + -- end + --end if role:checkHangPass(carbonId) then return 4 @@ -273,8 +280,8 @@ function _M.endBattleRpc(agent, data) end local nextCarbonId = role:getNextCarbonId(carbonId) -- 设置挂机关卡 - if isWin and hangInfo.carbonId < nextCarbonId then - hangInfo.carbonId = nextCarbonId + if isWin and (hangInfo.carbonId or 0) < nextCarbonId then + hangInfo.expCarbonId = nextCarbonId local cfg = csvdb["idle_battleCsv"][nextCarbonId] if cfg then hangInfo.bossTime = skynet.timex() + cfg.idle_time @@ -354,7 +361,9 @@ function _M.getRewardRpc(agent , data) hangInfo.itemTime = nowTime role:updateProperty({field = "hangBag", value = items}) role:updateProperty({field = "hangInfo", value = hangInfo}) - role:checkTaskEnter("HangGet") + role:pushMsg({type = "hang", time = globalCsv.idle_producetime_max}) + + role:checkTaskEnter("HangGet", {reward = reward}) if reward[ItemId.Gold] then role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) end @@ -382,6 +391,7 @@ function _M.quickRpc(agent , data) local hangInfo = role:getProperty("hangInfo") if not hangInfo.carbonId then return end local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] + local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] local curCount = role.dailyData:getProperty("hangQC") + 1 local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=") @@ -398,9 +408,9 @@ function _M.quickRpc(agent , data) local coinCount = math.floor(time / globalCsv.idle_money_produce_cd) local itemCount = math.floor(time / globalCsv.idle_item_produce_cd) - reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * carbonData.money) - reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * carbonData.exp) - reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) + reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * expCarbonData.money) + reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) + reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) local pool = {} for _, temp in pairs(carbonData.item:toArray()) do diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 1807342..b5418ca 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -60,6 +60,8 @@ function _M.levelUpRpc( agent, data ) hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")}) role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) + + role:checkTaskEnter("HeroLvlCollect", {}) SendPacket(actionCodes.Hero_levelUpRpc, '') return true end @@ -128,6 +130,8 @@ function _M.wakeRpc(agent, data) }) SendPacket(actionCodes.Hero_wakeRpc, '') + + role:checkTaskEnter("HeroStarCollect", {}) return true end @@ -595,6 +599,8 @@ function _M.referRunesRpc(agent, data) }) end end + + role:checkTaskEnter("RuneQualityCollect", {}) SendPacket(actionCodes.Hero_referRunesRpc, "") return true @@ -728,6 +734,13 @@ function _M.drawHeroRpc(agent, data) if btype ~= 1 then subType = 1 end + + if btype == 1 then + -- 判断定向卡池活动开启 + if not role.activity:isOpen("RaceDraw") then + return + end + end local buildTypeData = csvdb["build_typeCsv"][btype] if not buildTypeData then return 2 end @@ -835,7 +848,7 @@ function _M.drawHeroRpc(agent, data) local guideHero if role:getProperty("newerGuide") == "11=1" then - guideHero = 613 + guideHero = globalCsv.newdraw_hero_item_id or 613 end local ssrCount = 0 diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index c0a4500..472a850 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -121,6 +121,9 @@ function _M.loginRpc( agent, data ) role:setProperty("device", device) end end + if msg.token then + role._pushToken = msg.token + end if not msg.isGMlogin then local banTime = role:getProperty("banTime") @@ -550,7 +553,7 @@ function _M.openTimeBoxRpc(agent, data) if boxL[slot] then return end role:costItems({[itemId] = 1}, {log = {desc = "openTimeBox"}}) boxL[slot] = {id = itemId, time = skynet.timex() + randomData.openTime} - + role:pushMsg({type = "box", slot = slot, time = randomData.openTime}) elseif oper == 2 then -- 领取 local quick = msg.quick if not boxL[slot] then return end @@ -561,6 +564,7 @@ function _M.openTimeBoxRpc(agent, data) costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2] if not role:checkItemEnough({[ItemId.BoxKey] = costKey}) then return end role:costItems({[ItemId.BoxKey] = costKey}, {log = {desc = "openTimeBox"}}) + role:pushCancel({type = "box", slot = slot}) end local boxId = boxL[slot].id local itemData = csvdb["itemCsv"][boxId] @@ -615,52 +619,57 @@ end function _M.openSpeedUpBoxRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) - - local id = msg.id - local count = msg.count - local itemData = csvdb["itemCsv"][id] - if not itemData or itemData.type ~= ItemType.SpeedBox then return end - - if math.illegalNum(count, 1, role:getItemCount(id)) then return end - local useType, hour = table.unpack(itemData.use_effect:toArray(true, "=")) - local time = hour * 60 * 60 + local itemInfo = msg.itemInfo local reward = {} - if useType == 1 then -- 挂机齿轮 - local hangInfo = role:getProperty("hangInfo") - if not hangInfo.carbonId then - return - end - local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] - reward[ItemId.Gold] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count - elseif useType == 2 then -- 挂机经验 - local hangInfo = role:getProperty("hangInfo") - if not hangInfo.carbonId then - return - end - local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] - reward[ItemId.Exp] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count - elseif useType == 3 then -- 食材商人收入 - local buildType = 6 - local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) - local buildingData = csvdb["diner_buildingCsv"][buildType][level] - if not buildingData then - return 1 - end - local gfood = role.dinerData:getProperty("gfood") - if not next(gfood) then return end - for k , v in pairs(gfood) do - local itemId = v.id - local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 - reward[itemId] = math.floor(time / speed) * count + for i = 1, #itemInfo do + local pair = itemInfo[i] + local id = pair[1] + local count = pair[2] + local itemData = csvdb["itemCsv"][id] + if not itemData or itemData.type ~= ItemType.SpeedBox then return end + + if math.illegalNum(count, 1, role:getItemCount(id)) then return 1 end + local useType, hour = table.unpack(itemData.use_effect:toArray(true, "=")) + local time = hour * 60 * 60 + + if useType == 1 then -- 挂机齿轮 + local hangInfo = role:getProperty("hangInfo") + if not hangInfo.expCarbonId then + return 2 + end + local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count + elseif useType == 2 then -- 挂机经验 + local hangInfo = role:getProperty("hangInfo") + if not hangInfo.expCarbonId then + return 3 + end + local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count + elseif useType == 3 then -- 食材商人收入 + local buildType = 6 + local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) + local buildingData = csvdb["diner_buildingCsv"][buildType][level] + if not buildingData then + return 4 + end + local gfood = role.dinerData:getProperty("gfood") + if not next(gfood) then return 5 end + for k , v in pairs(gfood) do + local itemId = v.id + local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 + reward[itemId] = (reward[itemId] or 0) + math.floor((time / speed) * count) + end + else + return 6 end - else - return + + role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) end - role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) local change - reward, change = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count}) + reward, change = role:award(reward, {log = {desc = "speedUpBox"}}) SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack(role:packReward(reward, change))) return true diff --git a/src/csvdata b/src/csvdata index 9bb26cf..29d26c6 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 9bb26cfdb11f81dbfe6abbc468b44ca9f814deb2 +Subproject commit 29d26c6e3083676ddaa828f8d0b22cd1d0ee48cf diff --git a/src/models/Activity.lua b/src/models/Activity.lua index a6f9b99..708effa 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -18,6 +18,7 @@ Activity.ActivityType = { DrawHero = 12, --抽卡周 招募 AdvDraw = 13, --拾荒抽周 资助 OpenBox = 14, --拆解周 时钟箱 + RaceDraw = 15, -- 定向招募活动 } @@ -344,8 +345,9 @@ activityFunc[Activity.ActivityType.PaySignIn] = { ["init"] = function(self, actType, isCrossDay, notify) self:updateActData(actType, {}, not notify) end, - -- ["close"] = function(self, actType, notify) - -- end, + ["close"] = function(self, actType, notify) + self.owner.storeData:SetActGoodsFlag("paySignIn", 0) + end, } -- 充值反馈 @@ -367,6 +369,37 @@ activityFunc[Activity.ActivityType.PayBack] = { -- end, } +-- 英雄帖 +activityFunc[Activity.ActivityType.CalendaTask] = { + ["init"] = function(self, actType, isCrossDay, notify) + local calTask = self.owner:getProperty("CalTask") + calTask = {} + local role = self.owner + local buildL = role.dinerData:getProperty("buildL") + local curLevel = buildL:getv(1, 1) + role:checkTaskEnter("DinerLevelUp", {level = curLevel}) + + role:checkTaskEnter("HeroLvlCollect", {}) + role:checkTaskEnter("HeroQualityCollect", {}) + + local curPopular = role.dinerData:getProperty("popular") + role:checkTaskEnter("DinerPopular", {count = curPopular}) + + local rLevel = role:getProperty("level") + role:checkTaskEnter("RoleLevelUp", {level = rLevel}) + + local towerInfo = role:getProperty("towerInfo") + role:checkTaskEnter("TowerPass", {level = towerInfo.l}) + --"PvpWin" + role:checkTaskEnter("HangPass", {}) + role:checkTaskEnter("HeroStarCollect", {}) + role:checkTaskEnter("RuneQualityCollect", {}) + + end, + -- ["close"] = function(self, actType, notify) + -- end, +} + function Activity:initActivity(actId, isCrossDay, notify) local actData = csvdb["activity_ctrlCsv"][actId] if not actData then return end diff --git a/src/models/Diner.lua b/src/models/Diner.lua index 57cb7b1..9e744e5 100644 --- a/src/models/Diner.lua +++ b/src/models/Diner.lua @@ -298,6 +298,9 @@ function Diner:expediteSell(slot) self:checkDinerTask(DinerTask.SellDishType, expediteCount, math.ceil(sell.dish / 100)) self:checkDinerTask(DinerTask.SellDishRare, expediteCount, dishData.rarity) self.owner:checkTaskEnter("FoodSell", {count = expediteCount}) + + local needTime = sells[slot].count * dishData.sell_time + sells[slot].time - skynet.timex() + self.owner:pushMsg({type = "food", slot = slot, time = needTime}) end return { expediteCount = expediteCount, diff --git a/src/models/Role.lua b/src/models/Role.lua index a7bc281..5354052 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -27,6 +27,7 @@ function Role:ctor( properties ) self.runeBag = {} self.advData = nil self.activity = nil + self._pushToken = nil self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节 self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳 if self.advOverTime == 0 then @@ -174,6 +175,8 @@ Role.schema = { downCvR = {"number", 0}, -- 下载cv扩展包奖励 feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 + + calTask = {"table", {}}, -- 英雄令活动 日历任务活动 } @@ -395,6 +398,7 @@ function Role:data() downCvR = self:getProperty("downCvR"), -- 下载cv扩展包奖励 feedback = self:getProperty("feedback"), ctime = self:getProperty("ctime"), + calTask = self:getProperty("calTask"), } end diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index 8ea8f74..4216ce6 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -81,6 +81,7 @@ local ItemReason = { birth = 1006, -- 出生奖励 actSign = 1007, -- 活动签到 actPaySign = 1008, -- 活动付费签到 + calendaTask = 1009, -- 英雄帖 -- 餐厅 greenHourse = 1101, -- 食材获得 diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 271a9b0..accd842 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -453,6 +453,7 @@ function RolePlugin.bind(Role) newHero:saveBattleValue() self.heros[heroId] = newHero self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify) + self:checkTaskEnter("HeroQualityCollect", {}) if not params.notNotify then local heroResponse = {} table.insert(heroResponse, newHero:data()) @@ -1742,7 +1743,36 @@ function RolePlugin.bind(Role) end) return gift, checkPoint end + --[[ + "hang" : "挂机资源满", + "box" : "箱子拆解完毕", + "food" : "食物出售完毕", + "adv" : "代理拾荒完毕", + --]] + function Role:pushMsg(params) + if not self._pushToken or self._pushToken == "" then return end + if params.time <= 0 then + self:pushCancel(params) + return + end + local content = string.format("push:%d:%s:%s:%s", self:getProperty("id"), params.type, params.slot or 1, self._pushToken) + notifyClient({content = content, time = math.floor(params.time)}) + end + function Role:pushCancel(params) + if not self._pushToken or self._pushToken == "" then return end + local content = string.format("push:%d:%s:%s:%s", self:getProperty("id"), params.type, params.slot or 1, self._pushToken) + deleteNotify({content = content}) + end + + function Role:pushCancelAll(ptype) + if not self._pushToken or self._pushToken == "" then return end + local pattern = string.format("push:%d:*", self:getProperty("id")) + if ptype then + pattern = string.format("push:%d:%s:*", self:getProperty("id"), ptype) + end + deleteNotify({pattern = pattern}) + end end return RolePlugin \ No newline at end of file diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 697b903..bf28102 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -255,11 +255,11 @@ local CalendaTaskListener = { [TaskType.RoleLevelUp]= {{12, 2, f("level")}}, [TaskType.TowerPass]= {{13, 2, f("level")}}, [TaskType.HeroTalent]= {{14, 1}}, - [TaskType.HangPass]= {{15, 2, f("id")}}, + [TaskType.HangPass]= {{15, 3}}, [TaskType.HeroStarCollect]= {{16, 3}}, [TaskType.FoodSell]= {{17, 1, f("count")}}, [TaskType.HangGet]= {{18, 3, f("reward")}}, - [TaskType.RuneQualityCollect]= {{19, 3, f("id")}}, + [TaskType.RuneQualityCollect]= {{19, 3}}, [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, } } @@ -272,6 +272,7 @@ local TaskListeners = { SudokuListener, ActivityListener, StoreListener, + CalendaTaskListener, } local RoleTask = {} @@ -587,6 +588,8 @@ function RoleTask.bind(Role) end function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) + --print("check calenda taskl", mainType, subType, param1, param2) + if not self.activity then return end local open, actId = self.activity:isOpen("CalendaTask") local actData = csvdb["activity_ctrlCsv"][actId] if not actData then return end @@ -606,11 +609,86 @@ function RoleTask.bind(Role) elseif subType == 2 then -- 直接赋值 calTask[id] = param1 elseif subType == 3 then -- 自定义类型 + if cfg.type == 7 then -- 英雄品质收集进度 + local count = 0 + for _, hero in pairs(self.heros) do + local unitData = csvdb["unitCsv"][hero:getProperty("type")] + if unitData then + if cfg.condition2 <= unitData.rare then + count = count + 1 + end + end + end + if (calTask[id] or 0) < count then + calTask[id] = count + end + elseif cfg.type == 5 then -- 英雄等级收集进度 + local count = 0 + for _, hero in pairs(self.heros) do + if cfg.condition2 <= hero:getProperty("level") then + count = count + 1 + end + end + if calTask[id] < count then + calTask[id] = count + end + elseif cfg.type == 16 then -- 英雄星级收集进度 + local count = 0 + for _, hero in pairs(self.heros) do + if cfg.condition2 <= hero:getProperty("wakeL") then + count = count + 1 + end + end + if calTask[id] < count then + calTask[id] = count + end + elseif cfg.type == 18 then -- 挂机累计收获id,y个 + for rid, v in pairs(param1) do + if cfg.condition2 == rid then + calTask[id] = (calTask[id] or 0) + v + end + end + elseif cfg.type == 19 then -- x名英雄装备y品质以上符文套装 + local count = 0 + for _, hero in pairs(self.heros) do + local rcount = 0 + for _,uid in pairs(hero:getRunes()) do + if uid > 0 then + local runeData = self.runeBag[uid] + if runeData then + local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")] + + if csvData and cfg.condition2 <= csvData.rarity then + rcount = rcount + 1 + end + end + end + end + if rcount == 6 then + count = count + 1 + end + end + calTask[id] = count + elseif cfg.type == 20 then -- 开启x品质时钟箱子 + if cfg.condition2 <= (param2 or 0) then + calTask[id] = (calTask[id] or 0) + param2 + end + elseif cfg.type == 15 then -- 通关关卡 + if (calTask[id] or 0) == 0 then + local hangPass = self:getProperty("hangPass") + local diff = math.floor(cfg.condition2 / 10000) + if (hangPass[diff] or 0) >= cfg.condition1 then + calTask[id] = 1 + end + end + end end end end end end + self:updateProperty({field = "calTask", value = calTask, notNotify = notNotify}) + --dump(calTask) end end diff --git a/src/models/Store.lua b/src/models/Store.lua index e912457..c559f64 100644 --- a/src/models/Store.lua +++ b/src/models/Store.lua @@ -57,7 +57,7 @@ end function Store:onCrossDay() self:sendMonthCardEmail() self:deleteExpireLimitGoods() - self:checkPaySignReward() + --self:checkPaySignReward() end -- 删除过期商品 @@ -356,32 +356,46 @@ function GetActGoodsIndex(goodsType) return ActGoodsType[goodsType] or 0 end --- 购买付费签到 按开服时间算奖励 -function Store:onBuyPaySignCard(dur) - local curTs = skynet.timex() +function Store:SetActGoodsFlag(goodsType, flag) local actGoodsFlag = self:getProperty("actGoodsFlag") or {} - local goodsIndex = GetActGoodsIndex("paySignIn") + local goodsIndex = GetActGoodsIndex(goodsType) if goodsIndex == 0 then print("get act goods index fail :paySignIn") return end - actGoodsFlag[goodsIndex] = 1 + actGoodsFlag[goodsIndex] = flag self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag}) - -- 发钱 - local change - local reward, curData = self.owner.activity:getPaySignReward() - if next(reward) then - self.owner.activity:updateActData("PaySignIn", curData) - reward, change = self.owner:award(reward, {log = {desc = "actPaySign"}}) - end +end + +-- 购买付费签到 按开服时间算奖励 +function Store:onBuyPaySignCard(dur) + local curTs = skynet.timex() - self.owner:log("activity", { - activity_id = 0, -- 活动ID(或活动指定任务的ID) - activity_type = self.owner.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 - activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} - }) + self:SetActGoodsFlag("paySignIn", curTs) - SendPacket(actionCodes.Activity_actPaySignRewardNtf, MsgPack.pack(self.owner:packReward(reward, change))) + --local actGoodsFlag = self:getProperty("actGoodsFlag") or {} + --local goodsIndex = GetActGoodsIndex("paySignIn") + --if goodsIndex == 0 then + -- print("get act goods index fail :paySignIn") + -- return + --end + --actGoodsFlag[goodsIndex] = 1 + --self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag}) + -- 发钱 + --local change + --local reward, curData = self.owner.activity:getPaySignReward() + --if next(reward) then + -- self.owner.activity:updateActData("PaySignIn", curData) + -- reward, change = self.owner:award(reward, {log = {desc = "actPaySign"}}) + --end + + --self.owner:log("activity", { + -- activity_id = 0, -- 活动ID(或活动指定任务的ID) + -- activity_type = self.owner.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 + -- activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + --}) + + --SendPacket(actionCodes.Activity_actPaySignRewardNtf, MsgPack.pack(self.owner:packReward(reward, change))) end function Store:checkPaySignReward() diff --git a/src/utils/CommonFunc.lua b/src/utils/CommonFunc.lua index b7e2798..2688dae 100644 --- a/src/utils/CommonFunc.lua +++ b/src/utils/CommonFunc.lua @@ -161,6 +161,18 @@ function diffFromOpen() return math.floor((now - openTime) / DAY_SEC) end +function diffFromTs(ts) + local now = skynet.timex() + local tm = os.date("*t", ts) + + local time = os.time({year = tm.year, month = tm.month, day = tm.day, hour = RESET_TIME}) + if now < time then + return -1 + end + + return math.floor((now - time) / DAY_SEC) +end + function getServerOpenTs() local openTime = os.time{ year = tonum(SERV_OPEN:sub(1,4)), @@ -298,7 +310,7 @@ function notifyClient(params) params.key = "zhaolugame20170831" local status, body = httpc.get(skynet.getenv("codeurl"), - "/mipush/notify_user?" .. httpGetFormatData(params), {}, {}) + "/push/notify_user?" .. httpGetFormatData(params), {}, {}) if tonumber(status) ~= 200 then skynet.error(status, body) return @@ -313,7 +325,7 @@ function deleteNotify(params) params.key = "zhaolugame20170831" local status, body = httpc.get(skynet.getenv("codeurl"), - "/mipush/delete_notify?" .. httpGetFormatData(params), {}, {}) + "/push/delete_notify?" .. httpGetFormatData(params), {}, {}) if tonumber(status) ~= 200 then skynet.error(status, body) return -- libgit2 0.21.2