Commit 03c619fb46c4d6aaaa9e57af4e5a7319ecd8e1b7

Authored by chenyueqi
1 parent e8762443

电波塔属性塔功能部分功能草稿

src/GlobalVar.lua
... ... @@ -372,4 +372,22 @@ TeamSystemType = {
372 372 Tower = 3,
373 373 Dinner = 4,
374 374 FriendBattle = 5,
375   -}
376 375 \ No newline at end of file
  376 + Adv = 6,
  377 + Tower1 = 7,
  378 + Tower2 = 8,
  379 + Tower3 = 9,
  380 +}
  381 +
  382 +-- 某个功能对其他系统功能的加成类型
  383 +SystemBnousType = {
  384 + TowerBuff = 1, -- 电波塔内战斗开始时获得buff
  385 + CrusadeTask = 2, -- 讨伐电台任务加速
  386 + DinerGet = 3, -- 食材供应商获取速度
  387 + DinerLimit = 4, -- 食材供应商上限
  388 + DinerSell = 5, -- 料理贩卖速度
  389 + DinerPrice = 6, -- 齿轮价格
  390 + Adv = 7, -- 代理拾荒获得额外道具
  391 + HangTime = 8, -- 挂机时间上限
  392 + PvpTicket = 9, -- 每周额外获得竞技场门票数量
  393 + SweepReward = 10, -- 每次扫荡额外获得道具
  394 +}
... ...
src/ProtocolCode.lua
... ... @@ -145,6 +145,7 @@ actionCodes = {
145 145 Tower_rankRpc = 353,
146 146 Tower_bugCountRpc = 354,
147 147 Tower_rankInfoRpc = 355,
  148 + Tower_activeTowerBonusRpc = 356,
148 149  
149 150 Car_makePotionRpc = 400,
150 151 Car_equipUpRpc = 401,
... ...
src/RedisKeys.lua
... ... @@ -26,6 +26,15 @@ RANK_TYPE = {
26 26 RANK_TOWER = "rank:tower"
27 27 RANK_TOWER_INFO = "rank:tower:info"
28 28  
  29 +RANK_TOWER1 = "rank:tower1"
  30 +RANK_TOWER1_INFO = "rank:tower1:info"
  31 +
  32 +RANK_TOWER2 = "rank:tower2"
  33 +RANK_TOWER2_INFO = "rank:tower2:info"
  34 +
  35 +RANK_TOWER3 = "rank:tower3"
  36 +RANK_TOWER3_INFO = "rank:tower3:info"
  37 +
29 38 -- adv
30 39 RANK_ADV = {"rank:adv1", "rank:adv2"}
31 40 RANK_ADV_INFO = "rank:adv:info"
... ...
src/actions/TowerAction.lua
... ... @@ -23,12 +23,17 @@ function _M.startBattleRpc(agent, data)
23 23 local role = agent.role
24 24 local msg = MsgPack.unpack(data)
25 25 local id = msg.id
26   -
27   - if not role:isFuncUnlock(FuncUnlock.Tower) then return end
  26 + local towerType = math.floor(id / 10000)
  27 +
  28 + if not id or not towerType or towerType < 0 or towerType > 3 then return 0 end
  29 + if not role:isFuncUnlock(FuncUnlock.Tower) then return 1 end
28 30  
29 31 local towerInfo = role:getProperty("towerInfo")
30 32  
31   - if towerInfo.l ~= id then return end -- 层数不对
  33 + if towerType == 0 and (towerInfo.l or 1) ~= id then return 2 end -- 层数不对
  34 + if towerType == 1 and ((towerInfo.l1 or 10001) ~= id or (towerInfo.l or 1) < 10) then return 2 end -- 层数不对
  35 + if towerType == 2 and ((towerInfo.l2 or 20001) ~= id or (towerInfo.l or 1) < 10) then return 2 end -- 层数不对
  36 + if towerType == 3 and ((towerInfo.l3 or 30001) ~= id or (towerInfo.l or 1) < 10) then return 2 end -- 层数不对
32 37  
33 38 if not csvdb["tower_battleCsv"][id] then return end
34 39 local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t)
... ... @@ -57,13 +62,18 @@ function _M.endBattleRpc(agent, data)
57 62 local key = msg.key
58 63 local passTime = msg.passTime
59 64  
  65 + local curTower = csvdb["tower_battleCsv"][id]
  66 + if not curTower then return 2 end
  67 +
  68 + local towerType = math.floor(id / 10000)
  69 + local towerLevel = {[0] = (towerInfo.l or 1), [1] = (towerInfo.l1 or 10001), [2] = (towerInfo.l2 or 20001), [3] = (towerInfo.l3 or 30001)}
  70 + local curLevel = towerLevel[towerType]
  71 +
60 72 local towerInfo = role:getProperty("towerInfo")
61   - if towerInfo.l ~= id or not towerInfo.k or towerInfo.k ~= key then
  73 + if curLevel ~= id or not towerInfo.k or towerInfo.k ~= key then
62 74 SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({errorCode = 1}))
63 75 return true
64 76 end
65   - local curTower = csvdb["tower_battleCsv"][id]
66   - if not curTower then return 2 end
67 77  
68 78 -- 防作弊
69 79 if not role:checkBattleCheat("tower", {
... ... @@ -81,11 +91,21 @@ function _M.endBattleRpc(agent, data)
81 91 if msg.starNum and msg.starNum > 0 then --win
82 92 curCount = math.min(curCount + 1, globalCsv.tower_count_limit) -- 返还次数
83 93 --排行榜
84   - role:setTowerRank(towerInfo.l)
  94 + role:setTowerRank(curLevel % 10000, towerType)
85 95  
86   - towerInfo.l = towerInfo.l + 1
  96 + curLevel = curLevel + 1
87 97 reward, change = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}})
88   - role:checkTaskEnter("TowerPass", {level = towerInfo.l - 1})
  98 + role:checkTaskEnter("TowerPass", {count = 1, type = towerType + 1})
  99 + end
  100 +
  101 + if towerType == 0 then
  102 + towerInfo.l = curLevel
  103 + elseif towerType == 1 then
  104 + towerInfo.l1 = curLevel
  105 + elseif towerType == 2 then
  106 + towerInfo.l2 = curLevel
  107 + elseif towerType == 3 then
  108 + towerInfo.l3 = curLevel
