From be4e8031d77ccd09b4d260a91761cfe65e55d9a9 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Tue, 28 Jul 2020 13:57:21 +0800 Subject: [PATCH] 活动 拾荒 --- src/actions/ActivityAction.lua | 8 ++++---- src/actions/AdvAction.lua | 16 ++++++++++------ src/actions/RoleAction.lua | 4 ++-- src/adv/Adv.lua | 3 +-- src/models/Activity.lua | 21 +++++++++++---------- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index 71362fb..e5e8a07 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -135,11 +135,11 @@ end function _M.actSignRpc(agent, data) local role = agent.role - if not role.activity:isOpen("Sign") then return end + if not role.activity:isOpen("Sign") then return 1 end local curData = role.activity:getActData("Sign") local reward = {} - for day, csvData in ipairs(csvdb["new_signlnCsv"]) do + for day, csvData in ipairs(csvdb["new_signInCsv"]) do if day <= (curData[0] or 0) then if not curData[day] then curData[day] = -1 @@ -153,8 +153,8 @@ function _M.actSignRpc(agent, data) end end if next(reward) then - self.activity:updateActData("Sign", curData) - reward = role:award(reward, {log = "actSign"}) + role.activity:updateActData("Sign", curData) + reward = role:award(reward, {log = {desc = "actSign"}}) end SendPacket(actionCodes.Activity_actSignRpc, MsgPack.pack(reward)) return true diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index d1f0d47..9954d1e 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -197,7 +197,7 @@ function _M.startHangRpc(agent, data) if AdvCommon.isEndless(chapterId) then return end -- 无尽没有代理 - local advRelay = self.owner:getProperty("advRelay") + local advRelay = role:getProperty("advRelay") if not next(advRelay[chapterId] or {}) then return end -- 没有开放 @@ -212,7 +212,6 @@ function _M.startHangRpc(agent, data) player[attrName] = (player[attrName] or 0) + hero[attrName] end player[attrName] = player[attrName] * (globalCsv.adv_battle_attr_ratio[attrName] or 1) - player.growth[attrName] = player[attrName] * (globalCsv.adv_battle_attr_growth_ratio[attrName] or 1) end local battleV = 1 * player["hp"] @@ -296,9 +295,12 @@ function _M.endHangRpc(agent, data) -- 英雄加成 local idleUnit = chapterData.idleUnit:toNumMap() local upUnit = 0 - for slot, heroId in pairs(info.format or {}) do - if idleUnit[heroId] then - upUnit = upUnit + idleUnit[heroId] + for slot, heroId in pairs((info.format or {}).heros or {}) do + local hero = role.heros[heroId] + if hero then + if idleUnit[hero:getProperty("type")] then + upUnit = upUnit + idleUnit[hero:getProperty("type")] + end end end -- 中继加成 @@ -308,6 +310,8 @@ function _M.endHangRpc(agent, data) for _, campsite in ipairs(campsiteCsv) do if campsite.floor <= advPass[chapterId] then maxCampsite = campsite + else + break end end @@ -315,7 +319,7 @@ function _M.endHangRpc(agent, data) local idleReward = chapterData.idleReward:toNumMap() for itemId, count in pairs(idleReward) do - idleReward[itemId] = count * (maxCampsite.idleValue + upUnit) / 100 + idleReward[itemId] = math.floor(count * (maxCampsite.idleValue + upUnit) / 100) end reward = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}}) else diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 005f48c..3aa965e 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -122,8 +122,8 @@ function _M.loginRpc( agent, data ) -- 跨天登陆事件 local resetMode = role:updateTimeReset(now) - if not resetMode["CrossDay"] then -- 没有跨天 - self.activity:checkActivityStatus(now, false, false) + if not resetMode or not resetMode["CrossDay"] then -- 没有跨天 + role.activity:checkActivityStatus(now, false, false) end redisproxy:zadd(FRIEND_RECOMMEND, now, roleId) diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index df3a4c2..7538fd8 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -820,14 +820,13 @@ function Adv:over(success, rewardRatio, overType) advAFGet = {}, advAFWear = {}, }) - self:backEnd(success, score, scoreInfo, reward, overType, scoreReward, chapterId) self:pushBackEvent(AdvBackEventType.End, { success = success, score = score, scoreInfo = scoreInfo, reward = reward, type = overType, - scoreAward = scoreAward, + scoreAward = scoreReward, chapterId = chapterId, backAdvCount = backAdvCount, }) diff --git a/src/models/Activity.lua b/src/models/Activity.lua index 70e227b..64c56d7 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -1,5 +1,5 @@ local Activity = class("Activity", require("shared.ModelBase")) - +local string_format = string.format Activity.ActivityType = { Sign = 1, -- 签到 @@ -22,12 +22,13 @@ end Activity.schema = { - ctime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} + actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} act1 = {"table", {}}, -- {0 = day, 1= -1, 2 = -1} == 签到活动 } function Activity:data() return { + actime = self:getProperty("actime"), act1 = self:getProperty("act1"), } end @@ -111,30 +112,30 @@ end -- 跨天刷新 --登录刷新 function Activity:checkActivityStatus(now, isCrossDay, notify) self._isOpen = {} - local ctime = self:getProperty("ctime") + local actime = self:getProperty("actime") local change = false - for actType, actData in paris(csvdb["activity_ctrlCsv"]) do + for actType, actData in pairs(csvdb["activity_ctrlCsv"]) do local isOpen, startTime = self:isOpenRaw(actType, now) self._isOpen[actType] = isOpen if isOpen then - if ctime[actType] and ctime[actType] == startTime then -- 还是之前的状态 开放中 + if actime[actType] and actime[actType] == startTime then -- 还是之前的状态 开放中 else -- 重置 - ctime[actType] = startTime + actime[actType] = startTime self:closeActivity(actType, notify, true) self:initActivity(actType, isCrossDay, notify) change = true end else - if ctime[actType] then + if actime[actType] then self:closeActivity(actType, notify) - ctime[actType] = nil + actime[actType] = nil change = true end end end if change then - self:setProperty("ctime", ctime) + self:updateProperty({field = "actime", value = actime, notNotify = not notify}) end end @@ -153,7 +154,7 @@ activityFunc[Activity.ActivityType.Sign] = { ["crossDay"] = function(self, actType, notify) local curData = self:getActData(actType) curData[0] = (curData[0] or 0) + 1 - local actData = csvdb["new_signlnCsv"] + local actData = csvdb["new_signInCsv"] if curData[0] > #actData then return end -- 满了就忽略了 -- 没满更新一下 -- libgit2 0.21.2