Commit 404d5beef1eee7c4ad839b4ad724edfc0ffba4be

Authored by zhouhaihai
2 parents 4aa21a1d 2471ce93

Merge branch 'develop' into player

src/ProtocolCode.lua
1 -- 协议号 1 -- 协议号
2 actionCodes = { 2 actionCodes = {
3 Sys_heartBeat = 1, 3 Sys_heartBeat = 1,
  4 + Sys_endlessSeason = 2,
4 Sys_errorMsg = 3, 5 Sys_errorMsg = 3,
5 Sys_innerErrorMsg = 4, 6 Sys_innerErrorMsg = 4,
6 Sys_commonNotice = 5, 7 Sys_commonNotice = 5,
@@ -17,7 +17,7 @@ RANK_TOWER = "rank:tower" @@ -17,7 +17,7 @@ RANK_TOWER = "rank:tower"
17 RANK_TOWER_INFO = "rank:tower:info" 17 RANK_TOWER_INFO = "rank:tower:info"
18 18
19 -- adv 19 -- adv
20 -RANK_ADV = "rank:adv" 20 +RANK_ADV = {"rank:adv1", "rank:adv2"}
21 RANK_ADV_INFO = "rank:adv:info" 21 RANK_ADV_INFO = "rank:adv:info"
22 22
23 RANK_DINER = {"rank:diner1", "rank:diner2"} -- 餐厅排行榜 两个每天互换 23 RANK_DINER = {"rank:diner1", "rank:diner2"} -- 餐厅排行榜 两个每天互换
src/actions/AdvAction.lua
@@ -721,7 +721,7 @@ function _M.rankRpc(agent, data) @@ -721,7 +721,7 @@ function _M.rankRpc(agent, data)
721 local role = agent.role 721 local role = agent.role
722 722
723 local list = {} 723 local list = {}
724 - local ids = redisproxy:zrevrange(RANK_ADV, 0 , 99, "WITHSCORES") 724 + local ids = redisproxy:zrevrange(role:getAdvRankKey(), 0 , 99, "WITHSCORES")
725 local redret = {} 725 local redret = {}
726 if ids and next(ids) then 726 if ids and next(ids) then
727 redret = redisproxy:pipelining(function (red) 727 redret = redisproxy:pipelining(function (red)
@@ -739,8 +739,8 @@ function _M.rankRpc(agent, data) @@ -739,8 +739,8 @@ function _M.rankRpc(agent, data)
739 list[i].player = player 739 list[i].player = player
740 end 740 end
741 local redret = redisproxy:pipelining(function(red) 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 end) 744 end)
745 local rank = redret[1] 745 local rank = redret[1]
746 if not rank then 746 if not rank then
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/HttpAction.lua
@@ -197,6 +197,11 @@ function _M.broadcast(query) @@ -197,6 +197,11 @@ function _M.broadcast(query)
197 return "广播成功" 197 return "广播成功"
198 end 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 function _M.online(query) 205 function _M.online(query)
201 local count = datacenter.get("onlineCount") or 0 206 local count = datacenter.get("onlineCount") or 0
202 return count 207 return count
src/actions/PvpAction.lua
@@ -961,11 +961,11 @@ function _M.crossBetRpc(agent, data) @@ -961,11 +961,11 @@ function _M.crossBetRpc(agent, data)
961 local roleId = role:getProperty("id") 961 local roleId = role:getProperty("id")
962 local msg = MsgPack.unpack(data) 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 role:log("pvp_action", {desc = "crossBet"}) 970 role:log("pvp_action", {desc = "crossBet"})
971 SendPacket(actionCodes.Pvp_crossBetRpc, MsgPack.pack(result)) 971 SendPacket(actionCodes.Pvp_crossBetRpc, MsgPack.pack(result))
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
@@ -716,7 +716,7 @@ function Adv:over(success, rewardRatio, overType) @@ -716,7 +716,7 @@ function Adv:over(success, rewardRatio, overType)
716 end 716 end
717 717
718 local roleId = self.owner:getProperty("id") 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 if score > oldMaxScore then 720 if score > oldMaxScore then
721 local team = self.owner:getProperty("advTeam") 721 local team = self.owner:getProperty("advTeam")
722 local curInfo = { 722 local curInfo = {
@@ -728,7 +728,7 @@ function Adv:over(success, rewardRatio, overType) @@ -728,7 +728,7 @@ function Adv:over(success, rewardRatio, overType)
728 format = self.owner:getTeamHerosInfo(team.heros), 728 format = self.owner:getTeamHerosInfo(team.heros),
729 } 729 }
730 redisproxy:pipelining(function (red) 730 redisproxy:pipelining(function (red)
731 - red:zadd(RANK_ADV, score, roleId) --更新分数 731 + red:zadd(self.owner:getAdvRankKey(), score, roleId) --更新分数
732 red:hset(RANK_ADV_INFO, roleId, MsgPack.pack(curInfo)) 732 red:hset(RANK_ADV_INFO, roleId, MsgPack.pack(curInfo))
733 end) 733 end)
734 end 734 end
@@ -1617,7 +1617,7 @@ function Adv:mapItemChange(ctype) @@ -1617,7 +1617,7 @@ function Adv:mapItemChange(ctype)
1617 end 1617 end
1618 if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then 1618 if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then
1619 block.event.item = changeTo 1619 block.event.item = changeTo
1620 - self:backBlockChange(roomId, blockId) 1620 + self:backBlockChange(roomId, blockId, ctype)
1621 end 1621 end
1622 end 1622 end
1623 end 1623 end
@@ -1724,8 +1724,8 @@ function Adv:backEnd(success, score, scoreInfo, reward, overType, scoreAward) @@ -1724,8 +1724,8 @@ function Adv:backEnd(success, score, scoreInfo, reward, overType, scoreAward)
1724 self:pushBackEvent(AdvBackEventType.End, {success = success, score = score, scoreInfo = scoreInfo, reward = reward, type = overType, scoreAward = scoreAward}) 1724 self:pushBackEvent(AdvBackEventType.End, {success = success, score = score, scoreInfo = scoreInfo, reward = reward, type = overType, scoreAward = scoreAward})
1725 end 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 end 1729 end
1730 1730
1731 function Adv:backDead(enemyId, exp) 1731 function Adv:backDead(enemyId, exp)
src/adv/AdvPlayer.lua
@@ -414,7 +414,9 @@ function BaseObject:recover(value, releaser, params) @@ -414,7 +414,9 @@ function BaseObject:recover(value, releaser, params)
414 params = params or {} 414 params = params or {}
415 value = math.max(0, math.ceil(value)) 415 value = math.max(0, math.ceil(value))
416 self.hp = math.min(self.hpMax, self.hp + value) 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 end 420 end
419 421
420 function BaseObject:addSpecialSkill(skillId, skillLevel, target) 422 function BaseObject:addSpecialSkill(skillId, skillLevel, target)
@@ -51,6 +51,15 @@ end @@ -51,6 +51,15 @@ end
51 51
52 local _pipelinings = {} --可同时多个序列 栈的形式保证嵌套不出错 52 local _pipelinings = {} --可同时多个序列 栈的形式保证嵌套不出错
53 function SendPacket(actionCode, bin, client_fd) 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 client_fd = client_fd or agentInfo.client_fd 63 client_fd = client_fd or agentInfo.client_fd
55 64
56 local handlerName = actionHandlers[actionCode] 65 local handlerName = actionHandlers[actionCode]
src/models/HeroPlugin.lua
@@ -193,11 +193,12 @@ function HeroPlugin.bind(Hero) @@ -193,11 +193,12 @@ function HeroPlugin.bind(Hero)
193 return attrs 193 return attrs
194 end 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 end 202 end
202 203
203 function Hero:saveBattleValue() 204 function Hero:saveBattleValue()
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/RolePvp.lua
@@ -468,31 +468,33 @@ function Role:getCrossServerPvpBetInfo() @@ -468,31 +468,33 @@ function Role:getCrossServerPvpBetInfo()
468 end 468 end
469 469
470 function Role:setCrossServerPvpBet(idx) 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 local crossTime = skynet.timex() - self:getTimeResetStartTime(TimeReset.PvpCross) 472 local crossTime = skynet.timex() - self:getTimeResetStartTime(TimeReset.PvpCross)
473 local aday = 3600 * 24 473 local aday = 3600 * 24
474 local day = math.ceil(crossTime / aday) -- 当前是第几个比赛日 474 local day = math.ceil(crossTime / aday) -- 当前是第几个比赛日
475 local ctime = crossTime % aday -- 当前在本天 经过多少时间 475 local ctime = crossTime % aday -- 当前在本天 经过多少时间
476 476
477 if day > globalCsv.pvp_cross_server_day or ctime >= globalCsv.pvp_cross_server_stop_stake then 477 if day > globalCsv.pvp_cross_server_day or ctime >= globalCsv.pvp_cross_server_stop_stake then
478 - return 478 + return false , 2
479 end 479 end
480 local pvpBet = self:getProperty("pvpBet") 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 if ok then 488 if ok then
488 if result then 489 if result then
489 self:costItems(cost, {log = {desc = "crossPvpBet", short1 = day}}) 490 self:costItems(cost, {log = {desc = "crossPvpBet", short1 = day}})
490 pvpBet[day] = {idx, cost[ItemId.Gold]} 491 pvpBet[day] = {idx, cost[ItemId.Gold]}
491 self:setProperty("pvpBet", pvpBet) 492 self:setProperty("pvpBet", pvpBet)
492 end 493 end
493 - return result 494 + return result, 5
494 else 495 else
495 print(result) 496 print(result)
  497 + return false , 6
496 end 498 end
497 end 499 end
498 500
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
src/services/pvpd.lua
@@ -208,6 +208,7 @@ function CMD.getBetInfo() @@ -208,6 +208,7 @@ function CMD.getBetInfo()
208 betInfo[cday] = math.randomInt(1, #(MatchCache[cday] or {1})) 208 betInfo[cday] = math.randomInt(1, #(MatchCache[cday] or {1}))
209 if cday == lastDay then 209 if cday == lastDay then
210 betNum = {} 210 betNum = {}
  211 + redisproxy:del("cross:pvpInfo:bet:" .. cday)
211 end 212 end
212 end 213 end
213 end 214 end
@@ -221,7 +222,7 @@ function CMD.getBetInfo() @@ -221,7 +222,7 @@ function CMD.getBetInfo()
221 return pvpInfo:getProperties({"betInfo", "betNum"}) 222 return pvpInfo:getProperties({"betInfo", "betNum"})
222 end 223 end
223 224
224 -function CMD.setBet(idx) 225 +function CMD.setBet(idx, roleId, costNum)
225 local day, ctime = getDayAndTime() 226 local day, ctime = getDayAndTime()
226 if day > globalCsv.pvp_cross_server_day or ctime >= globalCsv.pvp_cross_server_stop_stake then return end 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,6 +232,8 @@ function CMD.setBet(idx)
231 local betNum = pvpInfo:getProperty("betNum") 232 local betNum = pvpInfo:getProperty("betNum")
232 betNum[idx] = (betNum[idx] or 0) + 1 233 betNum[idx] = (betNum[idx] or 0) + 1
233 pvpInfo:setProperty("betNum", betNum) 234 pvpInfo:setProperty("betNum", betNum)
  235 +
  236 + redisproxy:hset("cross:pvpInfo:bet:" .. day, roleId, costNum * 10 + idx)
234 return {betNum = betNum} 237 return {betNum = betNum}
235 end 238 end
236 239