Commit 98d32f9218d90cad222d51af75b932b799626195

Authored by liuzujun
1 parent 318a7041

多编队

@@ -321,4 +321,12 @@ DrawCardType = { @@ -321,4 +321,12 @@ DrawCardType = {
321 SpecifyDraw = 1, 321 SpecifyDraw = 1,
322 NormalDraw = 2, 322 NormalDraw = 2,
323 FriendDraw = 3 323 FriendDraw = 3
  324 +}
  325 +
  326 +-- 阵容系统类型
  327 +TeamSystemType = {
  328 + Hang = 1,
  329 + BonusBattle = 2,
  330 + Tower = 3,
  331 + Dinner = 4,
324 } 332 }
325 \ No newline at end of file 333 \ No newline at end of file
src/ProtocolCode.lua
@@ -49,6 +49,7 @@ actionCodes = { @@ -49,6 +49,7 @@ actionCodes = {
49 Role_updateFeedbackInfoRpc = 133, 49 Role_updateFeedbackInfoRpc = 133,
50 Role_useSelectItemRpc = 134, -- 使用多选一礼包 50 Role_useSelectItemRpc = 134, -- 使用多选一礼包
51 Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 51 Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄
  52 + Role_renameTeamRpc = 136, -- 编队改名
52 53
53 Adv_startAdvRpc = 151, 54 Adv_startAdvRpc = 151,
54 Adv_startHangRpc = 152, 55 Adv_startHangRpc = 152,
@@ -71,6 +72,7 @@ actionCodes = { @@ -71,6 +72,7 @@ actionCodes = {
71 Adv_rankRpc = 169, 72 Adv_rankRpc = 169,
72 Adv_quickHangRpc = 170, 73 Adv_quickHangRpc = 170,
73 Adv_refreshSupportRpc = 171, 74 Adv_refreshSupportRpc = 171,
  75 + Adv_selectTeamRpc = 172,
74 76
75 Hero_loadInfos = 201, 77 Hero_loadInfos = 201,
76 Hero_updateProperty = 202, 78 Hero_updateProperty = 202,
@@ -111,6 +113,7 @@ actionCodes = { @@ -111,6 +113,7 @@ actionCodes = {
111 Hang_hangGiftRpc = 262, 113 Hang_hangGiftRpc = 262,
112 Hang_bagFieldRpc = 263, 114 Hang_bagFieldRpc = 263,
113 Hang_chatLineRpc = 264, 115 Hang_chatLineRpc = 264,
  116 + Hang_selectTeamRpc = 265,
114 117
115 Diner_updateProperty = 300, 118 Diner_updateProperty = 300,
116 Diner_addSellRpc = 301, 119 Diner_addSellRpc = 301,
src/actions/AdvAction.lua
@@ -47,6 +47,10 @@ local function checkFormat(role, format, checkAdvTeam) @@ -47,6 +47,10 @@ local function checkFormat(role, format, checkAdvTeam)
47 end 47 end
48 end 48 end
49 49
  50 + if not format then
  51 + format = role:getProperty("advTeam")
  52 + end
  53 +
50 if checkAdvTeam then 54 if checkAdvTeam then
51 for _, heroId in pairs(role:getProperty("advTeam").heros or {}) do 55 for _, heroId in pairs(role:getProperty("advTeam").heros or {}) do
52 hadHero[heroId] = true 56 hadHero[heroId] = true
@@ -83,7 +87,7 @@ function _M.startAdvRpc( agent, data ) @@ -83,7 +87,7 @@ function _M.startAdvRpc( agent, data )
83 local msg = MsgPack.unpack(data) 87 local msg = MsgPack.unpack(data)
84 local chapterId = msg.chapterId --关卡id 88 local chapterId = msg.chapterId --关卡id
85 local layer = msg.layer or 1 --选择层数 89 local layer = msg.layer or 1 --选择层数
86 - local format = msg.format --编队 90 + --local format = msg.format --编队
87 local supportIdx = msg.supportIdx --选择的支援效果 91 local supportIdx = msg.supportIdx --选择的支援效果
88 if not role:isFuncUnlock(FuncUnlock.Adv) then return end 92 if not role:isFuncUnlock(FuncUnlock.Adv) then return end
89 93
@@ -127,18 +131,18 @@ function _M.startAdvRpc( agent, data ) @@ -127,18 +131,18 @@ function _M.startAdvRpc( agent, data )
127 end 131 end
128 end 132 end
129 133
130 - if not checkFormat(role, format) then return 7 end  
131 -  
132 - local advTeam = role:getProperty("advTeam")  
133 - table.clear(advTeam)  
134 -  
135 - advTeam.heros = {}  
136 - for slot, heroId in pairs(format.heros) do  
137 - advTeam.heros[slot] = heroId  
138 - end  
139 - advTeam.leader = format.leader  
140 - advTeam.leader2 = format.leader2  
141 - role:updateProperty({field = "advTeam", value = advTeam}) 134 + if not checkFormat(role) then return 7 end
  135 +
  136 + --local advTeam = role:getProperty("advTeam")
  137 + --table.clear(advTeam)
  138 +
  139 + --advTeam.heros = {}
  140 + --for slot, heroId in pairs(format.heros) do
  141 + -- advTeam.heros[slot] = heroId
  142 + --end
  143 + --advTeam.leader = format.leader
  144 + --advTeam.leader2 = format.leader2
  145 + --role:updateProperty({field = "advTeam", value = advTeam})
142 if AdvCommon.isEndless(chapterId) then 146 if AdvCommon.isEndless(chapterId) then
143 role.dailyData:updateProperty({field = "advElC", delta = 1}) 147 role.dailyData:updateProperty({field = "advElC", delta = 1})
144 else 148 else
@@ -950,4 +954,56 @@ function _M.refreshSupportRpc(agent, data) @@ -950,4 +954,56 @@ function _M.refreshSupportRpc(agent, data)
950 return true 954 return true
951 end 955 end
952 956
  957 +function _M.roleFormatRpc(agent , data)
  958 + local role = agent.role
  959 + local msg = MsgPack.unpack(data)
  960 + local index = msg.index -- 阵容索引
  961 + local title = msg.title -- 阵容名称
  962 + local team = {}
  963 + for slot, heroId in pairs(msg.heros) do
  964 + if not role.heros[heroId] then
  965 + return 1
  966 + end
  967 + end
  968 +
  969 + if index > 10 then
  970 + return 2
  971 + end
  972 +
  973 + team.heros = {}
  974 + for slot, heroId in pairs(msg.heros) do
  975 + team.heros[slot] = heroId
  976 + end
  977 + team.leader = msg.leader
  978 + team.leader2 = msg.leader2
  979 + team.title = title
  980 + role:setAdvTeamFormat(index, team)
  981 +
  982 + local advTeam = role:getProperty("advTeam")
  983 + table.clear(advTeam)
  984 +
  985 + advTeam.heros = {}
  986 + for slot, heroId in pairs(msg.heros) do
  987 + advTeam.heros[slot] = heroId
  988 + end
  989 + advTeam.leader = msg.leader
  990 + advTeam.leader2 = msg.leader2
  991 + role:updateProperty({field = "advTeam", value = advTeam})
  992 +
  993 + SendPacket(actionCodes.Adv_roleFormatRpc, '')
  994 + return true
  995 +end
  996 +
  997 +function _M.selectTeamRpc(agent, data)
  998 + local role = agent.role
  999 + local msg = MsgPack.unpack(data)
  1000 + local index = msg.index -- 阵容索引
  1001 + local team = role:getAdvTeamFormat(index)
  1002 + if not next(team) then return end
  1003 + role:updateProperty({field = "advTeam", value = team})
  1004 +
  1005 + SendPacket(actionCodes.Adv_selectTeamRpc, '')
  1006 + return true
  1007 +end
  1008 +
953 return _M 1009 return _M
954 \ No newline at end of file 1010 \ No newline at end of file
src/actions/HangAction.lua
@@ -269,7 +269,15 @@ function _M.endBattleRpc(agent, data) @@ -269,7 +269,15 @@ function _M.endBattleRpc(agent, data)
269 local nextCarbonId = role:getNextCarbonId(carbonId) 269 local nextCarbonId = role:getNextCarbonId(carbonId)
270 -- 设置挂机关卡 270 -- 设置挂机关卡
271 if isWin then --and (hangInfo.carbonId or 0) < nextCarbonId then 271 if isWin then --and (hangInfo.carbonId or 0) < nextCarbonId then
272 - hangInfo.expCarbonId = carbonId 272 + if not hangInfo.expCarbonId then
  273 + hangInfo.expCarbonId = carbonId
  274 + else
  275 + local oldCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId]
  276 + local newCarbonData = csvdb["idle_battleCsv"][carbonId]
  277 + if oldCarbonData.money < newCarbonData.money then
  278 + hangInfo.expCarbonId = carbonId
  279 + end
  280 + end
273 --local cfg = csvdb["idle_battleCsv"][nextCarbonId] 281 --local cfg = csvdb["idle_battleCsv"][nextCarbonId]
274 --if cfg then 282 --if cfg then
275 -- hangInfo.bossTime = skynet.timex() + cfg.idle_time 283 -- hangInfo.bossTime = skynet.timex() + cfg.idle_time
@@ -305,7 +313,10 @@ end @@ -305,7 +313,10 @@ end
305 function _M.roleFormatRpc(agent , data) 313 function _M.roleFormatRpc(agent , data)
306 local role = agent.role 314 local role = agent.role
307 local msg = MsgPack.unpack(data) 315 local msg = MsgPack.unpack(data)
308 - local hangTeam = role:getProperty("hangTeam") 316 + local index = msg.index -- 阵容索引
  317 + local title = msg.title -- 阵容名称
  318 + local type = msg.type -- 系统类型
  319 + local team = {}
309 for slot, heroId in pairs(msg.heros) do 320 for slot, heroId in pairs(msg.heros) do
310 if not role.heros[heroId] then 321 if not role.heros[heroId] then
311 return 1 322 return 1
@@ -321,15 +332,31 @@ function _M.roleFormatRpc(agent , data) @@ -321,15 +332,31 @@ function _M.roleFormatRpc(agent , data)
321 end 332 end
322 if not checkLeader(msg.heros, msg.leader) then return 4 end 333 if not checkLeader(msg.heros, msg.leader) then return 4 end
323 334
324 - table.clear(hangTeam)  
325 - hangTeam.heros = {} 335 + if index > 10 then
  336 + return 5
  337 + end
  338 +
  339 + if #title > 100 then
  340 + return 6
  341 + end
  342 +
  343 + team.heros = {}
326 for slot, heroId in pairs(msg.heros) do 344 for slot, heroId in pairs(msg.heros) do
327 - hangTeam.heros[slot] = heroId 345 + team.heros[slot] = heroId
  346 + end
  347 + team.leader = msg.leader
  348 + team.supports = supports
  349 + team.title = title
  350 +
  351 + role:setTeamFormat(index, team)
  352 + if type == TeamSystemType.Hang then
  353 + role:finishGuide(5)
  354 + role:updateHangTeamInfo()
  355 + elseif type == TeamSystemType.BonusBattle then
  356 + elseif type == TeamSystemType.Tower then
  357 + elseif type == TeamSystemType.Dinner then
328 end 358 end
329 - hangTeam.leader = msg.leader  
330 - hangTeam.supports = supports  
331 - role:saveHangTeam(hangTeam)  
332 - role:finishGuide(5) 359 +
333 SendPacket(actionCodes.Hang_roleFormatRpc, '') 360 SendPacket(actionCodes.Hang_roleFormatRpc, '')
334 return true 361 return true
335 end 362 end
@@ -523,7 +550,8 @@ function _M.startBonusBattleRpc(agent, data) @@ -523,7 +550,8 @@ function _M.startBonusBattleRpc(agent, data)
523 if not bonusData then return 3 end 550 if not bonusData then return 3 end
524 if not role:checkHangPass(bonusData.unlock) then return 4 end 551 if not role:checkHangPass(bonusData.unlock) then return 4 end
525 552
526 - if not next(role:getProperty("bTeam")) then return 5 end 553 + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
  554 + if not next(bTeam) then return 5 end
527 555
528 local bonusC = role.dailyData:getProperty("bonusC") 556 local bonusC = role.dailyData:getProperty("bonusC")
529 bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} 557 bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
@@ -666,4 +694,24 @@ function _M.chatLineRpc(agent, data) @@ -666,4 +694,24 @@ function _M.chatLineRpc(agent, data)
666 return true 694 return true
667 end 695 end
668 696
  697 +function _M.selectTeamRpc(agent, data)
  698 + local role = agent.role
  699 + local msg = MsgPack.unpack(data)
  700 + local index = msg.index -- 阵容索引
  701 + local type = msg.type -- 系统类型
  702 +
  703 + if index > 10 then
  704 + return 1
  705 + end
  706 + local team = role:getTeamFormat(index)
  707 + if not next(team) then return 2 end
  708 +
  709 + local teamIndex = role:getProperty("teamIndex") or {}
  710 + teamIndex[type] = index
  711 + role:updateProperty({field = "teamIndex", value = teamIndex})
  712 +
  713 + SendPacket(actionCodes.Hang_selectTeamRpc, '')
  714 + return true
  715 +end
  716 +
669 return _M 717 return _M
670 \ No newline at end of file 718 \ No newline at end of file
src/actions/RoleAction.lua
@@ -1255,4 +1255,28 @@ function _M.useSelectItemRpc(agent, data) @@ -1255,4 +1255,28 @@ function _M.useSelectItemRpc(agent, data)
1255 return true 1255 return true
1256 end 1256 end
1257 1257
  1258 +function _M.renameTeamRpc(agent, data)
  1259 + local role = agent.role
  1260 + local msg = MsgPack.unpack(data)
  1261 + local title = msg.title
  1262 + local index = msg.index
  1263 + local ispve = msg.ispve
  1264 + if ispve then
  1265 + local teams = role:getProperty("hangTeams")
  1266 + local team = role:getTeamFormat(index)
  1267 + team.title = title
  1268 + teams[index] = team
  1269 + role:updateProperty({field = "hangTeams", value = teams, notNotify = false})
  1270 + else
  1271 + local teams = role:getProperty("advTeams")
  1272 + local team = role:getAdvTeamFormat(index)
  1273 + team.title = title
  1274 + teams[index] = team
  1275 + role:updateProperty({field = "advTeams", value = teams, notNotify = false})
  1276 + end
  1277 +
  1278 + SendPacket(actionCodes.Role_renameTeamRpc, "")
  1279 + return true
  1280 +end
  1281 +
1258 return _M 1282 return _M
1259 \ No newline at end of file 1283 \ No newline at end of file
src/models/Role.lua
@@ -112,7 +112,9 @@ Role.schema = { @@ -112,7 +112,9 @@ Role.schema = {
112 hangBag = {"table", {}}, -- 背包 112 hangBag = {"table", {}}, -- 背包
113 hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限 113 hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限
114 bTeam = {"table", {}}, -- 奖励副本队伍 114 bTeam = {"table", {}}, -- 奖励副本队伍
115 - heroFormate = {"table", {}}, -- 自选编队 {adv={}, hang={}} 115 + hangTeams = {"table", {}}, -- pve自选编队
  116 + teamIndex = {"table", {}}, -- 各个系统使用的编队索引 type->index 见TeamSystemType
  117 + advTeams = {"table", {}}, -- 拾荒自选编队
116 118
117 --引导相关 119 --引导相关
118 newerGuide = {"string","1=1"}, -- 新手引导 master=slave 120 newerGuide = {"string","1=1"}, -- 新手引导 master=slave
@@ -359,6 +361,8 @@ function Role:data() @@ -359,6 +361,8 @@ function Role:data()
359 hangBag = self:getProperty("hangBag"), 361 hangBag = self:getProperty("hangBag"),
360 hangBagLimit = self:getProperty("hangBagLimit"), 362 hangBagLimit = self:getProperty("hangBagLimit"),
361 bTeam = self:getProperty("bTeam"), 363 bTeam = self:getProperty("bTeam"),
  364 + hangTeams = self:getProperty("hangTeams"),
  365 + teamIndex = self:getProperty("teamIndex"),
362 366
363 newerGuide = self:getProperty("newerGuide"), 367 newerGuide = self:getProperty("newerGuide"),
364 funcGuide = self:getProperty("funcGuide"), 368 funcGuide = self:getProperty("funcGuide"),
src/models/RoleBattle.lua
@@ -57,7 +57,8 @@ function Role:checkBattle(battleType, params) @@ -57,7 +57,8 @@ function Role:checkBattle(battleType, params)
57 end 57 end
58 end, 58 end,
59 tower = function() 59 tower = function()
60 - local towerF = self:getProperty("towerF") 60 + --local towerF = self:getProperty("towerF")
  61 + local towerF = self:getTeamFormatByType(TeamSystemType.Tower)
61 for slot, hero in pairs(self:getTeamHerosInfo(towerF.heros)) do 62 for slot, hero in pairs(self:getTeamHerosInfo(towerF.heros)) do
62 selflist[slot] = hero.type 63 selflist[slot] = hero.type
63 end 64 end
@@ -72,7 +73,8 @@ function Role:checkBattle(battleType, params) @@ -72,7 +73,8 @@ function Role:checkBattle(battleType, params)
72 end 73 end
73 end, 74 end,
74 bonus = function() 75 bonus = function()
75 - local bTeam = self:getProperty("bTeam") 76 + --local bTeam = self:getProperty("bTeam")
  77 + local bTeam = self:getTeamFormatByType(TeamSystemType.BonusBattle)
76 for slot, hero in pairs(self:getTeamHerosInfo(bTeam.heros)) do 78 for slot, hero in pairs(self:getTeamHerosInfo(bTeam.heros)) do
77 selflist[slot] = hero.type 79 selflist[slot] = hero.type
78 end 80 end
src/models/RolePlugin.lua
@@ -1132,7 +1132,8 @@ function RolePlugin.bind(Role) @@ -1132,7 +1132,8 @@ function RolePlugin.bind(Role)
1132 local now = skynet.timex() 1132 local now = skynet.timex()
1133 local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 1133 local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年
1134 local ct = 10000 - ct -- 越早的排名越靠前 1134 local ct = 10000 - ct -- 越早的排名越靠前
1135 - local towerTeam = self:getProperty("towerF") 1135 + --local towerTeam = self:getProperty("towerF")
  1136 + local towerTeam = self:getTeamFormatByType(TeamSystemType.Tower)
1136 local battleV = self:getTeamBattleValue(towerTeam.heros) 1137 local battleV = self:getTeamBattleValue(towerTeam.heros)
1137 local score = (level * 10000 + ct) * 10000000 + battleV 1138 local score = (level * 10000 + ct) * 10000000 + battleV
1138 1139
@@ -1324,6 +1325,52 @@ function RolePlugin.bind(Role) @@ -1324,6 +1325,52 @@ function RolePlugin.bind(Role)
1324 }) 1325 })
1325 end 1326 end
1326 1327
  1328 + function Role:updateHangTeamInfo()
  1329 + local team = self:getTeamFormatByType(TeamSystemType.Hang)
  1330 + if not team then return end
  1331 +
  1332 + self:setProperties({
  1333 + hangTS = self:getTeamHerosInfo(team.heros),
  1334 + hangTB = self:getTeamBattleInfo(team),
  1335 + hangTBV = self:getTeamBattleValue(team.heros),
  1336 + })
  1337 + end
  1338 +
  1339 + -- 设置pve阵容
  1340 + function Role:getTeamFormat(index)
  1341 + local teams = self:getProperty("hangTeams") or {}
  1342 + local team = teams[index] or {}
  1343 + return team
  1344 + end
  1345 +
  1346 + function Role:getTeamFormatByType(type)
  1347 + local teamIndex = self:getProperty("teamIndex") or {}
  1348 + local index = teamIndex[type]
  1349 + if not index then return {} end
  1350 +
  1351 + return self:getTeamFormat(index)
  1352 + end
  1353 +
  1354 + function Role:setTeamFormat(index, team)
  1355 + local teams = self:getProperty("hangTeams") or {}
  1356 + teams[index] = team
  1357 + self:updateProperty({field = "hangTeams", value = teams, notNotify = false})
  1358 + end
  1359 +
  1360 + -- 设置拾荒编队阵容
  1361 + function Role:getAdvTeamFormat(index)
  1362 + local teams = self:getProperty("advTeams") or {}
  1363 + local team = teams[index] or {}
  1364 + return team
  1365 + end
  1366 +
  1367 + function Role:setAdvTeamFormat(index, team)
  1368 + local teams = self:getProperty("advTeams") or {}
  1369 + teams[index] = team
  1370 + self:updateProperty({field = "advTeams", value = teams, notNotify = false})
  1371 + end
  1372 +
  1373 +
1327 function Role:savePvpCTeam(team) 1374 function Role:savePvpCTeam(team)
1328 if not team then 1375 if not team then
1329 team = self:getProperty("pvpTC") 1376 team = self:getProperty("pvpTC")