89 109 end
90 110  
91 111 towerInfo.c = curCount
... ... @@ -93,8 +113,9 @@ function _M.endBattleRpc(agent, data)
93 113 towerInfo.k = nil
94 114 role:updateProperty({field = "towerInfo", value = towerInfo})
95 115  
96   -
97   - local rank = redisproxy:ZREVRANK(RANK_TOWER, role:getProperty("id"))
  116 + local RankTower = {[0] = RANK_TOWER,[1] = RANK_TOWER1,[2] = RANK_TOWER2,[3] = RANK_TOWER3}
  117 + local rankName = RankTower[towerType]
  118 + local rank = redisproxy:ZREVRANK(rankName, role:getProperty("id"))
98 119 if not rank then
99 120 rank = -1
100 121 else
... ... @@ -143,7 +164,9 @@ end
143 164  
144 165 function _M.rankRpc(agent , data)
145 166 local role = agent.role
146   - SendPacket(actionCodes.Tower_rankRpc, MsgPack.pack(role:getTowerRank()))
  167 + local msg = MsgPack.unpack(data)
  168 + local towerType = msg.tower or 1
  169 + SendPacket(actionCodes.Tower_rankRpc, MsgPack.pack(role:getTowerRank(towerType)))
147 170 return true
148 171 end
149 172  
... ... @@ -151,7 +174,39 @@ function _M.rankInfoRpc(agent , data)
151 174 local role = agent.role
152 175 local msg = MsgPack.unpack(data)
153 176 local roleId = msg.roleId
154   - SendPacket(actionCodes.Tower_rankInfoRpc, MsgPack.pack({format = role:getTowerRankOneInfo(roleId)}))
  177 + local towerType = msg.tower or 1
  178 + SendPacket(actionCodes.Tower_rankInfoRpc, MsgPack.pack({format = role:getTowerRankOneInfo(roleId, towerType)}))
  179 + return true
  180 +end
  181 +
  182 +function _M.activeTowerBonusRpc(agent, data)
  183 + local role = agent.role
  184 + local msg = MsgPack.unpack(data)
  185 + local tType = msg.tower
  186 + local id = msg.id
  187 +
  188 + local bnousCsv = csvdb["tower_bnousCsv"]
  189 +
  190 + if not tType or not id or not bnousCsv[tType] then return 0 end
  191 + local bnousData = bnousCsv[tType][id]
  192 + if not bnousData then return 1 end
  193 +
  194 + local towerInfo = role:getProperty("towerInfo")
  195 + local towerBnous = role:getProperty("towerBnous")
  196 +
  197 + if towerBnous[tType] and towerBnous[tType][id] then return 2 end
  198 + local towerLevel = {[1] = (towerInfo.l or 1), [2] = (towerInfo.l1 or 10001), [3] = (towerInfo.l2 or 20001), [4] = (towerInfo.l3 or 30001)}
  199 + local curLevel = towerLevel[tType]
  200 +
  201 + if curLevel - 1 < bnousData.level then return 3 end
  202 +
  203 + if not towerBnous[tType] then
  204 + towerBnous[tType] = {}
  205 + end
  206 + towerBnous[tType][id] = 1
  207 + role:updateProperty({field = "towerBnous", value = towerBnous})
  208 + role:getTowerBnousActive(true)
  209 + SendPacket(actionCodes.Tower_activeTowerBonusRpc, '')
