Commit bd4fb5416f0e782c2ef0ff27b7b0756d51be6efe

Authored by zhouhaihai
1 parent c581c6e9

增加物品过期系统

src/actions/GmAction.lua
@@ -87,6 +87,11 @@ function _M.silent(role, pms) @@ -87,6 +87,11 @@ function _M.silent(role, pms)
87 return "禁言成功" 87 return "禁言成功"
88 end 88 end
89 89
  90 +function _M.pvp_cross_head(role, pms)
  91 + role:awardExpireItem(tonum(pms.expire), pms.reward, {log = {desc = "pvpCHead"}})
  92 + return "成功"
  93 +end
  94 +
90 95
91 local helpDes = {{"描述", "指令", "参数1", "参数2" ,"参数3"}} 96 local helpDes = {{"描述", "指令", "参数1", "参数2" ,"参数3"}}
92 97
src/actions/RoleAction.lua
@@ -942,9 +942,7 @@ function _M.changeHeadRpc(agent, data) @@ -942,9 +942,7 @@ function _M.changeHeadRpc(agent, data)
942 if not unlock then 942 if not unlock then
943 return 943 return
944 end 944 end
945 - role:updateProperty({field = "headId" ,value = id})  
946 - role:changeCrossServerPvpSelfInfo("headId")  
947 - role:log("role_action", {desc = "changeHead", int1 = id}) 945 + role:changeHead(id)
948 946
949 SendPacket(actionCodes.Role_changeHeadRpc, "") 947 SendPacket(actionCodes.Role_changeHeadRpc, "")
950 return true 948 return true
src/models/Role.lua
@@ -54,6 +54,7 @@ Role.schema = { @@ -54,6 +54,7 @@ Role.schema = {
54 level = {"number", 1}, 54 level = {"number", 1},
55 exp = {"number", 0}, 55 exp = {"number", 0},
56 items = {"string", ""}, 56 items = {"string", ""},
  57 + expireItem = {"table", {}}, --物品过期检查
57 funcOpen = {"table", {}}, --功能是否开放 58 funcOpen = {"table", {}}, --功能是否开放
58 funcLv = {"table", {}}, --功能等级 59 funcLv = {"table", {}}, --功能等级
59 -- loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL 60 -- loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL
src/models/RolePlugin.lua
@@ -139,6 +139,56 @@ function RolePlugin.bind(Role) @@ -139,6 +139,56 @@ function RolePlugin.bind(Role)
139 return reward, allChange --实际获得的奖励 和 最高级奖励转化过程 139 return reward, allChange --实际获得的奖励 和 最高级奖励转化过程
140 end 140 end
141 141
  142 + function Role:awardExpireItem(expireTime, gift, params)
  143 + if expireTime <= skynet.timex() then
  144 + return
  145 + end
  146 + local reward = self:award(gift, params)
  147 + local expireItem = self:getProperty("expireItem")
  148 + for itemId, _ in pairs(reward) do
  149 + expireItem[itemId] = expireTime
  150 + end
  151 + self:setProperty("expireItem", expireItem)
  152 + end
  153 +
  154 + function Role:checkExpireItem(notNotify)
  155 + local expireItem = self:getProperty("expireItem")
  156 + local now = skynet.timex()
  157 + for itemId, expireTime in pairs(expireItem) do
  158 + if expireTime <= now then
  159 + expireItem[itemId] = nil
  160 + local itemCount = self:getItemCount(itemId)
  161 + if itemCount > 0 then
  162 + -- 过期物品删掉
  163 + self:addItem({itemId = itemId, count = -itemCount, log = {desc = "expire"}, notNotify = notNotify}) --过期
  164 +
  165 + local itemData = csvdb["itemCsv"][itemId]
  166 + if itemData then
  167 + if itemData.type == ItemType.Head then
  168 + -- 检查头像是不是在穿戴
  169 + if self:getProperty("headId") == itemId then
  170 + self:changeHead(globalCsv.defaultHead, notNotify)
  171 +
  172 + local headData = csvdb["player_iconCsv"][itemId]
  173 + -- pvp 跨服竞技场奖励
  174 + if headData and headData.path == 2 then
  175 + redisproxy:insertEmail({roleId = self:getProperty("id"), emailId = 19})
  176 + end
  177 + end
  178 + end
  179 + end
  180 + end
  181 + end
  182 + end
  183 + self:setProperty("expireItem", expireItem)
  184 + end
  185 +
  186 + function Role:changeHead(id, notNotify)
  187 + self:updateProperty({field = "headId" ,value = id, notNotify = notNotify})
  188 + self:changeCrossServerPvpSelfInfo("headId")
  189 + self:log("role_action", {desc = "changeHead", int1 = id})
  190 + end
  191 +
142 function Role:addPlayExp(addExp, params) 192 function Role:addPlayExp(addExp, params)
143 local level = self:getProperty("level") 193 local level = self:getProperty("level")
144 if not csvdb["player_expCsv"][level + 1] then 194 if not csvdb["player_expCsv"][level + 1] then
@@ -996,10 +1046,9 @@ function RolePlugin.bind(Role) @@ -996,10 +1046,9 @@ function RolePlugin.bind(Role)
996 1046
997 1047
998 function Role:getCurDinerRankKey() 1048 function Role:getCurDinerRankKey()
999 - local StdDinerRankTime = toUnixtime("20190101"..string.format("%02x", math.floor(self:getTimeResetDataStart(TimeReset.DinerRank) / 3600))) --跨天时间  
1000 - local now = skynet.timex() 1049 + local round = self:getTimeResetRound(TimeReset.DinerRank)
1001 local idx = 1 1050 local idx = 1
1002 - if math.floor((now - StdDinerRankTime) / 86400) % 2 == 1 then 1051 + if round % 2 == 1 then
1003 idx = 2 1052 idx = 2
1004 end 1053 end
1005 return RANK_DINER[idx] 1054 return RANK_DINER[idx]
@@ -1314,6 +1363,15 @@ function RolePlugin.bind(Role) @@ -1314,6 +1363,15 @@ function RolePlugin.bind(Role)
1314 end 1363 end
1315 end 1364 end
1316 1365
  1366 + function Role:getAdvRankKey()
  1367 + local round = self:getProperty("advElS")
  1368 + local idx = 1
  1369 + if round % 2 == 1 then
  1370 + idx = 2
  1371 + end
  1372 + return RANK_ADV[idx]
  1373 + end
  1374 +
1317 end 1375 end
1318 1376
1319 return RolePlugin 1377 return RolePlugin
1320 \ No newline at end of file 1378 \ No newline at end of file
src/models/RoleTimeReset.lua
@@ -11,6 +11,8 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response) @@ -11,6 +11,8 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response)
11 self:setProperty("dTask", {}) 11 self:setProperty("dTask", {})
12 self:advRandomSupportEffect() 12 self:advRandomSupportEffect()
13 13
  14 + self:checkExpireItem(not notify)
  15 +
14 response.dTask = {} 16 response.dTask = {}
15 response.advSup = self:getProperty("advSup") 17 response.advSup = self:getProperty("advSup")
16 end 18 end