diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index c83a6fa..130cb85 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -87,6 +87,11 @@ function _M.silent(role, pms) return "禁言成功" end +function _M.pvp_cross_head(role, pms) + role:awardExpireItem(tonum(pms.expire), pms.reward, {log = {desc = "pvpCHead"}}) + return "成功" +end + local helpDes = {{"描述", "指令", "参数1", "参数2" ,"参数3"}} diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index e450c61..1db5a3d 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -942,9 +942,7 @@ function _M.changeHeadRpc(agent, data) if not unlock then return end - role:updateProperty({field = "headId" ,value = id}) - role:changeCrossServerPvpSelfInfo("headId") - role:log("role_action", {desc = "changeHead", int1 = id}) + role:changeHead(id) SendPacket(actionCodes.Role_changeHeadRpc, "") return true diff --git a/src/models/Role.lua b/src/models/Role.lua index 7ceefd8..d2152dc 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -54,6 +54,7 @@ Role.schema = { level = {"number", 1}, exp = {"number", 0}, items = {"string", ""}, + expireItem = {"table", {}}, --物品过期检查 funcOpen = {"table", {}}, --功能是否开放 funcLv = {"table", {}}, --功能等级 -- loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 441bac5..976fd2d 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -139,6 +139,56 @@ function RolePlugin.bind(Role) return reward, allChange --实际获得的奖励 和 最高级奖励转化过程 end + function Role:awardExpireItem(expireTime, gift, params) + if expireTime <= skynet.timex() then + return + end + local reward = self:award(gift, params) + local expireItem = self:getProperty("expireItem") + for itemId, _ in pairs(reward) do + expireItem[itemId] = expireTime + end + self:setProperty("expireItem", expireItem) + end + + function Role:checkExpireItem(notNotify) + local expireItem = self:getProperty("expireItem") + local now = skynet.timex() + for itemId, expireTime in pairs(expireItem) do + if expireTime <= now then + expireItem[itemId] = nil + local itemCount = self:getItemCount(itemId) + if itemCount > 0 then + -- 过期物品删掉 + self:addItem({itemId = itemId, count = -itemCount, log = {desc = "expire"}, notNotify = notNotify}) --过期 + + local itemData = csvdb["itemCsv"][itemId] + if itemData then + if itemData.type == ItemType.Head then + -- 检查头像是不是在穿戴 + if self:getProperty("headId") == itemId then + self:changeHead(globalCsv.defaultHead, notNotify) + + local headData = csvdb["player_iconCsv"][itemId] + -- pvp 跨服竞技场奖励 + if headData and headData.path == 2 then + redisproxy:insertEmail({roleId = self:getProperty("id"), emailId = 19}) + end + end + end + end + end + end + end + self:setProperty("expireItem", expireItem) + end + + function Role:changeHead(id, notNotify) + self:updateProperty({field = "headId" ,value = id, notNotify = notNotify}) + self:changeCrossServerPvpSelfInfo("headId") + self:log("role_action", {desc = "changeHead", int1 = id}) + end + function Role:addPlayExp(addExp, params) local level = self:getProperty("level") if not csvdb["player_expCsv"][level + 1] then @@ -996,10 +1046,9 @@ function RolePlugin.bind(Role) function Role:getCurDinerRankKey() - local StdDinerRankTime = toUnixtime("20190101"..string.format("%02x", math.floor(self:getTimeResetDataStart(TimeReset.DinerRank) / 3600))) --跨天时间 - local now = skynet.timex() + local round = self:getTimeResetRound(TimeReset.DinerRank) local idx = 1 - if math.floor((now - StdDinerRankTime) / 86400) % 2 == 1 then + if round % 2 == 1 then idx = 2 end return RANK_DINER[idx] @@ -1314,6 +1363,15 @@ function RolePlugin.bind(Role) end end + function Role:getAdvRankKey() + local round = self:getProperty("advElS") + local idx = 1 + if round % 2 == 1 then + idx = 2 + end + return RANK_ADV[idx] + end + end return RolePlugin \ No newline at end of file diff --git a/src/models/RoleTimeReset.lua b/src/models/RoleTimeReset.lua index 899981c..bdaa2e2 100644 --- a/src/models/RoleTimeReset.lua +++ b/src/models/RoleTimeReset.lua @@ -11,6 +11,8 @@ ResetFunc["CrossDay"] = function(self, notify, response) self:setProperty("dTask", {}) self:advRandomSupportEffect() + self:checkExpireItem(not notify) + response.dTask = {} response.advSup = self:getProperty("advSup") end -- libgit2 0.21.2