diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index 33d7868..643edeb 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -372,4 +372,22 @@ TeamSystemType = { Tower = 3, Dinner = 4, FriendBattle = 5, -} \ No newline at end of file + Adv = 6, + Tower1 = 7, + Tower2 = 8, + Tower3 = 9, +} + +-- 某个功能对其他系统功能的加成类型 +SystemBnousType = { + TowerBuff = 1, -- 电波塔内战斗开始时获得buff + CrusadeTask = 2, -- 讨伐电台任务加速 + DinerGet = 3, -- 食材供应商获取速度 + DinerLimit = 4, -- 食材供应商上限 + DinerSell = 5, -- 料理贩卖速度 + DinerPrice = 6, -- 齿轮价格 + Adv = 7, -- 代理拾荒获得额外道具 + HangTime = 8, -- 挂机时间上限 + PvpTicket = 9, -- 每周额外获得竞技场门票数量 + SweepReward = 10, -- 每次扫荡额外获得道具 +} diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index a984944..f88dced 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -145,6 +145,7 @@ actionCodes = { Tower_rankRpc = 353, Tower_bugCountRpc = 354, Tower_rankInfoRpc = 355, + Tower_activeTowerBonusRpc = 356, Car_makePotionRpc = 400, Car_equipUpRpc = 401, diff --git a/src/RedisKeys.lua b/src/RedisKeys.lua index cee5c40..73c05a5 100644 --- a/src/RedisKeys.lua +++ b/src/RedisKeys.lua @@ -26,6 +26,15 @@ RANK_TYPE = { RANK_TOWER = "rank:tower" RANK_TOWER_INFO = "rank:tower:info" +RANK_TOWER1 = "rank:tower1" +RANK_TOWER1_INFO = "rank:tower1:info" + +RANK_TOWER2 = "rank:tower2" +RANK_TOWER2_INFO = "rank:tower2:info" + +RANK_TOWER3 = "rank:tower3" +RANK_TOWER3_INFO = "rank:tower3:info" + -- adv RANK_ADV = {"rank:adv1", "rank:adv2"} RANK_ADV_INFO = "rank:adv:info" diff --git a/src/actions/TowerAction.lua b/src/actions/TowerAction.lua index 094b0bd..ea3a5e1 100644 --- a/src/actions/TowerAction.lua +++ b/src/actions/TowerAction.lua @@ -23,12 +23,17 @@ function _M.startBattleRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) local id = msg.id - - if not role:isFuncUnlock(FuncUnlock.Tower) then return end + local towerType = math.floor(id / 10000) + + if not id or not towerType or towerType < 0 or towerType > 3 then return 0 end + if not role:isFuncUnlock(FuncUnlock.Tower) then return 1 end local towerInfo = role:getProperty("towerInfo") - if towerInfo.l ~= id then return end -- 层数不对 + if towerType == 0 and (towerInfo.l or 1) ~= id then return 2 end -- 层数不对 + if towerType == 1 and ((towerInfo.l1 or 10001) ~= id or (towerInfo.l or 1) < 10) then return 2 end -- 层数不对 + if towerType == 2 and ((towerInfo.l2 or 20001) ~= id or (towerInfo.l or 1) < 10) then return 2 end -- 层数不对 + if towerType == 3 and ((towerInfo.l3 or 30001) ~= id or (towerInfo.l or 1) < 10) then return 2 end -- 层数不对 if not csvdb["tower_battleCsv"][id] then return end local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) @@ -57,13 +62,18 @@ function _M.endBattleRpc(agent, data) local key = msg.key local passTime = msg.passTime + local curTower = csvdb["tower_battleCsv"][id] + if not curTower then return 2 end + + local towerType = math.floor(id / 10000) + local towerLevel = {[0] = (towerInfo.l or 1), [1] = (towerInfo.l1 or 10001), [2] = (towerInfo.l2 or 20001), [3] = (towerInfo.l3 or 30001)} + local curLevel = towerLevel[towerType] + local towerInfo = role:getProperty("towerInfo") - if towerInfo.l ~= id or not towerInfo.k or towerInfo.k ~= key then + if curLevel ~= id or not towerInfo.k or towerInfo.k ~= key then SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({errorCode = 1})) return true end - local curTower = csvdb["tower_battleCsv"][id] - if not curTower then return 2 end -- 防作弊 if not role:checkBattleCheat("tower", { @@ -81,11 +91,21 @@ function _M.endBattleRpc(agent, data) if msg.starNum and msg.starNum > 0 then --win curCount = math.min(curCount + 1, globalCsv.tower_count_limit) -- 返还次数 --排行榜 - role:setTowerRank(towerInfo.l) + role:setTowerRank(curLevel % 10000, towerType) - towerInfo.l = towerInfo.l + 1 + curLevel = curLevel + 1 reward, change = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}}) - role:checkTaskEnter("TowerPass", {level = towerInfo.l - 1}) + role:checkTaskEnter("TowerPass", {count = 1, type = towerType + 1}) + end + + if towerType == 0 then + towerInfo.l = curLevel + elseif towerType == 1 then + towerInfo.l1 = curLevel + elseif towerType == 2 then + towerInfo.l2 = curLevel + elseif towerType == 3 then + towerInfo.l3 = curLevel end towerInfo.c = curCount @@ -93,8 +113,9 @@ function _M.endBattleRpc(agent, data) towerInfo.k = nil role:updateProperty({field = "towerInfo", value = towerInfo}) - - local rank = redisproxy:ZREVRANK(RANK_TOWER, role:getProperty("id")) + local RankTower = {[0] = RANK_TOWER,[1] = RANK_TOWER1,[2] = RANK_TOWER2,[3] = RANK_TOWER3} + local rankName = RankTower[towerType] + local rank = redisproxy:ZREVRANK(rankName, role:getProperty("id")) if not rank then rank = -1 else @@ -143,7 +164,9 @@ end function _M.rankRpc(agent , data) local role = agent.role - SendPacket(actionCodes.Tower_rankRpc, MsgPack.pack(role:getTowerRank())) + local msg = MsgPack.unpack(data) + local towerType = msg.tower or 1 + SendPacket(actionCodes.Tower_rankRpc, MsgPack.pack(role:getTowerRank(towerType))) return true end @@ -151,7 +174,39 @@ function _M.rankInfoRpc(agent , data) local role = agent.role local msg = MsgPack.unpack(data) local roleId = msg.roleId - SendPacket(actionCodes.Tower_rankInfoRpc, MsgPack.pack({format = role:getTowerRankOneInfo(roleId)})) + local towerType = msg.tower or 1 + SendPacket(actionCodes.Tower_rankInfoRpc, MsgPack.pack({format = role:getTowerRankOneInfo(roleId, towerType)})) + return true +end + +function _M.activeTowerBonusRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local tType = msg.tower + local id = msg.id + + local bnousCsv = csvdb["tower_bnousCsv"] + + if not tType or not id or not bnousCsv[tType] then return 0 end + local bnousData = bnousCsv[tType][id] + if not bnousData then return 1 end + + local towerInfo = role:getProperty("towerInfo") + local towerBnous = role:getProperty("towerBnous") + + if towerBnous[tType] and towerBnous[tType][id] then return 2 end + local towerLevel = {[1] = (towerInfo.l or 1), [2] = (towerInfo.l1 or 10001), [3] = (towerInfo.l2 or 20001), [4] = (towerInfo.l3 or 30001)} + local curLevel = towerLevel[tType] + + if curLevel - 1 < bnousData.level then return 3 end + + if not towerBnous[tType] then + towerBnous[tType] = {} + end + towerBnous[tType][id] = 1 + role:updateProperty({field = "towerBnous", value = towerBnous}) + role:getTowerBnousActive(true) + SendPacket(actionCodes.Tower_activeTowerBonusRpc, '') return true end diff --git a/src/models/Activity.lua b/src/models/Activity.lua index 2c670bd..f41ca7b 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -489,7 +489,7 @@ activityFunc[Activity.ActivityType.CalendaTask] = { role:checkTaskEnter("RoleLevelUp", {level = rLevel}) local towerInfo = role:getProperty("towerInfo") - role:checkTaskEnter("TowerPass", {level = towerInfo.l}) + role:checkTaskEnter("TowerPass", {count = towerInfo.l, type = 1}) --"PvpWin" --role:checkTaskEnter("HangPass", {id = 0}) role:checkCalendaTask(true, 15, 3) @@ -557,7 +557,7 @@ activityFunc[Activity.ActivityType.BattleCommandTask] = { role:checkTaskEnter("RoleLevelUp", {level = rLevel}) local towerInfo = role:getProperty("towerInfo") - role:checkTaskEnter("TowerPass", {level = towerInfo.l}) + role:checkTaskEnter("TowerPass", {count = towerInfo.l, type = 1}) --"PvpWin" --role:checkTaskEnter("HangPass", {id = 0}) role:checkCalendaTask(true, 15, 3) diff --git a/src/models/Role.lua b/src/models/Role.lua index 5a28d68..7d977de 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -146,7 +146,8 @@ Role.schema = { boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}} - towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey} + towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1, l1 = 10001, l2 = 20001, l3 = 30001}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey} + towerBnous = {"table", {}}, -- 电波塔加成 {[1] = {[1] = 1, [2] = 1}, [2] = {}, [3] = {}, [4] = {}} spTask = {"table", {}}, -- 特殊任务 -- {id = status} @@ -385,6 +386,7 @@ function Role:data() equips = self:getProperty("equips"), boxL = self:getProperty("boxL"), towerInfo = self:getProperty("towerInfo"), + towerBnous = self:getProperty("towerBnous"), spTask = self:getProperty("spTask"), dTask = self:getProperty("dTask"), wTask = self:getProperty("wTask"), diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index d88f70a..ffc283b 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -303,7 +303,6 @@ function RolePlugin.bind(Role) end function Role:addPotion(params) - dump(params) local pId = globalCsv.adv_item_potion[params.id] local potionBag = self:getProperty("potionBag") local origin = potionBag[pId] or 0 @@ -1270,11 +1269,21 @@ function RolePlugin.bind(Role) end local StdTowerRankTime = toUnixtime("2019010100") - function Role:setTowerRank(level) + local TowerRankInfo = { + [1] = {teamType = TeamSystemType.Tower, rank = RANK_TOWER, rankInfo = RANK_TOWER_INFO}, + [2] = {teamType = TeamSystemType.Tower1, rank = RANK_TOWER1, rankInfo = RANK_TOWER1_INFO}, + [3] = {teamType = TeamSystemType.Tower2, rank = RANK_TOWER2, rankInfo = RANK_TOWER2_INFO}, + [4] = {teamType = TeamSystemType.Tower3, rank = RANK_TOWER3, rankInfo = RANK_TOWER3_INFO}, + } + function Role:setTowerRank(level,tType) + tType = tType or 1 local now = skynet.timex() local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 local ct = 10000 - ct -- 越早的排名越靠前 - local towerTeam = self:getTeamFormatByType(TeamSystemType.Tower) + + + local info = TowerRankInfo[tType] + local towerTeam = self:getTeamFormatByType(info.teamType) local battleV = self:getTeamBattleValue(towerTeam.heros) local score = (level * 10000 + ct) * 10000000 + battleV @@ -1288,21 +1297,23 @@ function RolePlugin.bind(Role) } local roleId = self:getProperty("id") redisproxy:pipelining(function (red) - red:zadd(RANK_TOWER, score, roleId) --更新分数 - red:hset(RANK_TOWER_INFO, roleId, MsgPack.pack(curInfo)) + red:zadd(info.rank, score, roleId) --更新分数 + red:hset(info.rankInfo, roleId, MsgPack.pack(curInfo)) end) end - function Role:getTowerRank() + function Role:getTowerRank(tType) + tType = tType or 1 + local info = TowerRankInfo[tType] local list = {} - local ids = redisproxy:zrevrange(RANK_TOWER, 0 , 99) + local ids = redisproxy:zrevrange(Info.rank, 0 , 99) local redret = {} if ids and next(ids) then redret = redisproxy:pipelining(function (red) for i = 1, #ids do local roleId = ids[i] table.insert(list, {roleId = tonumber(roleId)}) - red:hget(RANK_TOWER_INFO, roleId) + red:hget(Info.rankInfo, roleId) end end) end @@ -1311,7 +1322,7 @@ function RolePlugin.bind(Role) player.format = nil list[i].player = player end - local rank = redisproxy:ZREVRANK(RANK_TOWER, self:getProperty("id")) + local rank = redisproxy:ZREVRANK(Info.rank, self:getProperty("id")) if not rank then rank = -1 else @@ -1320,8 +1331,10 @@ function RolePlugin.bind(Role) return {list = list, rank = rank} end - function Role:getTowerRankOneInfo(roleId) - local data = redisproxy:hget(RANK_TOWER_INFO, roleId) + function Role:getTowerRankOneInfo(roleId,tType) + tType = tType or 1 + local info = TowerRankInfo[tType] + local data = redisproxy:hget(info.rankInfo, roleId) if data then local player = MsgPack.unpack(data) return player.format @@ -2146,6 +2159,74 @@ function RolePlugin.bind(Role) return hero:getProperty("faith") end + -- 电波塔加成 开始 + + function Role:getTowerBnousActive(update) + if not update and self.towerBnousActive then + return self.towerBnousActive + end + local towerInfo = role:getProperty("towerInfo") + local towerLevel = {towerInfo.l or 1, towerInfo.l1 or 10001, towerInfo.l2 or 20001, towerInfo.l3 or 30001} + local towerBnous = self:getProperty("towerBnous") + local bnousCsv = csvdb["tower_bnousCsv"] + self.towerBnousActive = {} + for towerIdx, Set in ipairs(towerLevel) do + for id, data in pairs(Set) do + if (towerLevel[towerIdx] - 1) >= data.level then + self.towerBnousActive[data.type] = (self.towerBnousActive[data.type] or 0) + data.value + end + end + end + return self.towerBnousActive + end + + function Role:getTowerBnousBattleBuff() + local towerBnous = self:getTowerBnousActive() + return towerBnous[SystemBnousType.TowerBuff] + end + + function Role:getTowerBnousCrusade() + local towerBnous = self:getTowerBnousActive() + return towerBnous[SystemBnousType.CrusadeTask] + end + + function Role:getTowerBnousDiner(type) + local towerBnous = self:getTowerBnousActive() + type = type or 1 + if type == 1 then + return towerBnous[SystemBnousType.DinerGet] + elseif type == 2 then + return towerBnous[SystemBnousType.DinerLimit] + elseif type == 3 then + return towerBnous[SystemBnousType.DinerSell] + elseif type == 4 then + return towerBnous[SystemBnousType.DinerPrice] + end + return + end + + function Role:getTowerBnousAdv() + local towerBnous = self:getTowerBnousActive() + return towerBnous[SystemBnousType.Adv] + end + + function Role:getTowerBnousHangTime() + local towerBnous = self:getTowerBnousActive() + return towerBnous[SystemBnousType.HangTime] + end + + function Role:getTowerBnousPvpTicket() + local towerBnous = self:getTowerBnousActive() + return towerBnous[SystemBnousType.PvpTicket] + end + + function Role:getTowerBnousSweep() + local towerBnous = self:getTowerBnousActive() + return towerBnous[SystemBnousType.SweepReward] + end + + -- 电波塔加成 结束 + end return RolePlugin \ No newline at end of file diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 78a82d2..eafafba 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -191,7 +191,7 @@ local AchievListener = { [TaskType.OverOderTask] = {{14}}, [TaskType.FoodSellGold] = {{15, f("count")}}, [TaskType.DinerPopular] = {{16, f("count")}}, - [TaskType.TowerPass] = {{17, f("level")}}, + [TaskType.TowerPass] = {{17, f("count"), f("type")}}, [TaskType.OpenBox] = {{18, f("count")}}, [TaskType.DinerLevelUp] = {{19, f("level"), f("type")}}, [TaskType.DinerTalentUp] = {{20, 1, f("type")}}, @@ -492,7 +492,6 @@ function RoleTask.bind(Role) [6] = true, [7] = true, [16] = true, - [17] = true, [19] = true, [22] = true, [23] = true, -- libgit2 0.21.2