Commit 404d5beef1eee7c4ad839b4ad724edfc0ffba4be
Merge branch 'develop' into player
Showing
16 changed files
with
120 additions
and
33 deletions
Show diff stats
src/ProtocolCode.lua
src/RedisKeys.lua
... | ... | @@ -17,7 +17,7 @@ RANK_TOWER = "rank:tower" |
17 | 17 | RANK_TOWER_INFO = "rank:tower:info" |
18 | 18 | |
19 | 19 | -- adv |
20 | -RANK_ADV = "rank:adv" | |
20 | +RANK_ADV = {"rank:adv1", "rank:adv2"} | |
21 | 21 | RANK_ADV_INFO = "rank:adv:info" |
22 | 22 | |
23 | 23 | RANK_DINER = {"rank:diner1", "rank:diner2"} -- 餐厅排行榜 两个每天互换 | ... | ... |
src/actions/AdvAction.lua
... | ... | @@ -721,7 +721,7 @@ function _M.rankRpc(agent, data) |
721 | 721 | local role = agent.role |
722 | 722 | |
723 | 723 | local list = {} |
724 | - local ids = redisproxy:zrevrange(RANK_ADV, 0 , 99, "WITHSCORES") | |
724 | + local ids = redisproxy:zrevrange(role:getAdvRankKey(), 0 , 99, "WITHSCORES") | |
725 | 725 | local redret = {} |
726 | 726 | if ids and next(ids) then |
727 | 727 | redret = redisproxy:pipelining(function (red) |
... | ... | @@ -739,8 +739,8 @@ function _M.rankRpc(agent, data) |
739 | 739 | list[i].player = player |
740 | 740 | end |
741 | 741 | local redret = redisproxy:pipelining(function(red) |
742 | - red:ZREVRANK(RANK_ADV, role:getProperty("id")) | |
743 | - red:zscore(RANK_ADV, role:getProperty("id")) | |
742 | + red:ZREVRANK(role:getAdvRankKey(), role:getProperty("id")) | |
743 | + red:zscore(role:getAdvRankKey(), role:getProperty("id")) | |
744 | 744 | end) |
745 | 745 | local rank = redret[1] |
746 | 746 | if not rank then | ... | ... |
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/HttpAction.lua
... | ... | @@ -197,6 +197,11 @@ function _M.broadcast(query) |
197 | 197 | return "广播成功" |
198 | 198 | end |
199 | 199 | |
200 | +function _M.endless_season_check() | |
201 | + mcast_util.pub_world(actionCodes.Sys_endlessSeason, "") | |
202 | + return "success" | |
203 | +end | |
204 | + | |
200 | 205 | function _M.online(query) |
201 | 206 | local count = datacenter.get("onlineCount") or 0 |
202 | 207 | return count | ... | ... |
src/actions/PvpAction.lua
... | ... | @@ -961,11 +961,11 @@ function _M.crossBetRpc(agent, data) |
961 | 961 | local roleId = role:getProperty("id") |
962 | 962 | local msg = MsgPack.unpack(data) |
963 | 963 | |
964 | - if not role:isTimeResetOpen(TimeReset.PvpCross) then return end | |
965 | - if msg.idx ~= 1 and msg.idx ~= 2 then return end | |
964 | + if not role:isTimeResetOpen(TimeReset.PvpCross) then return 1 end | |
965 | + if msg.idx ~= 1 and msg.idx ~= 2 then return 2 end | |
966 | 966 | |
967 | - local result = role:setCrossServerPvpBet(msg.idx) | |
968 | - if not result then return end | |
967 | + local result, code = role:setCrossServerPvpBet(msg.idx) | |
968 | + if not result then return 10 + code end | |
969 | 969 | |
970 | 970 | role:log("pvp_action", {desc = "crossBet"}) |
971 | 971 | SendPacket(actionCodes.Pvp_crossBetRpc, MsgPack.pack(result)) | ... | ... |
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/adv/Adv.lua
... | ... | @@ -716,7 +716,7 @@ function Adv:over(success, rewardRatio, overType) |
716 | 716 | end |
717 | 717 | |
718 | 718 | local roleId = self.owner:getProperty("id") |
719 | - local oldMaxScore = tonum(redisproxy:zscore(RANK_ADV, roleId)) | |
719 | + local oldMaxScore = tonum(redisproxy:zscore(self.owner:getAdvRankKey(), roleId)) | |
720 | 720 | if score > oldMaxScore then |
721 | 721 | local team = self.owner:getProperty("advTeam") |
722 | 722 | local curInfo = { |
... | ... | @@ -728,7 +728,7 @@ function Adv:over(success, rewardRatio, overType) |
728 | 728 | format = self.owner:getTeamHerosInfo(team.heros), |
729 | 729 | } |
730 | 730 | redisproxy:pipelining(function (red) |
731 | - red:zadd(RANK_ADV, score, roleId) --更新分数 | |
731 | + red:zadd(self.owner:getAdvRankKey(), score, roleId) --更新分数 | |
732 | 732 | red:hset(RANK_ADV_INFO, roleId, MsgPack.pack(curInfo)) |
733 | 733 | end) |
734 | 734 | end |
... | ... | @@ -1617,7 +1617,7 @@ function Adv:mapItemChange(ctype) |
1617 | 1617 | end |
1618 | 1618 | if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then |
1619 | 1619 | block.event.item = changeTo |
1620 | - self:backBlockChange(roomId, blockId) | |
1620 | + self:backBlockChange(roomId, blockId, ctype) | |
1621 | 1621 | end |
1622 | 1622 | end |
1623 | 1623 | end |
... | ... | @@ -1724,8 +1724,8 @@ function Adv:backEnd(success, score, scoreInfo, reward, overType, scoreAward) |
1724 | 1724 | self:pushBackEvent(AdvBackEventType.End, {success = success, score = score, scoreInfo = scoreInfo, reward = reward, type = overType, scoreAward = scoreAward}) |
1725 | 1725 | end |
1726 | 1726 | |
1727 | -function Adv:backBlockChange(roomId, blockId) | |
1728 | - self:pushBackEvent(AdvBackEventType.BlockChange, {roomId = roomId, blockId = blockId}) | |
1727 | +function Adv:backBlockChange(roomId, blockId, itemChangeType) | |
1728 | + self:pushBackEvent(AdvBackEventType.BlockChange, {roomId = roomId, blockId = blockId, itemChangeType = itemChangeType}) | |
1729 | 1729 | end |
1730 | 1730 | |
1731 | 1731 | function Adv:backDead(enemyId, exp) | ... | ... |
src/adv/AdvPlayer.lua
... | ... | @@ -414,7 +414,9 @@ function BaseObject:recover(value, releaser, params) |
414 | 414 | params = params or {} |
415 | 415 | value = math.max(0, math.ceil(value)) |
416 | 416 | self.hp = math.min(self.hpMax, self.hp + value) |
417 | - self.battle.adv:pushBackEvent(AdvBackEventType.HpChange, {change = value}) | |
417 | + if self:is("Player") then | |
418 | + self.battle.adv:pushBackEvent(AdvBackEventType.HpChange, {change = value}) | |
419 | + end | |
418 | 420 | end |
419 | 421 | |
420 | 422 | function BaseObject:addSpecialSkill(skillId, skillLevel, target) | ... | ... |
src/agent.lua
... | ... | @@ -51,6 +51,15 @@ end |
51 | 51 | |
52 | 52 | local _pipelinings = {} --可同时多个序列 栈的形式保证嵌套不出错 |
53 | 53 | function SendPacket(actionCode, bin, client_fd) |
54 | + -- 内部消息不扩散出去 | |
55 | + if actionCode == actionCodes.Sys_endlessSeason then | |
56 | + if agentInfo.role then | |
57 | + agentInfo.role:advEndlessSeasonCheck() | |
58 | + end | |
59 | + return | |
60 | + end | |
61 | + | |
62 | + | |
54 | 63 | client_fd = client_fd or agentInfo.client_fd |
55 | 64 | |
56 | 65 | local handlerName = actionHandlers[actionCode] | ... | ... |
src/models/HeroPlugin.lua
... | ... | @@ -193,11 +193,12 @@ function HeroPlugin.bind(Hero) |
193 | 193 | return attrs |
194 | 194 | end |
195 | 195 | |
196 | - -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击 + 命中 * 4)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] | |
197 | - function Hero:getBattleValue(activeRelation) | |
198 | - local attrs = self:getTotalAttrs({activeRelation = activeRelation}) | |
199 | - local battleValue = ((attrs["hp"] + attrs["def"] * 7 + attrs["miss"] * 4) * (attrs["atk"] + attrs["hit"] * 4) * (1 + attrs["crit"]/100 * attrs["critHurt"]/100) * attrs["atkSpeed"] / 60000) ^ 0.8 | |
200 | - return math.floor(battleValue) | |
196 | + | |
197 | + -- 战斗力(当前属性)= POWER[(生命 + 防御 * 23 + 闪避 * 4)*(攻击*14 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] | |
198 | + function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成 | |
199 | + local attrs = self:getTotalAttrs({activeRelation = activeRelation}) | |
200 | + local battleValue = ((attrs["hp"] + attrs["def"] * 23 + attrs["miss"] * 4) * (attrs["atk"] * 14 + attrs["hit"] * 2) * (1 + attrs["crit"]/100 * attrs["critHurt"]/100) * attrs["atkSpeed"] / 600000) ^ 0.8 | |
201 | + return math.floor(battleValue) | |
201 | 202 | end |
202 | 203 | |
203 | 204 | function Hero:saveBattleValue() | ... | ... |
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/RolePvp.lua
... | ... | @@ -468,31 +468,33 @@ function Role:getCrossServerPvpBetInfo() |
468 | 468 | end |
469 | 469 | |
470 | 470 | function Role:setCrossServerPvpBet(idx) |
471 | - if not self:isTimeResetOpen(TimeReset.PvpCross) then return end | |
471 | + if not self:isTimeResetOpen(TimeReset.PvpCross) then return false , 1 end | |
472 | 472 | local crossTime = skynet.timex() - self:getTimeResetStartTime(TimeReset.PvpCross) |
473 | 473 | local aday = 3600 * 24 |
474 | 474 | local day = math.ceil(crossTime / aday) -- 当前是第几个比赛日 |
475 | 475 | local ctime = crossTime % aday -- 当前在本天 经过多少时间 |
476 | 476 | |
477 | 477 | if day > globalCsv.pvp_cross_server_day or ctime >= globalCsv.pvp_cross_server_stop_stake then |
478 | - return | |
478 | + return false , 2 | |
479 | 479 | end |
480 | 480 | local pvpBet = self:getProperty("pvpBet") |
481 | - if pvpBet[day] then return end | |
481 | + if pvpBet[day] then return false , 3 end | |
482 | 482 | |
483 | - local cost = {[ItemId.Gold] = self:getProperty("level") * globalCsv.pvp_cross_bet_pre_level} | |
484 | - if not self:checkItemEnough(cost) then return end | |
483 | + local costNum = self:getProperty("level") * globalCsv.pvp_cross_bet_pre_level | |
484 | + local cost = {[ItemId.Gold] = costNum} | |
485 | + if not self:checkItemEnough(cost) then return false , 4 end | |
485 | 486 | |
486 | - local ok, result = pcall(skynet.call, pvpd, "lua", "setBet", idx) | |
487 | + local ok, result = pcall(skynet.call, pvpd, "lua", "setBet", idx, self:getProperty("id"), costNum) | |
487 | 488 | if ok then |
488 | 489 | if result then |
489 | 490 | self:costItems(cost, {log = {desc = "crossPvpBet", short1 = day}}) |
490 | 491 | pvpBet[day] = {idx, cost[ItemId.Gold]} |
491 | 492 | self:setProperty("pvpBet", pvpBet) |
492 | 493 | end |
493 | - return result | |
494 | + return result, 5 | |
494 | 495 | else |
495 | 496 | print(result) |
497 | + return false , 6 | |
496 | 498 | end |
497 | 499 | end |
498 | 500 | ... | ... |
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 | ... | ... |
src/services/pvpd.lua
... | ... | @@ -208,6 +208,7 @@ function CMD.getBetInfo() |
208 | 208 | betInfo[cday] = math.randomInt(1, #(MatchCache[cday] or {1})) |
209 | 209 | if cday == lastDay then |
210 | 210 | betNum = {} |
211 | + redisproxy:del("cross:pvpInfo:bet:" .. cday) | |
211 | 212 | end |
212 | 213 | end |
213 | 214 | end |
... | ... | @@ -221,7 +222,7 @@ function CMD.getBetInfo() |
221 | 222 | return pvpInfo:getProperties({"betInfo", "betNum"}) |
222 | 223 | end |
223 | 224 | |
224 | -function CMD.setBet(idx) | |
225 | +function CMD.setBet(idx, roleId, costNum) | |
225 | 226 | local day, ctime = getDayAndTime() |
226 | 227 | if day > globalCsv.pvp_cross_server_day or ctime >= globalCsv.pvp_cross_server_stop_stake then return end |
227 | 228 | |
... | ... | @@ -231,6 +232,8 @@ function CMD.setBet(idx) |
231 | 232 | local betNum = pvpInfo:getProperty("betNum") |
232 | 233 | betNum[idx] = (betNum[idx] or 0) + 1 |
233 | 234 | pvpInfo:setProperty("betNum", betNum) |
235 | + | |
236 | + redisproxy:hset("cross:pvpInfo:bet:" .. day, roleId, costNum * 10 + idx) | |
234 | 237 | return {betNum = betNum} |
235 | 238 | end |
236 | 239 | ... | ... |