Commit bd4fb5416f0e782c2ef0ff27b7b0756d51be6efe
1 parent
c581c6e9
增加物品过期系统
Showing
5 changed files
with
70 additions
and
6 deletions
Show diff stats
src/actions/GmAction.lua
... | ... | @@ -87,6 +87,11 @@ function _M.silent(role, pms) |
87 | 87 | return "禁言成功" |
88 | 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 | 96 | local helpDes = {{"描述", "指令", "参数1", "参数2" ,"参数3"}} |
92 | 97 | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -942,9 +942,7 @@ function _M.changeHeadRpc(agent, data) |
942 | 942 | if not unlock then |
943 | 943 | return |
944 | 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 | 947 | SendPacket(actionCodes.Role_changeHeadRpc, "") |
950 | 948 | return true | ... | ... |
src/models/Role.lua
... | ... | @@ -54,6 +54,7 @@ Role.schema = { |
54 | 54 | level = {"number", 1}, |
55 | 55 | exp = {"number", 0}, |
56 | 56 | items = {"string", ""}, |
57 | + expireItem = {"table", {}}, --物品过期检查 | |
57 | 58 | funcOpen = {"table", {}}, --功能是否开放 |
58 | 59 | funcLv = {"table", {}}, --功能等级 |
59 | 60 | -- loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -139,6 +139,56 @@ function RolePlugin.bind(Role) |
139 | 139 | return reward, allChange --实际获得的奖励 和 最高级奖励转化过程 |
140 | 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 | 192 | function Role:addPlayExp(addExp, params) |
143 | 193 | local level = self:getProperty("level") |
144 | 194 | if not csvdb["player_expCsv"][level + 1] then |
... | ... | @@ -996,10 +1046,9 @@ function RolePlugin.bind(Role) |
996 | 1046 | |
997 | 1047 | |
998 | 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 | 1050 | local idx = 1 |
1002 | - if math.floor((now - StdDinerRankTime) / 86400) % 2 == 1 then | |
1051 | + if round % 2 == 1 then | |
1003 | 1052 | idx = 2 |
1004 | 1053 | end |
1005 | 1054 | return RANK_DINER[idx] |
... | ... | @@ -1314,6 +1363,15 @@ function RolePlugin.bind(Role) |
1314 | 1363 | end |
1315 | 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 | 1375 | end |
1318 | 1376 | |
1319 | 1377 | return RolePlugin |
1320 | 1378 | \ No newline at end of file | ... | ... |
src/models/RoleTimeReset.lua
... | ... | @@ -11,6 +11,8 @@ ResetFunc["CrossDay"] = function(self, notify, response) |
11 | 11 | self:setProperty("dTask", {}) |
12 | 12 | self:advRandomSupportEffect() |
13 | 13 | |
14 | + self:checkExpireItem(not notify) | |
15 | + | |
14 | 16 | response.dTask = {} |
15 | 17 | response.advSup = self:getProperty("advSup") |
16 | 18 | end | ... | ... |