155 210 return true
156 211 end
157 212  
... ...
src/models/Activity.lua
... ... @@ -489,7 +489,7 @@ activityFunc[Activity.ActivityType.CalendaTask] = {
489 489 role:checkTaskEnter("RoleLevelUp", {level = rLevel})
490 490  
491 491 local towerInfo = role:getProperty("towerInfo")
492   - role:checkTaskEnter("TowerPass", {level = towerInfo.l})
  492 + role:checkTaskEnter("TowerPass", {count = towerInfo.l, type = 1})
493 493 --"PvpWin"
494 494 --role:checkTaskEnter("HangPass", {id = 0})
495 495 role:checkCalendaTask(true, 15, 3)
... ... @@ -557,7 +557,7 @@ activityFunc[Activity.ActivityType.BattleCommandTask] = {
557 557 role:checkTaskEnter("RoleLevelUp", {level = rLevel})
558 558  
559 559 local towerInfo = role:getProperty("towerInfo")
560   - role:checkTaskEnter("TowerPass", {level = towerInfo.l})
  560 + role:checkTaskEnter("TowerPass", {count = towerInfo.l, type = 1})
561 561 --"PvpWin"
562 562 --role:checkTaskEnter("HangPass", {id = 0})
563 563 role:checkCalendaTask(true, 15, 3)
... ...
src/models/Role.lua
... ... @@ -146,7 +146,8 @@ Role.schema = {
146 146  
147 147 boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}}
148 148  
149   - towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey}
  149 + towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1, l1 = 10001, l2 = 20001, l3 = 30001}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey}
  150 + towerBnous = {"table", {}}, -- 电波塔加成 {[1] = {[1] = 1, [2] = 1}, [2] = {}, [3] = {}, [4] = {}}
150 151  
151 152 spTask = {"table", {}}, -- 特殊任务 -- {id = status}
152 153  
... ... @@ -385,6 +386,7 @@ function Role:data()
385 386 equips = self:getProperty("equips"),
386 387 boxL = self:getProperty("boxL"),
387 388 towerInfo = self:getProperty("towerInfo"),
  389 + towerBnous = self:getProperty("towerBnous"),
