Commit 3dbbc9f35e0c5d2fd897cff7815ef9c6350b7dfe
1 parent
85083dba
加上新的任务
Showing
5 changed files
with
62 additions
and
42 deletions
Show diff stats
src/actions/FriendAction.lua
| @@ -378,6 +378,7 @@ function _M.listRpc(agent, data) | @@ -378,6 +378,7 @@ function _M.listRpc(agent, data) | ||
| 378 | end | 378 | end |
| 379 | if next(clearRed) then | 379 | if next(clearRed) then |
| 380 | redisproxy:hmset(FRIEND_KEY:format(roleId), table_unpack(clearRed)) --清除新好友标记 | 380 | redisproxy:hmset(FRIEND_KEY:format(roleId), table_unpack(clearRed)) --清除新好友标记 |
| 381 | + role:checkTaskEnter("AddFriend", {count = #friendList}) | ||
| 381 | end | 382 | end |
| 382 | 383 | ||
| 383 | SendPacket(actionCodes.Friend_listRpc, MsgPack.pack({list = friendList})) | 384 | SendPacket(actionCodes.Friend_listRpc, MsgPack.pack({list = friendList})) |
| @@ -518,6 +519,7 @@ function _M.pointRpc(agent, data) | @@ -518,6 +519,7 @@ function _M.pointRpc(agent, data) | ||
| 518 | redisproxy:sadd(FRIEND_POINT:format(objId), roleId) | 519 | redisproxy:sadd(FRIEND_POINT:format(objId), roleId) |
| 519 | giveP[objId] = 1 | 520 | giveP[objId] = 1 |
| 520 | role.dailyData:updateProperty({field = "giveFP", value = giveP}) | 521 | role.dailyData:updateProperty({field = "giveFP", value = giveP}) |
| 522 | + role:checkTaskEnter("GiveFriendP", {count = 1}) | ||
| 521 | rpcRole(objId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newPoint = 1, roleId = roleId})) | 523 | rpcRole(objId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newPoint = 1, roleId = roleId})) |
| 522 | end | 524 | end |
| 523 | elseif cmd == 2 then -- 领取 | 525 | elseif cmd == 2 then -- 领取 |
| @@ -536,25 +538,27 @@ function _M.pointRpc(agent, data) | @@ -536,25 +538,27 @@ function _M.pointRpc(agent, data) | ||
| 536 | getP[objId] = 1 | 538 | getP[objId] = 1 |
| 537 | reward = role:award({[ItemId.FriendPoint] = 1}) | 539 | reward = role:award({[ItemId.FriendPoint] = 1}) |
| 538 | role.dailyData:updateProperty({field = "getFP", value = getP}) | 540 | role.dailyData:updateProperty({field = "getFP", value = getP}) |
| 541 | + role:checkTaskEnter("GetFriendP", {count = 1}) | ||
| 539 | end | 542 | end |
| 540 | elseif cmd == 3 then -- 一键赠送领取 | 543 | elseif cmd == 3 then -- 一键赠送领取 |
| 541 | -- 赠送 | 544 | -- 赠送 |
| 542 | local giveP = role.dailyData:getProperty("giveFP") | 545 | local giveP = role.dailyData:getProperty("giveFP") |
| 543 | local friends = redisproxy:hgetall(FRIEND_KEY:format(roleId)) | 546 | local friends = redisproxy:hgetall(FRIEND_KEY:format(roleId)) |
| 544 | - local change = false | 547 | + local change = 0 |
| 545 | redisproxy:pipelining(function(red) | 548 | redisproxy:pipelining(function(red) |
| 546 | for i = 1, #friends , 2 do | 549 | for i = 1, #friends , 2 do |
| 547 | local objId = tonumber(friends[i]) | 550 | local objId = tonumber(friends[i]) |
| 548 | if not giveP[objId] then | 551 | if not giveP[objId] then |
| 549 | giveP[objId] = 1 | 552 | giveP[objId] = 1 |
| 550 | - change = true | 553 | + change = change + 1 |
| 551 | red:sadd(FRIEND_POINT:format(objId), roleId) | 554 | red:sadd(FRIEND_POINT:format(objId), roleId) |
| 552 | rpcRole(objId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newPoint = 1, roleId = roleId})) | 555 | rpcRole(objId, "SendPacket", actionCodes.Friend_updateProperty, MsgPack.pack({newPoint = 1, roleId = roleId})) |
| 553 | end | 556 | end |
| 554 | end | 557 | end |
| 555 | end) | 558 | end) |
| 556 | - if change then | 559 | + if change > 0 then |
| 557 | role.dailyData:updateProperty({field = "giveFP", value = giveP}) | 560 | role.dailyData:updateProperty({field = "giveFP", value = giveP}) |
| 561 | + role:checkTaskEnter("GiveFriendP", {count = change}) | ||
| 558 | else | 562 | else |
| 559 | result = 1 | 563 | result = 1 |
| 560 | end | 564 | end |
| @@ -578,6 +582,7 @@ function _M.pointRpc(agent, data) | @@ -578,6 +582,7 @@ function _M.pointRpc(agent, data) | ||
| 578 | if getCount > 0 then | 582 | if getCount > 0 then |
| 579 | reward = role:award({[ItemId.FriendPoint] = getCount}) | 583 | reward = role:award({[ItemId.FriendPoint] = getCount}) |
| 580 | role.dailyData:updateProperty({field = "getFP", value = getP}) | 584 | role.dailyData:updateProperty({field = "getFP", value = getP}) |
| 585 | + role:checkTaskEnter("GetFriendP", {count = getCount}) | ||
| 581 | else | 586 | else |
| 582 | result = (result or 0) + 2 | 587 | result = (result or 0) + 2 |
| 583 | end | 588 | end |
src/actions/PvpAction.lua
| @@ -22,12 +22,12 @@ function _M.formatCommonRpc(agent , data) | @@ -22,12 +22,12 @@ function _M.formatCommonRpc(agent , data) | ||
| 22 | local roleId = role:getProperty("id") | 22 | local roleId = role:getProperty("id") |
| 23 | local msg = MsgPack.unpack(data) | 23 | local msg = MsgPack.unpack(data) |
| 24 | local pvpTC = role:getProperty("pvpTC") | 24 | local pvpTC = role:getProperty("pvpTC") |
| 25 | - for slot, heroId in pairs(msg.heros) do | 25 | + for slot, heroId in pairs(msg.heros or {}) do |
| 26 | if not role.heros[heroId] then | 26 | if not role.heros[heroId] then |
| 27 | return | 27 | return |
| 28 | end | 28 | end |
| 29 | end | 29 | end |
| 30 | - if not next(msg.heros) then | 30 | + if not msg.heros or not next(msg.heros) then |
| 31 | return | 31 | return |
| 32 | end | 32 | end |
| 33 | 33 | ||
| @@ -44,7 +44,7 @@ function _M.formatCommonRpc(agent , data) | @@ -44,7 +44,7 @@ function _M.formatCommonRpc(agent , data) | ||
| 44 | end | 44 | end |
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | -local function getMatchInfo(pvpList, battleCache) | 47 | +local function getMatchInfo(role, pvpList, battleCache) |
| 48 | table.clear(battleCache) | 48 | table.clear(battleCache) |
| 49 | local redret = redisproxy:pipelining(function(red) | 49 | local redret = redisproxy:pipelining(function(red) |
| 50 | for _, info in ipairs(pvpList) do | 50 | for _, info in ipairs(pvpList) do |
| @@ -60,7 +60,7 @@ local function getMatchInfo(pvpList, battleCache) | @@ -60,7 +60,7 @@ local function getMatchInfo(pvpList, battleCache) | ||
| 60 | local curInfo = {idx = idx} | 60 | local curInfo = {idx = idx} |
| 61 | if info.t == 1 then --玩家 | 61 | if info.t == 1 then --玩家 |
| 62 | curInfo.roleId = info.id | 62 | curInfo.roleId = info.id |
| 63 | - curInfo.score = tonumber(redret[curIdx] or 0) | 63 | + curInfo.score = role:unpackPvpScore(redret[curIdx] or 0) |
| 64 | curIdx = curIdx + 1 | 64 | curIdx = curIdx + 1 |
| 65 | -- name, level, headId, battleV, heros | 65 | -- name, level, headId, battleV, heros |
| 66 | local online, roleInfo = rpcRole(curInfo.roleId, "pvpCInfo") | 66 | local online, roleInfo = rpcRole(curInfo.roleId, "pvpCInfo") |
| @@ -92,7 +92,7 @@ function _M.infoRpc(agent, data) | @@ -92,7 +92,7 @@ function _M.infoRpc(agent, data) | ||
| 92 | red:zscore(RANK_PVP_COMMON, roleId) | 92 | red:zscore(RANK_PVP_COMMON, roleId) |
| 93 | red:zrevrank(RANK_PVP_COMMON, roleId) | 93 | red:zrevrank(RANK_PVP_COMMON, roleId) |
| 94 | end) | 94 | end) |
| 95 | - local score = tonumber(redret[1] or 0) | 95 | + local score = role:unpackPvpScore(redret[1] or 0) |
| 96 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp | 96 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp |
| 97 | local pvpMC = role:getProperty("pvpMC") | 97 | local pvpMC = role:getProperty("pvpMC") |
| 98 | if not next(pvpMC) then --没有分配过对手 | 98 | if not next(pvpMC) then --没有分配过对手 |
| @@ -103,7 +103,7 @@ function _M.infoRpc(agent, data) | @@ -103,7 +103,7 @@ function _M.infoRpc(agent, data) | ||
| 103 | 103 | ||
| 104 | response.score = score | 104 | response.score = score |
| 105 | response.rank = rank | 105 | response.rank = rank |
| 106 | - response.matches = getMatchInfo(pvpMC, _pvpBattleInfoCacheC) | 106 | + response.matches = getMatchInfo(role, pvpMC, _pvpBattleInfoCacheC) |
| 107 | 107 | ||
| 108 | elseif ptype == 2 then -- 高级pvp | 108 | elseif ptype == 2 then -- 高级pvp |
| 109 | return | 109 | return |
| @@ -120,7 +120,7 @@ function _M.refreshMatchCRpc(agent, data) | @@ -120,7 +120,7 @@ function _M.refreshMatchCRpc(agent, data) | ||
| 120 | role:refreshPvpMatchC() | 120 | role:refreshPvpMatchC() |
| 121 | 121 | ||
| 122 | local pvpMC = role:getProperty("pvpMC") | 122 | local pvpMC = role:getProperty("pvpMC") |
| 123 | - local matches = getMatchInfo(pvpMC, _pvpBattleInfoCacheC) | 123 | + local matches = getMatchInfo(role, pvpMC, _pvpBattleInfoCacheC) |
| 124 | 124 | ||
| 125 | SendPacket(actionCodes.Pvp_refreshMatchCRpc, MsgPack.pack({matches = matches})) | 125 | SendPacket(actionCodes.Pvp_refreshMatchCRpc, MsgPack.pack({matches = matches})) |
| 126 | return true | 126 | return true |
| @@ -151,11 +151,15 @@ function _M.startBattleRpc(agent, data) | @@ -151,11 +151,15 @@ function _M.startBattleRpc(agent, data) | ||
| 151 | local idx = msg.idx | 151 | local idx = msg.idx |
| 152 | local revenge = msg.revenge | 152 | local revenge = msg.revenge |
| 153 | 153 | ||
| 154 | + local pvpTC = role:getProperty("pvpTC") | ||
| 155 | + if not pvpTC.heros or not next(pvpTC.heros) then return 1 end | ||
| 156 | + | ||
| 154 | local matchInfo, result, key, wait | 157 | local matchInfo, result, key, wait |
| 158 | + | ||
| 155 | local now = skynet.timex() | 159 | local now = skynet.timex() |
| 156 | if revenge then --复仇 | 160 | if revenge then --复仇 |
| 157 | local temp = _pvpRecordInfoCache[idx] | 161 | local temp = _pvpRecordInfoCache[idx] |
| 158 | - if not temp then return end | 162 | + if not temp then return 2 end |
| 159 | 163 | ||
| 160 | if not _responseRecord[temp.id] or now >= _responseRecord[temp.id] then | 164 | if not _responseRecord[temp.id] or now >= _responseRecord[temp.id] then |
| 161 | if temp.t == 1 then | 165 | if temp.t == 1 then |
| @@ -169,7 +173,7 @@ function _M.startBattleRpc(agent, data) | @@ -169,7 +173,7 @@ function _M.startBattleRpc(agent, data) | ||
| 169 | end | 173 | end |
| 170 | else --打正常 | 174 | else --打正常 |
| 171 | local pvpMC = role:getProperty("pvpMC") | 175 | local pvpMC = role:getProperty("pvpMC") |
| 172 | - if not pvpMC[idx] then return end | 176 | + if not pvpMC[idx] then return 3 end |
| 173 | if pvpMC[idx].t == 1 then | 177 | if pvpMC[idx].t == 1 then |
| 174 | matchInfo = _pvpBattleInfoCacheC[pvpMC[idx].id] | 178 | matchInfo = _pvpBattleInfoCacheC[pvpMC[idx].id] |
| 175 | elseif pvpMC[idx].t == 2 then | 179 | elseif pvpMC[idx].t == 2 then |
| @@ -177,14 +181,14 @@ function _M.startBattleRpc(agent, data) | @@ -177,14 +181,14 @@ function _M.startBattleRpc(agent, data) | ||
| 177 | end | 181 | end |
| 178 | end | 182 | end |
| 179 | 183 | ||
| 180 | - if not result and not matchInfo then return end | 184 | + if not result and not matchInfo then return 4 end |
| 181 | 185 | ||
| 182 | if not result then | 186 | if not result then |
| 183 | -- 次数扣一波 | 187 | -- 次数扣一波 |
| 184 | local pvpFree = role.dailyData:getProperty("pvpFree") | 188 | local pvpFree = role.dailyData:getProperty("pvpFree") |
| 185 | if pvpFree >= globalCsv.pvp_battle_free_count then | 189 | if pvpFree >= globalCsv.pvp_battle_free_count then |
| 186 | local cost = {[ItemId.PvpKey] = 1} | 190 | local cost = {[ItemId.PvpKey] = 1} |
| 187 | - if not role:checkItemEnough(cost) then return end | 191 | + if not role:checkItemEnough(cost) then return 5 end |
| 188 | role:costItems(cost) | 192 | role:costItems(cost) |
| 189 | else | 193 | else |
| 190 | role.dailyData:updateProperty({field = "pvpFree", delta = 1}) | 194 | role.dailyData:updateProperty({field = "pvpFree", delta = 1}) |
| @@ -192,6 +196,8 @@ function _M.startBattleRpc(agent, data) | @@ -192,6 +196,8 @@ function _M.startBattleRpc(agent, data) | ||
| 192 | 196 | ||
| 193 | key = tostring(math.random()) | 197 | key = tostring(math.random()) |
| 194 | _pvpStartBattleCache = {idx = idx, key = key, revenge = revenge} | 198 | _pvpStartBattleCache = {idx = idx, key = key, revenge = revenge} |
| 199 | + | ||
| 200 | + role:checkTaskEnter("PvpBattle") | ||
| 195 | end | 201 | end |
| 196 | 202 | ||
| 197 | SendPacket(actionCodes.Pvp_startBattleRpc, MsgPack.pack({matchInfo = matchInfo, key = key, result = result, wait = wait})) | 203 | SendPacket(actionCodes.Pvp_startBattleRpc, MsgPack.pack({matchInfo = matchInfo, key = key, result = result, wait = wait})) |
| @@ -206,7 +212,8 @@ function _M.endBattleRpc(agent, data) | @@ -206,7 +212,8 @@ function _M.endBattleRpc(agent, data) | ||
| 206 | if not msg.key or not _pvpStartBattleCache or msg.key ~= _pvpStartBattleCache.key then | 212 | if not msg.key or not _pvpStartBattleCache or msg.key ~= _pvpStartBattleCache.key then |
| 207 | return 1 | 213 | return 1 |
| 208 | end | 214 | end |
| 209 | - if not msg.idx or not msg.idx ~= _pvpStartBattleCache.idx then | 215 | + |
| 216 | + if not msg.idx or msg.idx ~= _pvpStartBattleCache.idx then | ||
| 210 | return 2 | 217 | return 2 |
| 211 | end | 218 | end |
| 212 | 219 | ||
| @@ -275,6 +282,10 @@ function _M.endBattleRpc(agent, data) | @@ -275,6 +282,10 @@ function _M.endBattleRpc(agent, data) | ||
| 275 | red:trim(dbKey, 0, 9) | 282 | red:trim(dbKey, 0, 9) |
| 276 | end | 283 | end |
| 277 | end) | 284 | end) |
| 285 | + | ||
| 286 | + if isWin then | ||
| 287 | + role:checkTaskEnter("PvpWin", {score = myScore}) | ||
| 288 | + end | ||
| 278 | 289 | ||
| 279 | SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({ | 290 | SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({ |
| 280 | reward = reward, | 291 | reward = reward, |
| @@ -301,13 +312,13 @@ function _M.rankListRpc(agent, data) | @@ -301,13 +312,13 @@ function _M.rankListRpc(agent, data) | ||
| 301 | red:zrevrank(RANK_PVP_COMMON, roleId) | 312 | red:zrevrank(RANK_PVP_COMMON, roleId) |
| 302 | red:zrevrange(RANK_PVP_COMMON, 0, 99, "WITHSCORES") | 313 | red:zrevrange(RANK_PVP_COMMON, 0, 99, "WITHSCORES") |
| 303 | end) | 314 | end) |
| 304 | - local score = tonumber(redret[1] or 0) | 315 | + local score = role:unpackPvpScore(redret[1] or 0) |
| 305 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp | 316 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp |
| 306 | 317 | ||
| 307 | local rankList = {} | 318 | local rankList = {} |
| 308 | for i = 1, #redret[3], 2 do | 319 | for i = 1, #redret[3], 2 do |
| 309 | local roleId = tonumber(redret[i]) | 320 | local roleId = tonumber(redret[i]) |
| 310 | - local score = tonumber(redret[i + 1]) | 321 | + local score = role:unpackPvpScore(redret[i + 1]) |
| 311 | local online, curInfo = rpcRole(roleId, "friendSInfo") | 322 | local online, curInfo = rpcRole(roleId, "friendSInfo") |
| 312 | curInfo.score = score | 323 | curInfo.score = score |
| 313 | curInfo.roleId = roleId | 324 | curInfo.roleId = roleId |
| @@ -345,7 +356,7 @@ function _M.recordListRpc(agent, data) | @@ -345,7 +356,7 @@ function _M.recordListRpc(agent, data) | ||
| 345 | end | 356 | end |
| 346 | _pvpRecordInfoCache = tempList | 357 | _pvpRecordInfoCache = tempList |
| 347 | 358 | ||
| 348 | - recordList = getMatchInfo(tempList, _pvpRecordBattleInfoCache) | 359 | + recordList = getMatchInfo(role, tempList, _pvpRecordBattleInfoCache) |
| 349 | for idx, info in ipairs(recordList) do | 360 | for idx, info in ipairs(recordList) do |
| 350 | local temp = tempList[idx] | 361 | local temp = tempList[idx] |
| 351 | info.win = temp.win | 362 | info.win = temp.win |
src/models/RolePlugin.lua
| @@ -835,18 +835,19 @@ function RolePlugin.bind(Role) | @@ -835,18 +835,19 @@ function RolePlugin.bind(Role) | ||
| 835 | end | 835 | end |
| 836 | 836 | ||
| 837 | function Role:getTeamBattleValue(heros) | 837 | function Role:getTeamBattleValue(heros) |
| 838 | - local battleV = 0 | ||
| 839 | - for _, heroId in pairs(heros or {}) do | ||
| 840 | - local hero = self.heros[heroId] | ||
| 841 | - battleV = battleV + hero:getProperty("battleV") | ||
| 842 | - end | ||
| 843 | - return battleV | 838 | + -- local battleV = 0 |
| 839 | + -- for _, heroId in pairs(heros or {}) do | ||
| 840 | + -- local hero = self.heros[heroId] | ||
| 841 | + -- battleV = battleV + hero:getProperty("battleV") | ||
| 842 | + -- end | ||
| 843 | + -- return battleV | ||
| 844 | + return self:getRealBattleValue(heros) | ||
| 844 | end | 845 | end |
| 845 | 846 | ||
| 846 | -- 不传参数 只修改保存的阵容信息 | 847 | -- 不传参数 只修改保存的阵容信息 |
| 847 | function Role:saveHangTeam(team) | 848 | function Role:saveHangTeam(team) |
| 848 | if not team then | 849 | if not team then |
| 849 | - team = self:getProperty("pvpTSC") | 850 | + team = self:getProperty("hangTeam") |
| 850 | else | 851 | else |
| 851 | self:updateProperty({field = "hangTeam", value = team}) | 852 | self:updateProperty({field = "hangTeam", value = team}) |
| 852 | end | 853 | end |
| @@ -859,9 +860,9 @@ function RolePlugin.bind(Role) | @@ -859,9 +860,9 @@ function RolePlugin.bind(Role) | ||
| 859 | 860 | ||
| 860 | function Role:savePvpCTeam(team) | 861 | function Role:savePvpCTeam(team) |
| 861 | if not team then | 862 | if not team then |
| 862 | - team = self:getProperty("pvpTSC") | 863 | + team = self:getProperty("pvpTC") |
| 863 | else | 864 | else |
| 864 | - self:updateProperty({field = "pvpTSC", value = team}) | 865 | + self:updateProperty({field = "pvpTC", value = team}) |
| 865 | end | 866 | end |
| 866 | self:setProperties({ | 867 | self:setProperties({ |
| 867 | pvpTSC = self:getTeamHerosInfo(team.heros), | 868 | pvpTSC = self:getTeamHerosInfo(team.heros), |
src/models/RolePvp.lua
| @@ -8,17 +8,17 @@ local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数 | @@ -8,17 +8,17 @@ local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数 | ||
| 8 | local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异 | 8 | local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异 |
| 9 | local PVP_RANK_ROBOT_SCORE = 1000 -- 机器人积分 | 9 | local PVP_RANK_ROBOT_SCORE = 1000 -- 机器人积分 |
| 10 | 10 | ||
| 11 | -local function unpackScore(score) | 11 | + |
| 12 | +function Role:unpackPvpScore(score) | ||
| 12 | score = tonumber(score or 0) | 13 | score = tonumber(score or 0) |
| 13 | return math.floor(score / PVP_RANK_TIME_SORT_PLACE) | 14 | return math.floor(score / PVP_RANK_TIME_SORT_PLACE) |
| 14 | end | 15 | end |
| 15 | 16 | ||
| 16 | -local function packScore(score, now) | 17 | +function Role:packPvpScore(score, now) |
| 17 | now = now or skynet.timex() | 18 | now = now or skynet.timex() |
| 18 | return math.floor(score * PVP_RANK_TIME_SORT_PLACE + (PVP_RANK_TIME_SORT_STD - now) / PVP_RANK_TIME_SORT_PRECISION) | 19 | return math.floor(score * PVP_RANK_TIME_SORT_PLACE + (PVP_RANK_TIME_SORT_STD - now) / PVP_RANK_TIME_SORT_PRECISION) |
| 19 | end | 20 | end |
| 20 | 21 | ||
| 21 | - | ||
| 22 | function Role:changePvpScoreCommon(matchId, isWin) | 22 | function Role:changePvpScoreCommon(matchId, isWin) |
| 23 | local roleId = self:getProperty("id") | 23 | local roleId = self:getProperty("id") |
| 24 | local isPlayer = matchId ~= -1 | 24 | local isPlayer = matchId ~= -1 |
| @@ -29,11 +29,11 @@ function Role:changePvpScoreCommon(matchId, isWin) | @@ -29,11 +29,11 @@ function Role:changePvpScoreCommon(matchId, isWin) | ||
| 29 | red:zscore(RANK_PVP_COMMON, matchId) | 29 | red:zscore(RANK_PVP_COMMON, matchId) |
| 30 | end | 30 | end |
| 31 | end) | 31 | end) |
| 32 | - local myScore = unpackScore(redret[1]) | 32 | + local myScore = self:unpackPvpScore(redret[1]) |
| 33 | local oldMyRank = tonumber(redret[2] or -2) + 1 | 33 | local oldMyRank = tonumber(redret[2] or -2) + 1 |
| 34 | local matchScore = PVP_RANK_ROBOT_SCORE | 34 | local matchScore = PVP_RANK_ROBOT_SCORE |
| 35 | if isPlayer then | 35 | if isPlayer then |
| 36 | - matchScore = unpackScore(redret[3]) | 36 | + matchScore = self:unpackPvpScore(redret[3]) |
| 37 | end | 37 | end |
| 38 | local oldmyScore, oldMatchScore = myScore, matchScore | 38 | local oldmyScore, oldMatchScore = myScore, matchScore |
| 39 | 39 | ||
| @@ -52,9 +52,9 @@ function Role:changePvpScoreCommon(matchId, isWin) | @@ -52,9 +52,9 @@ function Role:changePvpScoreCommon(matchId, isWin) | ||
| 52 | 52 | ||
| 53 | local now = skynet.timex() | 53 | local now = skynet.timex() |
| 54 | redisproxy:pipelining(function(red) | 54 | redisproxy:pipelining(function(red) |
| 55 | - red:zadd(RANK_PVP_COMMON, packScore(myScore, now), roleId) | 55 | + red:zadd(RANK_PVP_COMMON, self:packPvpScore(myScore, now), roleId) |
| 56 | if isPlayer then | 56 | if isPlayer then |
| 57 | - red:zadd(RANK_PVP_COMMON, packScore(matchScore, now), matchId) | 57 | + red:zadd(RANK_PVP_COMMON, self:packPvpScore(matchScore, now), matchId) |
| 58 | end | 58 | end |
| 59 | red:zrevrank(RANK_PVP_COMMON, roleId) | 59 | red:zrevrank(RANK_PVP_COMMON, roleId) |
| 60 | end) | 60 | end) |
| @@ -70,7 +70,7 @@ end | @@ -70,7 +70,7 @@ end | ||
| 70 | 70 | ||
| 71 | function Role:refreshPvpMatchC(score) | 71 | function Role:refreshPvpMatchC(score) |
| 72 | local roleId = self:getProperty("id") | 72 | local roleId = self:getProperty("id") |
| 73 | - local score = score or redisproxy:zscore(RANK_PVP_COMMON, roleId) or 0 | 73 | + local score = score or self:unpackPvpScore(redisproxy:zscore(RANK_PVP_COMMON, roleId)) |
| 74 | 74 | ||
| 75 | local function getPlayers(levels) | 75 | local function getPlayers(levels) |
| 76 | local redret = redisproxy:pipelining(function(red) | 76 | local redret = redisproxy:pipelining(function(red) |
src/models/RoleTask.lua
| @@ -65,22 +65,25 @@ local TaskType = { | @@ -65,22 +65,25 @@ local TaskType = { | ||
| 65 | OpenBox = 702, -- 拆解时间箱 | 65 | OpenBox = 702, -- 拆解时间箱 |
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | + -- pvp相关 | ||
| 69 | + PvpWin = 751, -- pvp胜利 - score | ||
| 70 | + PvpBattle = 752, -- pvp挑战 | ||
| 71 | + | ||
| 72 | + --好友相关 | ||
| 73 | + GiveFriendP = 801, -- 赠送友情点 - count | ||
| 74 | + AddFriend = 802, -- 加入一个好友 - count | ||
| 75 | + GetFriendP = 803, -- 获得友情点 - count | ||
| 76 | + | ||
| 68 | --功能未实现 todo | 77 | --功能未实现 todo |
| 69 | - PvpWin = 1000, -- pvp胜利 - score | ||
| 70 | - PvpBattle = 1001, -- pvp挑战 | ||
| 71 | AdvShop = 1002, -- 冒险商城 | 78 | AdvShop = 1002, -- 冒险商城 |
| 72 | - GiveFriendP = 1003, -- 赠送友情点 | ||
| 73 | UnionBoss = 1004, -- 工会boss | 79 | UnionBoss = 1004, -- 工会boss |
| 74 | UnionBattle = 1005, -- 工会战 | 80 | UnionBattle = 1005, -- 工会战 |
| 75 | AddUnion = 1006, -- 加入一个公会 | 81 | AddUnion = 1006, -- 加入一个公会 |
| 76 | - AddFriend = 1007, -- 加入一个好友 - count | ||
| 77 | BindPhone = 1008, -- 绑定手机 | 82 | BindPhone = 1008, -- 绑定手机 |
| 78 | WeChat = 1009, -- 关注微信 | 83 | WeChat = 1009, -- 关注微信 |
| 79 | WeBlog = 1010, -- 关注微博 | 84 | WeBlog = 1010, -- 关注微博 |
| 80 | SignIn = 1011, -- 签到 | 85 | SignIn = 1011, -- 签到 |
| 81 | - GetFriendP = 1012, -- 获得友情点 - count | ||
| 82 | ShopAll = 1013, -- 在任意商店购买 | 86 | ShopAll = 1013, -- 在任意商店购买 |
| 83 | - | ||
| 84 | } | 87 | } |
| 85 | 88 | ||
| 86 | local function v(value) | 89 | local function v(value) |
| @@ -126,7 +129,7 @@ local CommonListener = { | @@ -126,7 +129,7 @@ local CommonListener = { | ||
| 126 | [TaskType.HeroLevelUp] = {{v(17)}}, | 129 | [TaskType.HeroLevelUp] = {{v(17)}}, |
| 127 | [TaskType.Wake] = {{v(18)}}, | 130 | [TaskType.Wake] = {{v(18)}}, |
| 128 | [TaskType.EquipUp] = {{v(19), f("count")}}, | 131 | [TaskType.EquipUp] = {{v(19), f("count")}}, |
| 129 | - [TaskType.GiveFriendP] = {{v(20)}}, | 132 | + [TaskType.GiveFriendP] = {{v(20), f("count")}}, |
| 130 | [TaskType.UnionBoss] = {{v(21)}}, | 133 | [TaskType.UnionBoss] = {{v(21)}}, |
| 131 | [TaskType.GetFriendP] = {{v(22), f("count")}}, | 134 | [TaskType.GetFriendP] = {{v(22), f("count")}}, |
| 132 | [TaskType.BonusPass] = {{v(23)}}, | 135 | [TaskType.BonusPass] = {{v(23)}}, |