388 390 spTask = self:getProperty("spTask"),
389 391 dTask = self:getProperty("dTask"),
390 392 wTask = self:getProperty("wTask"),
... ...
src/models/RolePlugin.lua
... ... @@ -303,7 +303,6 @@ function RolePlugin.bind(Role)
303 303 end
304 304  
305 305 function Role:addPotion(params)
306   - dump(params)
307 306 local pId = globalCsv.adv_item_potion[params.id]
308 307 local potionBag = self:getProperty("potionBag")
309 308 local origin = potionBag[pId] or 0
... ... @@ -1270,11 +1269,21 @@ function RolePlugin.bind(Role)
1270 1269 end
1271 1270  
1272 1271 local StdTowerRankTime = toUnixtime("2019010100")
1273   - function Role:setTowerRank(level)
  1272 + local TowerRankInfo = {
  1273 + [1] = {teamType = TeamSystemType.Tower, rank = RANK_TOWER, rankInfo = RANK_TOWER_INFO},
  1274 + [2] = {teamType = TeamSystemType.Tower1, rank = RANK_TOWER1, rankInfo = RANK_TOWER1_INFO},
  1275 + [3] = {teamType = TeamSystemType.Tower2, rank = RANK_TOWER2, rankInfo = RANK_TOWER2_INFO},
  1276 + [4] = {teamType = TeamSystemType.Tower3, rank = RANK_TOWER3, rankInfo = RANK_TOWER3_INFO},
  1277 + }
  1278 + function Role:setTowerRank(level,tType)
  1279 + tType = tType or 1
1274 1280 local now = skynet.timex()
1275 1281 local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年
1276 1282 local ct = 10000 - ct -- 越早的排名越靠前
1277   - local towerTeam = self:getTeamFormatByType(TeamSystemType.Tower)
  1283 +
  1284 +
  1285 + local info = TowerRankInfo[tType]
  1286 + local towerTeam = self:getTeamFormatByType(info.teamType)
1278 1287 local battleV = self:getTeamBattleValue(towerTeam.heros)
1279 1288 local score = (level * 10000 + ct) * 10000000 + battleV
1280 1289  
... ... @@ -1288,21 +1297,23 @@ function RolePlugin.bind(Role)
1288 1297 }
1289 1298 local roleId = self:getProperty("id")
1290 1299 redisproxy:pipelining(function (red)
1291   - red:zadd(RANK_TOWER, score, roleId) --更新分数
1292   - red:hset(RANK_TOWER_INFO, roleId, MsgPack.pack(curInfo))
  1300 + red:zadd(info.rank, score, roleId) --更新分数
  1301 + red:hset(info.rankInfo, roleId, MsgPack.pack(curInfo))
1293 1302 end)
1294 1303 end
1295 1304  
1296   - function Role:getTowerRank()
  1305 + function Role:getTowerRank(tType)
  1306 + tType = tType or 1
  1307 + local info = TowerRankInfo[tType]
1297 1308 local list = {}
1298   - local ids = redisproxy:zrevrange(RANK_TOWER, 0 , 99)
  1309 + local ids = redisproxy:zrevrange(Info.rank, 0 , 99)
1299 1310 local redret = {}
1300 1311 if ids and next(ids) then
1301 1312 redret = redisproxy:pipelining(function (red)
1302 1313 for i = 1, #ids do
1303 1314 local roleId = ids[i]
1304 1315 table.insert(list, {roleId = tonumber(roleId)})
1305   - red:hget(RANK_TOWER_INFO, roleId)
  1316 + red:hget(Info.rankInfo, roleId)
1306 1317 end
1307 1318 end)
1308 1319 end
... ... @@ -1311,7 +1322,7 @@ function RolePlugin.bind(Role)
1311 1322 player.format = nil
1312 1323 list[i].player = player
1313 1324 end
1314   - local rank = redisproxy:ZREVRANK(RANK_TOWER, self:getProperty("id"))
  1325 + local rank = redisproxy:ZREVRANK(Info.rank, self:getProperty("id"))
1315 1326 if not rank then
1316 1327 rank = -1
1317 1328 else
... ... @@ -1320,8 +1331,10 @@ function RolePlugin.bind(Role)
1320 1331 return {list = list, rank = rank}
1321 1332 end
1322 1333  
1323   - function Role:getTowerRankOneInfo(roleId)
1324   - local data = redisproxy:hget(RANK_TOWER_INFO, roleId)
  1334 + function Role:getTowerRankOneInfo(roleId,tType)
  1335 + tType = tType or 1
  1336 + local info = TowerRankInfo[tType]
  1337 + local data = redisproxy:hget(info.rankInfo, roleId)
1325 1338 if data then
1326 1339 local player = MsgPack.unpack(data)
1327 1340 return player.format
... ... @@ -2146,6 +2159,74 @@ function RolePlugin.bind(Role)
2146 2159 return hero:getProperty("faith")
2147 2160 end
2148 2161  
  2162 + -- 电波塔加成 开始
  2163 +
  2164 + function Role:getTowerBnousActive(update)
  2165 + if not update and self.towerBnousActive then
  2166 + return self.towerBnousActive
  2167 + end
  2168 + local towerInfo = role:getProperty("towerInfo")
  2169 + local towerLevel = {towerInfo.l or 1, towerInfo.l1 or 10001, towerInfo.l2 or 20001, towerInfo.l3 or 30001}
  2170 + local towerBnous = self:getProperty("towerBnous")
  2171 + local bnousCsv = csvdb["tower_bnousCsv"]
  2172 + self.towerBnousActive = {}
  2173 + for towerIdx, Set in ipairs(towerLevel) do
  2174 + for id, data in pairs(Set) do
  2175 + if (towerLevel[towerIdx] - 1) >= data.level then
  2176 + self.towerBnousActive[data.type] = (self.towerBnousActive[data.type] or 0) + data.value
  2177 + end
  2178 + end
  2179 + end
  2180 + return self.towerBnousActive
  2181 + end
  2182 +
  2183 + function Role:getTowerBnousBattleBuff()
  2184 + local towerBnous = self:getTowerBnousActive()
  2185 + return towerBnous[SystemBnousType.TowerBuff]
  2186 + end
  2187 +
  2188 + function Role:getTowerBnousCrusade()
  2189 + local towerBnous = self:getTowerBnousActive()
  2190 + return towerBnous[SystemBnousType.CrusadeTask]
  2191 + end
  2192 +
  2193 + function Role:getTowerBnousDiner(type)
  2194 + local towerBnous = self:getTowerBnousActive()
  2195 + type = type or 1
  2196 + if type == 1 then
  2197 + return towerBnous[SystemBnousType.DinerGet]
  2198 + elseif type == 2 then
  2199 + return towerBnous[SystemBnousType.DinerLimit]
  2200 + elseif type == 3 then
  2201 + return towerBnous[SystemBnousType.DinerSell]
  2202 + elseif type == 4 then
  2203 + return towerBnous[SystemBnousType.DinerPrice]
  2204 + end
  2205 + return
  2206 + end
  2207 +
  2208 + function Role:getTowerBnousAdv()
  2209 + local towerBnous = self:getTowerBnousActive()
  2210 + return towerBnous[SystemBnousType.Adv]
  2211 + end
  2212 +
  2213 + function Role:getTowerBnousHangTime()
  2214 + local towerBnous = self:getTowerBnousActive()
  2215 + return towerBnous[SystemBnousType.HangTime]
  2216 + end
  2217 +
  2218 + function Role:getTowerBnousPvpTicket()
  2219 + local towerBnous = self:getTowerBnousActive()
  2220 + return towerBnous[SystemBnousType.PvpTicket]
  2221 + end
  2222 +
  2223 + function Role:getTowerBnousSweep()
  2224 + local towerBnous = self:getTowerBnousActive()
  2225 + return towerBnous[SystemBnousType.SweepReward]
  2226 + end
  2227 +
  2228 + -- 电波塔加成 结束
  2229 +
2149 2230 end
2150 2231  
2151 2232 return RolePlugin
2152 2233 \ No newline at end of file
... ...
src/models/RoleTask.lua
... ... @@ -191,7 +191,7 @@ local AchievListener = {
191 191 [TaskType.OverOderTask] = {{14}},
192 192 [TaskType.FoodSellGold] = {{15, f("count")}},
193 193 [TaskType.DinerPopular] = {{16, f("count")}},
194   - [TaskType.TowerPass] = {{17, f("level")}},
  194 + [TaskType.TowerPass] = {{17, f("count"), f("type")}},
195 195 [TaskType.OpenBox] = {{18, f("count")}},
196 196 [TaskType.DinerLevelUp] = {{19, f("level"), f("type")}},
197 197 [TaskType.DinerTalentUp] = {{20, 1, f("type")}},
... ... @@ -492,7 +492,6 @@ function RoleTask.bind(Role)
492 492 [6] = true,
493 493 [7] = true,
494 494 [16] = true,
495   - [17] = true,
496 495 [19] = true,
497 496 [22] = true,
498 497 [23] = true,
... ...