Commit 75f560205a5ef263acf30e957daed3e9389d7a2c

Authored by 熊润斐
2 parents daaf02b6 eb87ab7d

Merge branch 'develop' into tr/publish

# Conflicts:
#	config/nodenames.lua
src/GlobalVar.lua
... ... @@ -126,6 +126,7 @@ ItemId = {
126 126 HeroFC = {700, 701, 702, 703}, --通用角色碎片
127 127 AdvKey = 80, -- 冒险钥匙
128 128 BoxKey = 60, -- 拆解工具
  129 + AdvPower = 4701, -- 拾荒体力
129 130 }
130 131  
131 132 TimeReset = {
... ... @@ -303,6 +304,7 @@ MailId = {
303 304 ActDrawCardReward = 222,
304 305 ActAdvDrawReward = 223,
305 306 ActOpenBoxReward = 224,
  307 + ActItemRecycle = 225,
306 308  
307 309 PaySignAward = 241,
308 310 PayBackAward = 242,
... ... @@ -322,4 +324,13 @@ DrawCardType = {
322 324 SpecifyDraw = 1,
323 325 NormalDraw = 2,
324 326 FriendDraw = 3
  327 +}
  328 +
  329 +-- 阵容系统类型
  330 +TeamSystemType = {
  331 + Hang = 1,
  332 + BonusBattle = 2,
  333 + Tower = 3,
  334 + Dinner = 4,
  335 + FriendBattle = 5,
325 336 }
326 337 \ No newline at end of file
... ...
src/ProtocolCode.lua
... ... @@ -49,6 +49,8 @@ actionCodes = {
49 49 Role_updateFeedbackInfoRpc = 133,
50 50 Role_useSelectItemRpc = 134, -- 使用多选一礼包
51 51 Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄
  52 + Role_renameTeamRpc = 136, -- 编队改名
  53 + Role_accuseRpc = 137, -- 举报
52 54  
53 55 Adv_startAdvRpc = 151,
54 56 Adv_startHangRpc = 152,
... ... @@ -71,6 +73,8 @@ actionCodes = {
71 73 Adv_rankRpc = 169,
72 74 Adv_quickHangRpc = 170,
73 75 Adv_refreshSupportRpc = 171,
  76 + Adv_selectTeamRpc = 172,
  77 + Adv_roleFormatRpc = 173,
74 78  
75 79 Hero_loadInfos = 201,
76 80 Hero_updateProperty = 202,
... ... @@ -96,6 +100,8 @@ actionCodes = {
96 100 Hero_unlockPoolRpc = 222,
97 101 Hero_changeCrown = 223,
98 102 Hero_drawHeroExtraRewardNtf = 224,
  103 + Hero_itemComposeRpc = 225,
  104 + Hero_setWishPoolRpc = 226,
99 105  
100 106 Hang_startRpc = 251,
101 107 Hang_checkRpc = 252,
... ... @@ -111,6 +117,7 @@ actionCodes = {
111 117 Hang_hangGiftRpc = 262,
112 118 Hang_bagFieldRpc = 263,
113 119 Hang_chatLineRpc = 264,
  120 + Hang_selectTeamRpc = 265,
114 121  
115 122 Diner_updateProperty = 300,
116 123 Diner_addSellRpc = 301,
... ... @@ -197,6 +204,7 @@ actionCodes = {
197 204 Store_getGrowFundRewardRpc = 561, --成长助力奖励
198 205 Store_getBattlePassRewardRpc = 562, --赛季卡奖励
199 206 Store_getExploreCommandRewardRpc = 563, --探索指令
  207 + Store_getTotalRechargeAwardRpc = 564, -- 累计充值
200 208  
201 209  
202 210 Email_listRpc = 600,
... ... @@ -212,6 +220,11 @@ actionCodes = {
212 220 Activity_actPaySignRewardNtf = 654,
213 221 Activity_actCalendaTaskRpc = 655,
214 222 Activity_actPaySignRpc = 656,
  223 + Activity_exchangeRpc = 657,
  224 +
  225 + Radio_startQuestRpc = 700,
  226 + Radio_finishQuestRpc = 701,
  227 + Radio_cancelQuestRpc = 702,
215 228 }
216 229  
217 230 rpcResponseBegin = 10000
... ...
src/RedisKeys.lua
... ... @@ -12,6 +12,8 @@ R_RUNE = "role:%d:rune:%d" -- 符文详细信息
12 12 R_EMAIL = "role:%d:emailIds" --邮件列表
13 13 R_EMAIL_ITEM = "email:%d:%d" --邮件
14 14 R_STORE = "role:%d:store" -- 商店
  15 +R_ORDERS = "role:%d:orders" -- 订单
  16 +R_ORDER = "order:%d:%d"
15 17  
16 18  
17 19 -- rank
... ...
src/actions/ActivityAction.lua
... ... @@ -263,4 +263,36 @@ function _M.actCalendaTaskRpc(agent, data)
263 263 return true
264 264 end
265 265  
  266 +function _M.exchangeRpc(agent, data)
  267 + local role = agent.role
  268 + local msg = MsgPack.unpack(data)
  269 + local actid = msg.actid
  270 + local id = msg.id
  271 + if not role.activity:isOpen("Exchange") then return 1 end
  272 +
  273 + local exchangeCfg = csvdb["activity_exchangeCsv"][actid]
  274 + if not exchangeCfg then return 2 end
  275 + if not exchangeCfg[id] then return 3 end
  276 + local curData = role.activity:getActData("Exchange") or {}
  277 + local exchangeData = curData[actid] or {}
  278 + local curCount = exchangeData[id] or 0
  279 + local actCfg = exchangeCfg[id]
  280 + if curCount >= actCfg then return 4 end
  281 +
  282 + local costs = actCfg.goods:toNumMap()
  283 + if not role:checkItemEnough(costs) then return 5 end
  284 + role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}})
  285 +
  286 + curCount = curCount + 1
  287 + exchangeData[id] = curCount
  288 + curData[actid] = exchangeData
  289 + role.activity:updateActData("Exchange", curData)
  290 +
  291 + local reward, change = role:award(actCfg.award, {log = {desc = "actExchange", int1 = actid, int2 = id}})
  292 +
  293 +
  294 + SendPacket(actionCodes.Activity_exchangeRpc, MsgPack.pack(role:packReward(reward, change)))
  295 + return true
  296 +end
  297 +
266 298 return _M
267 299 \ No newline at end of file
... ...
src/actions/AdvAction.lua
... ... @@ -47,6 +47,10 @@ local function checkFormat(role, format, checkAdvTeam)
47 47 end
48 48 end
49 49  
  50 + if not format then
  51 + format = role:getProperty("advTeam")
  52 + end
  53 +
50 54 if checkAdvTeam then
51 55 for _, heroId in pairs(role:getProperty("advTeam").heros or {}) do
52 56 hadHero[heroId] = true
... ... @@ -83,7 +87,7 @@ function _M.startAdvRpc( agent, data )
83 87 local msg = MsgPack.unpack(data)
84 88 local chapterId = msg.chapterId --关卡id
85 89 local layer = msg.layer or 1 --选择层数
86   - local format = msg.format --编队
  90 + --local format = msg.format --编队
87 91 local supportIdx = msg.supportIdx --选择的支援效果
88 92 if not role:isFuncUnlock(FuncUnlock.Adv) then return end
89 93  
... ... @@ -127,18 +131,18 @@ function _M.startAdvRpc( agent, data )
127 131 end
128 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 146 if AdvCommon.isEndless(chapterId) then
143 147 role.dailyData:updateProperty({field = "advElC", delta = 1})
144 148 else
... ... @@ -243,13 +247,14 @@ function _M.startHangRpc(agent, data)
243 247 info.format.heros[slot] = heroId
244 248 end
245 249 info.time = skynet.timex() + adv_idle_time --挂机时间
  250 + info.duration = adv_idle_time
246 251 info.campId = campId
247 252 info.index = index
248 253  
249 254 -- 没有在战斗 用team来挂机了 把team清掉
250   - if not role:getAdvData():isRunning() then
251   - role:updateProperty({field = "advTeam", value = {}})
252   - end
  255 + --if not role:getAdvData():isRunning() then
  256 + -- role:updateProperty({field = "advTeam", value = {}})
  257 + --end
253 258 role:pushMsg({type = "adv", slot = chapterId, time = adv_idle_time})
254 259 role:changeUpdates({{type = "advHang", field = chapterId, value = info}})
255 260  
... ... @@ -261,6 +266,16 @@ function _M.startHangRpc(agent, data)
261 266 return true
262 267 end
263 268  
  269 +local function addHeroFaith(role, heroId, exp)
  270 + local hero = role.heros[heroId]
  271 + if not hero then
  272 + return
  273 + end
  274 +
  275 + hero:addHeroFaith(exp)
  276 + return hero:getProperty("faith")
  277 +end
  278 +
264 279 function _M.quickHangRpc(agent, data)
265 280 local role = agent.role
266 281 local msg = MsgPack.unpack(data)
... ... @@ -328,7 +343,7 @@ function _M.endHangRpc(agent, data)
328 343 end
329 344 adv_idle_time = adv_idle_time * 60
330 345  
331   - local reward, isFull, change
  346 + local reward, isFull, change, heroFaithMap
332 347 if skynet.timex() >= info.time then
333 348 -- 最新需求加成取消
334 349 --[[
... ... @@ -357,6 +372,14 @@ function _M.endHangRpc(agent, data)
357 372  
358 373 if not maxCampsite then return end
359 374 ]]
  375 + -- 增加英雄信赖
  376 + local exp = info.duration / 60
  377 + heroFaithMap = {}
  378 + for _, heroId in pairs(info.format.heros) do
  379 + local curFaith = addHeroFaith(role, heroId, exp)
  380 + heroFaithMap[heroId] = curFaith
  381 + end
  382 +
360 383 local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2
361 384  
362 385 local idleReward = totalReward:toNumMap()
... ... @@ -384,7 +407,7 @@ function _M.endHangRpc(agent, data)
384 407  
385 408 role:checkTaskEnter("AdvHang", {})
386 409  
387   - SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull}))
  410 + SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull, heroFaith = heroFaithMap}))
388 411 return true
389 412 end
390 413  
... ... @@ -504,25 +527,8 @@ function _M.useItemRpc(agent, data)
504 527 adv:cost({[itemId] = count}, {log = {desc = "useItem", int1 = itemId, int2 = count}})
505 528 adv:backUse({[itemId] = count})
506 529 end
507   -
508   - if itemId == 5020 then
509   - role:finishGuide(53)
510   - end
511   - adv:checkAchievement(adv.AchievType.UseItem, count, itemId)
512   - adv:mylog({desc = "useItem", int1 = itemId, int2 = count})
513   -
514   - role:log("mission_pick_use", {
515   - mission_threadid = adv.chapterId, -- 大地图ID
516   - mission_threadname = (csvdb["adv_chapterCsv"][adv.chapterId] or {})["chapter"] or "auto", -- 大地图名称
517   - mission_id = adv.level, -- 关卡ID
518   - item_id = itemId, -- 道具ID
519   - mission_pick_use_num = count, -- 道具使用量
520   - mission_sequenceid = adv.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志
521   - })
522   -
523   - for i = 1, count do
524   - adv:doActive(itemData.effect, target) -- target
525   - end
  530 +
  531 + adv:useItem(itemId, count, target)
526 532  
527 533 adv:afterRound()
528 534 adv:saveDB()
... ... @@ -740,7 +746,7 @@ function _M.endBattleRpc(agent, data)
740 746 end
741 747 end
742 748 adv:mylog({desc = "endBattle"})
743   - local status = adv:clickBlock(roomId, blockId, {player = player, bySkill = bySkill})
  749 + local status = adv:clickBlock(roomId, blockId, {player = player, enemy = msg.enemy, bySkill = bySkill})
744 750  
745 751 if not status then return end
746 752 SendPacket(actionCodes.Adv_endBattleRpc, MsgPack.pack({events = adv:popBackEvents()}))
... ... @@ -950,4 +956,61 @@ function _M.refreshSupportRpc(agent, data)
950 956 return true
951 957 end
952 958  
  959 +function _M.roleFormatRpc(agent , data)
  960 + local role = agent.role
  961 + local msg = MsgPack.unpack(data)
  962 + local index = msg.index -- 阵容索引
  963 + local title = msg.title -- 阵容名称
  964 + local team = {}
  965 + for slot, heroId in pairs(msg.heros) do
  966 + if not role.heros[heroId] then
  967 + return 1
  968 + end
  969 + end
  970 +
  971 + if index > 10 then
  972 + return 2
  973 + end
  974 +
  975 + team.heros = {}
  976 + for slot, heroId in pairs(msg.heros) do
  977 + team.heros[slot] = heroId
  978 + end
  979 + team.leader = msg.leader
  980 + team.leader2 = msg.leader2
  981 + team.title = title
  982 + role:setAdvTeamFormat(index, team)
  983 +
  984 + local advTeam = role:getProperty("advTeam")
  985 + local curIndex = advTeam.index
  986 + if curIndex == index then
  987 + table.clear(advTeam)
  988 +
  989 + advTeam.heros = {}
  990 + for slot, heroId in pairs(msg.heros) do
  991 + advTeam.heros[slot] = heroId
  992 + end
  993 + advTeam.leader = msg.leader
  994 + advTeam.leader2 = msg.leader2
  995 + advTeam.index = index
  996 + role:updateProperty({field = "advTeam", value = advTeam})
  997 + end
  998 +
  999 + SendPacket(actionCodes.Adv_roleFormatRpc, '')
  1000 + return true
  1001 +end
  1002 +
  1003 +function _M.selectTeamRpc(agent, data)
  1004 + local role = agent.role
  1005 + local msg = MsgPack.unpack(data)
  1006 + local index = msg.index -- 阵容索引
  1007 + local team = role:getAdvTeamFormat(index)
  1008 + if not next(team) then return end
  1009 + team["index"] = index
  1010 + role:updateProperty({field = "advTeam", value = team})
  1011 +
  1012 + SendPacket(actionCodes.Adv_selectTeamRpc, '')
  1013 + return true
  1014 +end
  1015 +
953 1016 return _M
954 1017 \ No newline at end of file
... ...
src/actions/DinerAction.lua
... ... @@ -609,10 +609,10 @@ function _M.refreshTaskRpc( agent, data )
609 609 local role = agent.role
610 610 local msg = MsgPack.unpack(data)
611 611  
612   - local cost = {[ItemId.Diamond] = 40}
613   - if not role:checkItemEnough(cost) then
614   - return 1
615   - end
  612 + --local cost = {[ItemId.Diamond] = 40}
  613 + --if not role:checkItemEnough(cost) then
  614 + -- return 1
  615 + --end
616 616  
617 617 local orders = json.decode(role.dinerData:getProperty("order"))
618 618  
... ...
src/actions/GmAction.lua
... ... @@ -402,24 +402,23 @@ function _M.advl(role, pms)
402 402 return "成功"
403 403 end
404 404  
405   -table.insert(helpDes, {"冒险内等级增加", "advcl", "经验值"})
406   -function _M.advcl(role, pms)
407   - local exp = tonum(pms.pm1)
408   - local advData = role:getAdvData()
  405 +-- table.insert(helpDes, {"冒险内等级增加", "advcl", "经验值"})
  406 +-- function _M.advcl(role, pms)
  407 +-- local exp = tonum(pms.pm1)
  408 +-- local advData = role:getAdvData()
409 409  
410   - if not advData.chapterId then
411   - return "先随便开启一关"
412   - end
413   - advData.battle.player:addExp(exp)
414   - advData:saveDB()
415   - role:mylog("gm_action", {desc = "advcl", int1 = exp, key1 = pms.sender})
  410 +-- if not advData.chapterId then
  411 +-- return "先随便开启一关"
  412 +-- end
  413 +-- advData.battle.player:addExp(exp)
  414 +-- advData:saveDB()
  415 +-- role:mylog("gm_action", {desc = "advcl", int1 = exp, key1 = pms.sender})
416 416  
417   - return "成功"
418   -end
  417 +-- return "成功"
  418 +-- end
419 419  
420 420 table.insert(helpDes, {"挂机清除" , "idlec"})
421 421 function _M.idlec(role, pms)
422   - role:updateProperty({field = "hangTeam", value = {}})
423 422 role:updateProperty({field = "hangInfo", value = {}})
424 423 role:updateProperty({field = "hangBag", value = {}})
425 424 role:mylog("gm_action", {desc = "idlec", key1 = pms.sender})
... ... @@ -534,7 +533,8 @@ function _M.test(role, pms)
534 533 local id = tonum(pms.pm1, 0)
535 534 --local hero = require ("actions.HeroAction")
536 535 --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id}))
537   - print(role:getPaybackReward(0, 10000))
  536 +
  537 + role:sendMail(13, nil, "1=2", {111})
538 538 return "成功"
539 539 end
540 540  
... ...
src/actions/HangAction.lua
... ... @@ -269,7 +269,15 @@ function _M.endBattleRpc(agent, data)
269 269 local nextCarbonId = role:getNextCarbonId(carbonId)
270 270 -- 设置挂机关卡
271 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 281 --local cfg = csvdb["idle_battleCsv"][nextCarbonId]
274 282 --if cfg then
275 283 -- hangInfo.bossTime = skynet.timex() + cfg.idle_time
... ... @@ -305,7 +313,10 @@ end
305 313 function _M.roleFormatRpc(agent , data)
306 314 local role = agent.role
307 315 local msg = MsgPack.unpack(data)
308   - local hangTeam = role:getProperty("hangTeam")
  316 + local index = msg.index -- 阵容索引
  317 + local title = msg.title -- 阵容名称
  318 + local tactics = msg.tactics -- 战术
  319 + local team = {}
309 320 for slot, heroId in pairs(msg.heros) do
310 321 if not role.heros[heroId] then
311 322 return 1
... ... @@ -321,15 +332,27 @@ function _M.roleFormatRpc(agent , data)
321 332 end
322 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 344 for slot, heroId in pairs(msg.heros) do
327   - hangTeam.heros[slot] = heroId
  345 + team.heros[slot] = heroId
328 346 end
329   - hangTeam.leader = msg.leader
330   - hangTeam.supports = supports
331   - role:saveHangTeam(hangTeam)
332   - role:finishGuide(5)
  347 + team.leader = msg.leader
  348 + team.supports = supports
  349 + team.title = title
  350 + if msg.tactics and globalCsv.tactics_skill_passive_cell[msg.tactics] then
  351 + team.tactics = msg.tactics
  352 + end
  353 +
  354 + role:setTeamFormat(index, team)
  355 +
333 356 SendPacket(actionCodes.Hang_roleFormatRpc, '')
334 357 return true
335 358 end
... ... @@ -440,36 +463,6 @@ function _M.quickRpc(agent , data)
440 463 return true
441 464 end
442 465  
443   -function _M.bonusFormatRpc(agent , data)
444   - local role = agent.role
445   - local msg = MsgPack.unpack(data)
446   - local bTeam = role:getProperty("bTeam")
447   - for slot, heroId in pairs(msg.heros) do
448   - if not role.heros[heroId] then
449   - return
450   - end
451   - end
452   - local supports = {}
453   - for slot, support in pairs(msg.supports) do
454   - if slot ~= 1 and slot ~= 2 then return end
455   - local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
456   - if level <= 0 then return end
457   - supports[slot] = support
458   - end
459   - if not checkLeader(msg.heros, msg.leader) then return end
460   -
461   - table.clear(bTeam)
462   - bTeam.heros = {}
463   - for slot, heroId in pairs(msg.heros) do
464   - bTeam.heros[slot] = heroId
465   - end
466   - bTeam.leader = msg.leader
467   - bTeam.supports = supports
468   -
469   - role:updateProperty({field = "bTeam", value = bTeam})
470   - SendPacket(actionCodes.Hang_bonusFormatRpc, '')
471   - return true
472   -end
473 466  
474 467 function _M.buyBonusCountRpc(agent, data)
475 468 local role = agent.role
... ... @@ -505,10 +498,53 @@ function _M.buyBonusCountRpc(agent, data)
505 498 return true
506 499 end
507 500  
  501 +local function bonusWinReward(role, bonusData, bwin, count)
  502 + count = count or 1
  503 + local open, actId = role.activity:isOpen("BonusDouble")
  504 + local actData = csvdb["activity_ctrlCsv"][actId]
  505 + local extraCnt = role.storeData:getBonusExtraFightCount()
  506 +
  507 + local coef = 1
  508 + if open and actData then
  509 + coef = tonumber(actData.condition2)
  510 + end
  511 + local bonusC = role.dailyData:getProperty("bonusC")
  512 + bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
  513 + if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] < count then return false, 1 end
  514 + bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count
  515 + role.dailyData:updateProperty({field = "bonusC", value = bonusC})
  516 +
  517 + local reward, change
  518 + reward = bonusData.reward:toNumMap()
  519 + for itemId, c in pairs(reward) do
  520 + reward[itemId] = c * count
  521 + end
  522 + for i = 1, count do
  523 + local chance = bonusData.chance:randWeight(true)
  524 + if chance[1] ~= 0 then
  525 + reward[chance[1]] = (reward[chance[1]] or 0) + chance[2]
  526 + end
  527 + end
  528 +
  529 + for k, v in pairs(reward) do
  530 + reward[k] = v * (coef > 1 and actData.condition or 1)
  531 + end
  532 +
  533 + if bwin then -- 满星 额外奖励
  534 + for k, v in pairs(bonusData.perfect_reward:toNumMap()) do
  535 + reward[k] = (reward[k] or 0) + v
  536 + end
  537 + end
  538 + reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}})
  539 + role:checkTaskEnter("BonusPass", {id = id, count = count})
  540 + return true, reward, change
  541 +end
  542 +
508 543 function _M.startBonusBattleRpc(agent, data)
509 544 local role = agent.role
510 545 local msg = MsgPack.unpack(data)
511 546 local id = msg.id
  547 + local count = msg.count or 1
512 548  
513 549 local open, actId = role.activity:isOpen("BonusDouble")
514 550  
... ... @@ -523,8 +559,6 @@ function _M.startBonusBattleRpc(agent, data)
523 559 if not bonusData then return 3 end
524 560 if not role:checkHangPass(bonusData.unlock) then return 4 end
525 561  
526   - if not next(role:getProperty("bTeam")) then return 5 end
527   -
528 562 local bonusC = role.dailyData:getProperty("bonusC")
529 563 bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
530 564  
... ... @@ -535,15 +569,24 @@ function _M.startBonusBattleRpc(agent, data)
535 569 if open and actData then
536 570 coef = tonumber(actData.condition2)
537 571 end
  572 +
  573 + if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end
538 574  
539   - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 7 end
540   -
  575 + local bonusStar = role:getProperty("bonusStar")
  576 + if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then
  577 + local status, reward, change = bonusWinReward(role, bonusData, nil, count)
  578 + if not status then return 10 * (reward or 0) end
  579 + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change}))
  580 + else
  581 + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
  582 + if not next(bTeam) then return 5 end
  583 + role.__bonusBattleCache = {
  584 + key = tostring(math.random()),
  585 + id = id,
  586 + }
  587 + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
  588 + end
541 589  
542   - role.__bonusBattleCache = {
543   - key = tostring(math.random()),
544   - id = id,
545   - }
546   - SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
547 590 return true
548 591 end
549 592  
... ... @@ -554,14 +597,7 @@ function _M.endBonusBattleRpc(agent, data)
554 597 local key = msg.key
555 598 local starNum = msg.starNum
556 599 if not role.__bonusBattleCache then return 1 end
557   - local open, actId = role.activity:isOpen("BonusDouble")
558   - local actData = csvdb["activity_ctrlCsv"][actId]
559   - local extraCnt = role.storeData:getBonusExtraFightCount()
560   -
561   - local coef = 1
562   - if open and actData then
563   - coef = tonumber(actData.condition2)
564   - end
  600 +
565 601  
566 602 if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then
567 603 SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1}))
... ... @@ -570,24 +606,79 @@ function _M.endBonusBattleRpc(agent, data)
570 606 local bonusData = csvdb["bonus_battleCsv"][id]
571 607  
572 608 local reward, change
  609 +
  610 + local bonusStar = role:getProperty("bonusStar")
  611 + local curStar = 0
573 612 if starNum and starNum > 0 then
574 613 -- 胜利扣除次数
575   - local bonusC = role.dailyData:getProperty("bonusC")
576   - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
577   - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 3 end
578   - bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1
579   - role.dailyData:updateProperty({field = "bonusC", value = bonusC})
580   -
581   - reward = bonusData.reward:toNumMap()
582   - local chance = bonusData.chance:randWeight(true)
583   - if chance[1] ~= 0 then
584   - reward[chance[1]] = (reward[chance[1]] or 0) + chance[2]
  614 +
  615 + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
  616 + local herosInfo = role:getTeamHerosInfo(bTeam.heros)
  617 +
  618 + local check = {}
  619 + -- 1 通关
  620 + check[1] = function(_)
  621 + return true
585 622 end
586   - for k, v in pairs(reward) do
587   - reward[k] = v * (coef > 1 and actData.condition or 1)
  623 + -- 2 阵亡人数 <= N
  624 + check[2] = function(_, cond)
  625 + return msg.info.dead and msg.info.dead <= cond
588 626 end
589   - reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}})
590   - role:checkTaskEnter("BonusPass", {id = id})
  627 + -- 3 全员存活
  628 + check[3] = function(_)
  629 + return msg.info.dead and msg.info.dead == 0
  630 + end
  631 + -- 4 指定种族 >= N
  632 + check[4] = function(_, cond)
  633 + local count = 0
  634 + for _, one in pairs(herosInfo) do
  635 + local heroData = csv["unitCsv"][one.type]
  636 + if heroData.camp == cond then
  637 + count = count + 1
  638 + end
  639 + end
  640 + return count >= cond
  641 + end
  642 + -- 5 指定职业 >= N
  643 + check[5] = function(_, cond)
  644 + local count = 0
  645 + for _, one in pairs(herosInfo) do
  646 + local heroData = csv["unitCsv"][one.type]
  647 + if heroData.job == cond then
  648 + count = count + 1
  649 + end
  650 + end
  651 + return count >= cond
  652 + end
  653 + -- 6 含有指定角色
  654 + check[6] = function(_, cond)
  655 + for _, one in pairs(herosInfo) do
  656 + if one.type == cond then
  657 + return true
  658 + end
  659 + end
  660 + return false
  661 + end
  662 + -- 7 通关耗时 <= X 秒 msg.info.atime
  663 + check[7] = function(_, cond)
  664 + return msg.info.atime and msg.info.atime <= cond
  665 + end
  666 + curStar = 0
  667 + local sweepConds = bonusData.sweep_condition:toTableArray(true)
  668 + for i, cond in ipairs(sweepConds) do
  669 + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then
  670 + curStar = curStar + (1 << (i - 1))
  671 + end
  672 + end
  673 + local status
  674 + status, reward, change = bonusWinReward(role, bonusData, curStar >= (1 << #sweepConds) - 1)
  675 + if not status then return 10 + (reward or 0) end
  676 + else
  677 + curStar = 0
  678 + end
  679 + if curStar ~= bonusStar[id] then
  680 + bonusStar[id] = curStar
  681 + role:updateProperty({field = "bonusStar", value = bonusStar})
591 682 end
592 683  
593 684 role:checkBattle("bonus", {
... ... @@ -666,4 +757,29 @@ function _M.chatLineRpc(agent, data)
666 757 return true
667 758 end
668 759  
669   -return _M
670 760 \ No newline at end of file
  761 +function _M.selectTeamRpc(agent, data)
  762 + local role = agent.role
  763 + local msg = MsgPack.unpack(data)
  764 + local index = msg.index -- 阵容索引
  765 + local type = msg.type -- 系统类型
  766 +
  767 + if index > 10 then
  768 + return 1
  769 + end
  770 + local team = role:getTeamFormat(index)
  771 + if not next(team) then return 2 end
  772 +
  773 + local teamIndex = role:getProperty("teamIndex") or {}
  774 + teamIndex[type] = index
  775 + role:updateProperty({field = "teamIndex", value = teamIndex})
  776 +
  777 + if type == TeamSystemType.Hang then
  778 + role:finishGuide(5)
  779 + role:updateHangTeamInfo()
  780 + end
  781 +
  782 + SendPacket(actionCodes.Hang_selectTeamRpc, '')
  783 + return true
  784 +end
  785 +
  786 +return _M
... ...
src/actions/HeroAction.lua
... ... @@ -143,74 +143,45 @@ function _M.talentRpc(agent, data)
143 143 local hero = role.heros[msg.id]
144 144 if not hero then return 1 end
145 145  
146   - local index = msg.index -- 第几个天赋
147   - local need = {[0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1}
148   - if not need[index] then return 2 end
149   -
150 146 local talent = hero:getProperty("talent")
  147 + local heroCfgId = hero:getProperty("type")
151 148 local curStage = talent:getv(0, 1)
152   - local curData = csvdb["unit_talentCsv"][curStage]
153   - if not curData then return 4 end
  149 + local curLevel = talent:getv(1, 1)
  150 + local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][curStage]
  151 + if not curData then return 1 end
154 152 local oldSkillLv = hero:getSkillLevel(1)
155 153  
156 154  
157 155 local cost = {}
158   - if index == 0 then
159   - --是否进阶
160   - local max = true
161   - for i = 1, 4 do
162   - if talent:getv(i, 0) < #curData then
163   - max = false
164   - break
165   - end
166   - end
167   - if max then
168   - talent = talent:setv(0, curStage + 1)
169   - for i = 1, 4 do
170   - talent = talent:setv(i, 0)
171   - end
172   - else
173   - return 12
174   - end
  156 + if curLevel == #curData then
  157 + talent = talent:setv(0, curStage + 1)
  158 + talent = talent:setv(1, 1)
175 159 else
176   -
177   - local level = talent:getv(index, 0)
178   - if level >= #curData then return 5 end
  160 + if curLevel > #curData then return 2 end
179 161  
180   - local talentData = curData[level]
181   - if not talentData then return end
  162 + local talentData = curData[curLevel]
  163 + if not talentData then return 3 end
182 164  
183   - if talentData.lvRequire > hero:getProperty("level") then return 6 end
  165 + if talentData.lvRequire > hero:getProperty("level") then return 4 end
184 166  
185 167 cost = talentData.money:toNumMap()
186   - local cost2 = talentData.cost:toNumMap()
187   - for k,v in pairs(cost2) do
188   - cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v
189   - end
190   - if not role:checkItemEnough(cost) then return 6 end
  168 + if not role:checkItemEnough(cost) then return 5 end
191 169 role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}})
192   - talent = talent:incrv(index, 1)
193   -
194   -
195   - local aheadLevel = 0
196   - for i = 1, talent:getv(0, 1) - 1 do
197   - aheadLevel = aheadLevel + #csvdb["unit_talentCsv"][i]
198   - end
199   - aheadLevel = aheadLevel + talent:getv(index, 0)
200   -
201   - role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = aheadLevel})
  170 + talent = talent:setv(1, curLevel + 1)
202 171 end
  172 + curStage = talent:getv(0, 1)
  173 + role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = curStage})
203 174  
204 175 hero:updateProperty({field = "talent", value = talent})
205 176  
206 177 role:log("hero_talent", {
207 178 hero_id = hero:getProperty("type"), --英雄ID
208   - hero_talent_id = index, --天赋ID
  179 + hero_talent_id = curStage, --天赋ID
209 180 hero_talent_cost = cost, -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
210 181 hero_talent_levelbef = oldSkillLv, -- 英雄技能升级前等级
211 182 hero_talent_level = hero:getSkillLevel(1), -- 英雄技能升级后等级
212 183 })
213   - hero:mylog({desc = "talent", int1 = index, int2 = talent:getv(index, 0)})
  184 + hero:mylog({desc = "talent", int1 = talent:getv(0, 1), int2 = talent:getv(1, 1)})
214 185  
215 186 SendPacket(actionCodes.Hero_talentRpc, '')
216 187 return true
... ... @@ -640,9 +611,37 @@ function _M.getResetRewardRpc(agent, data)
640 611 local level = hero:getProperty("level")
641 612 local breakL = hero:getProperty("breakL")
642 613 local talent = hero:getProperty("talent")
  614 + local heroCfgId = hero:getProperty("type")
643 615  
  616 + local tmpLevel = level
644 617 if level <= 1 and talent == "" then return end
645 618  
  619 + local pay = true
  620 + if level <= 60 then
  621 + pay = false
  622 + end
  623 +
  624 + if pay then
  625 + local costArr = globalCsv.unit_heroBack_cost:toArray(true, "=")
  626 + local itemCount = role:getItemCount(costArr[1])
  627 + local totalCost = {}
  628 + if itemCount >= costArr[2] then
  629 + totalCost[costArr[1]] = costArr[2]
  630 + else
  631 + local diamond = (costArr[2] - itemCount) * costArr[3]
  632 + if role:getItemCount(ItemId.Diamond) < diamond then
  633 + return 1
  634 + end
  635 + totalCost[costArr[1]] = itemCount
  636 + totalCost[ItemId.Diamond] = diamond
  637 + end
  638 +
  639 + --if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then
  640 + -- return 1
  641 + --end
  642 + role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}})
  643 + end
  644 +
646 645 local reward = {}
647 646 while level > 1 do
648 647 local curData = csvdb["unit_expCsv"][level - 1]
... ... @@ -659,32 +658,18 @@ function _M.getResetRewardRpc(agent, data)
659 658 end
660 659  
661 660 local stage = talent:getv(0, 1)
662   - local tlevel = {talent:getv(1, 0), talent:getv(2, 0), talent:getv(3, 0), talent:getv(4, 0)}
  661 + local curTalentLvl = talent:getv(1, 1)
  662 + --local tlevel = {talent:getv(1, 0), talent:getv(2, 0), talent:getv(3, 0), talent:getv(4, 0)}
663 663  
664   - local talentCostIds = globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp]
665 664 while stage > 0 do
666   - local curData = csvdb["unit_talentCsv"][stage]
667   - for level = math.max(table.unpack(tlevel)), 1, -1 do
668   - local add = 0
669   - for i = 1, 4 do
670   - if tlevel[i] == level then
671   - add = add + 1
672   - tlevel[i] = tlevel[i] - 1
673   - end
674   - end
675   - local talentData = curData[level - 1]
  665 + local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][stage]
  666 + for lvl = 1, curTalentLvl - 1 do
  667 + local talentData = curData[lvl]
676 668 for itemId, count in pairs(talentData.money:toNumMap()) do
677   - reward[itemId] = (reward[itemId] or 0) + count * add
678   - end
679   - for idx , count in pairs(talentData.cost:toNumMap()) do
680   - reward[talentCostIds[idx]] = (reward[talentCostIds[idx]] or 0) + count * add
  669 + reward[itemId] = (reward[itemId] or 0) + count
681 670 end
682 671 end
683 672 stage = stage - 1
684   - curData = csvdb["unit_talentCsv"][stage]
685   - if curData then
686   - tlevel = {#curData, #curData, #curData, #curData}
687   - end
688 673 end
689 674  
690 675 local equip = hero:getProperty("equip")
... ... @@ -708,9 +693,11 @@ function _M.getResetRewardRpc(agent, data)
708 693 rune = "",
709 694 })
710 695 hero:mylog({desc = "resetHero"})
711   -
  696 +
  697 + --local coef = globalCsv.unit_back_discount
  698 + --coef = (pay or tmpLevel <= 60) and 1 or coef
712 699 for itemId, count in pairs(reward) do
713   - reward[itemId] = math.floor(count * globalCsv.unit_back_discount)
  700 + reward[itemId] = count
714 701 end
715 702 local change
716 703 reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}})
... ... @@ -729,11 +716,14 @@ function _M.drawHeroRpc(agent, data)
729 716 local msg = MsgPack.unpack(data)
730 717  
731 718 if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end
732   - local btype = msg.pool -- 1 2 3 卡池类型
  719 + local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池
733 720 local subType = msg.subType or 1-- 定向卡池需要传 子类型
734 721 local drawType = msg.type -- 1 单抽 2 十连
735 722 if btype ~= 1 then
736 723 subType = 1
  724 + if btype == 4 and role:getProperty("newerDraw") >= 10 then
  725 + subType = 2
  726 + end
737 727 end
738 728  
739 729 if btype == 1 then
... ... @@ -754,23 +744,32 @@ function _M.drawHeroRpc(agent, data)
754 744  
755 745 -- 计算抽卡消耗品
756 746 local cost = {}
757   - local lastCount = drawCount[drawType]
758   - for _, costType in ipairs({"draw_card", "draw_coin"}) do
  747 + if buildTypeData["draw_coin_1"] == "" then
  748 + return 11
  749 + end
  750 + local diamondCost = buildTypeData["draw_coin_1"]:toArray(true, "=")
  751 +
  752 + local isEnough = true
  753 + for _, costType in ipairs({"draw_card_"}) do
  754 + costType = costType..drawCount[drawType]
759 755 if buildTypeData[costType] ~= "" then
760 756 local curCost = buildTypeData[costType]:toArray(true, "=")
761 757 local hadCount = role:getItemCount(curCost[1])
762   - local curCount = math.floor(hadCount / curCost[2])
763   - if curCount >= lastCount then
764   - cost[curCost[1]] = curCost[2] * lastCount
765   - lastCount = 0
  758 + if hadCount >= curCost[2] then
  759 + cost[curCost[1]] = curCost[2]
766 760 break
767   - elseif curCount > 0 then
768   - cost[curCost[1]] = curCost[2] * curCount
769   - lastCount = lastCount - curCount
  761 + else
  762 + cost[curCost[1]] = hadCount
  763 + diamondCost[2] = (curCost[2] - hadCount) * diamondCost[2]
  764 + if not role:checkItemEnough({[diamondCost[1]]=diamondCost[2]}) then
  765 + isEnough = false
  766 + break
  767 + end
  768 + cost[diamondCost[1]] = diamondCost[2]
770 769 end
771 770 end
772 771 end
773   - if lastCount > 0 then -- 钱不够
  772 + if isEnough == false then -- 钱不够
774 773 return 4
775 774 end
776 775  
... ... @@ -833,6 +832,9 @@ function _M.drawHeroRpc(agent, data)
833 832 --print(poolId, rand_v, weight, up_pool, values[1])
834 833 if rand_v < weight and up_pool then
835 834 up_pool = up_pool:toArray(true, "=")
  835 + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子
  836 + up_pool = role:getProperty("wishPool")
  837 + end
836 838 for k, v in ipairs(up_pool) do
837 839 resultPool[v] = {1}
838 840 end
... ... @@ -898,8 +900,14 @@ function _M.drawHeroRpc(agent, data)
898 900 end
899 901 end
900 902  
901   - if itemData.quality >= HeroQuality.SR then
902   - floorHeroCount = 0
  903 + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池
  904 + if itemData.quality == HeroQuality.SSR then
  905 + floorHeroCount = 0
  906 + end
  907 + else
  908 + if itemData.quality >= HeroQuality.SR then
  909 + floorHeroCount = 0
  910 + end
903 911 end
904 912  
905 913 if role:isHaveHero(itemData.id - ItemStartId.Hero) then
... ... @@ -922,6 +930,11 @@ function _M.drawHeroRpc(agent, data)
922 930 role:setProperty("floorHero", floorHero)
923 931 end
924 932  
  933 + if btype == 4 then
  934 + local newCount = role:getProperty("newerDraw")
  935 + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]})
  936 + end
  937 +
925 938 role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]})
926 939 if ssrCount > 0 then
927 940 role:checkTaskEnter("DrawSSR", {count = ssrCount})
... ... @@ -1068,4 +1081,51 @@ function _M.changeCrown(agent, data)
1068 1081 return true
1069 1082 end
1070 1083  
  1084 +function _M.itemComposeRpc(agent, data)
  1085 + local role = agent.role
  1086 + local msg = MsgPack.unpack(data)
  1087 +
  1088 + local itemId = msg.id
  1089 + local count = msg.count
  1090 + if not csvdb["itemCsv"][itemId] then return 1 end
  1091 + local config = csvdb["item_processCsv"][itemId]
  1092 + if not config then return 2 end
  1093 +
  1094 + local cost = config.cost:toNumMap()
  1095 + if not role:checkItemEnough(cost) then return 2 end
  1096 + role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}})
  1097 + role:award({[itemId] = count}, {log = {desc = "itemCompose"}})
  1098 +
  1099 + SendPacket(actionCodes.Hero_itemComposeRpc, "")
  1100 + return true
  1101 +end
  1102 +
  1103 +function _M.setWishPoolRpc(agent, data)
  1104 + local role = agent.role
  1105 + local msg = MsgPack.unpack(data)
  1106 +
  1107 + local heros = msg.heros
  1108 + if #heros > 3 then return 1 end
  1109 +
  1110 + for _, heroId in pairs(heros) do
  1111 + local cfg = csvdb["build_poolCsv"][heroId]
  1112 + if not cfg then return 2 end
  1113 +
  1114 + local buildTypeData = csvdb["build_typeCsv"][5]
  1115 + if not buildTypeData then return 3 end
  1116 + local poolMap = buildTypeData["pool"]:toNumMap()
  1117 + local poolId = poolMap[1]
  1118 + if not poolId then return 4 end
  1119 +
  1120 + if cfg["pool_"..poolId] == 0 then
  1121 + return 5
  1122 + end
  1123 + end
  1124 +
  1125 + role:updateProperty({field="wishPool", value = heros})
  1126 +
  1127 + SendPacket(actionCodes.Hero_setWishPoolRpc, "")
  1128 + return true
  1129 +end
  1130 +
1071 1131 return _M
... ...
src/actions/PvpAction.lua
... ... @@ -50,6 +50,9 @@ function _M.formatCommonRpc(agent , data)
50 50 end
51 51 pvpTC.leader = msg.leader
52 52 pvpTC.supports = supports
  53 + if msg.tactics and globalCsv.tactics_skill_passive_cell[msg.tactics] then
  54 + pvpTC.tactics = msg.tactics
  55 + end
53 56  
54 57 role:savePvpCTeam(pvpTC)
55 58 SendPacket(actionCodes.Pvp_formatCommonRpc, '')
... ... @@ -92,6 +95,9 @@ function _M.formatHighRpc(agent , data)
92 95 curTeam.heros = team.heros
93 96 curTeam.leader = team.leader
94 97 curTeam.supports = supports
  98 + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then
  99 + curTeam.tactics = team.tactics
  100 + end
95 101  
96 102 table.insert(pvpTH, curTeam)
97 103 end
... ... @@ -462,6 +468,10 @@ function _M.startBattleHRpc(agent, data)
462 468 curTeam.heros = team.heros
463 469 curTeam.leader = team.leader
464 470 curTeam.supports = supports
  471 + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then
  472 + curTeam.tactics = team.tactics
  473 + end
  474 +
465 475  
466 476 table.insert(pvpTH, curTeam)
467 477 end
... ... @@ -725,6 +735,7 @@ function _M.endBattleHRpc(agent, data)
725 735 myRank = myRank,
726 736 oldMyRank = oldMyRank,
727 737 video = video,
  738 + headers = headers,
728 739 isWin = isWin,
729 740 }))
730 741 return true
... ...
src/actions/RadioAction.lua 0 → 100644
... ... @@ -0,0 +1,181 @@
  1 +local _M = {}
  2 +
  3 +-- 获取英雄大成功率
  4 +local function getHeroCoef(hero, condition)
  5 + -- 基础概率
  6 + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20}
  7 + local rare = hero:getRare()
  8 + local result = 0
  9 + for _, it in ipairs(condition:toTableArray(true)) do
  10 + local type = it[1]
  11 + local value = it[2]
  12 + local add = it[3]
  13 + if type == 1 then -- 种族加成
  14 + if hero:getCamp() == value then
  15 + result = result + add
  16 + end
  17 + elseif type == 2 then -- 定位加成
  18 + if hero:getPosition() == value then
  19 + result = result + add
  20 + end
  21 + end
  22 + end
  23 +
  24 + return result + (rareMap[rare] or 0)
  25 +end
  26 +
  27 +local function getQuestMax(role)
  28 + local count = 0
  29 + for _, carbonId in ipairs(globalCsv.crusade_team_unlock or {}) do
  30 + if role:checkHangPass(carbonId) then
  31 + count = count + 1
  32 + end
  33 + end
  34 +
  35 + return count + (globalCsv.cursade_team_count_initial or 0)
  36 +end
  37 +
  38 +function _M.startQuestRpc(agent, data)
  39 + local role = agent.role
  40 + local msg = MsgPack.unpack(data)
  41 + local id = msg.id
  42 + local heros = msg.heros
  43 + local result = {}
  44 + local radioTask = role:getProperty("radioTask")
  45 + if table.numbers(radioTask) >= getQuestMax(role) then
  46 + return 1
  47 + end
  48 + -- check id
  49 + local config = csvdb["crusadeCsv"][id]
  50 + if not config then return 2 end
  51 + if not role:checkHangPass(config.unlock) then return 3 end
  52 + if radioTask[id] then return 4 end
  53 + -- check hero
  54 + --1=指定等级=人数
  55 + --2=指定稀有度=人数
  56 + --3=人数
  57 + local needHeroCnt = 0
  58 + local lvlMap = {}
  59 + local rareMap = {}
  60 + for _, it in ipairs(config.condition:toTableArray(true)) do
  61 + local type = it[1]
  62 + if type == 1 then
  63 + lvlMap[1] = it[2]
  64 + lvlMap[2] = it[3]
  65 + elseif type == 2 then
  66 + rareMap[1] = it[2]
  67 + rareMap[2] = it[3]
  68 + elseif type == 3 then
  69 + needHeroCnt = it[2]
  70 + end
  71 + end
  72 + for _, heroId in ipairs(heros) do
  73 + local hero = role.heros[heroId]
  74 + if hero then
  75 + needHeroCnt = needHeroCnt - 1
  76 + if next(lvlMap) then
  77 + if hero:getProperty("level") >= lvlMap[1] then
  78 + lvlMap[2] = lvlMap[2] - 1
  79 + if lvlMap[2] <= 0 then
  80 + lvlMap = {}
  81 + end
  82 + end
  83 + end
  84 + if next(rareMap) then
  85 + if hero:getRare() >= rareMap[1] then
  86 + rareMap[2] = rareMap[2] - 1
  87 + end
  88 + if rareMap[2] <= 0 then
  89 + rareMap = {}
  90 + end
  91 + end
  92 + end
  93 + end
  94 + if needHeroCnt > 0 or next(rareMap) or next(lvlMap) then
  95 + return 5
  96 + end
  97 + -- start quest, set finish time
  98 + local taskData = {}
  99 + taskData["time"] = skynet.timex() + config.time
  100 + taskData["heros"] = heros
  101 + radioTask[id] = taskData
  102 + role:updateProperty({field="radioTask", value=radioTask, notNotify=true})
  103 +
  104 + SendPacket(actionCodes.Radio_startQuestRpc, MsgPack.pack({id=id, task=taskData}))
  105 + return true
  106 +end
  107 +
  108 +function _M.finishQuestRpc(agent, data)
  109 + local role = agent.role
  110 + local msg = MsgPack.unpack(data)
  111 + local id = msg.id
  112 + -- check finish time
  113 + local radioTask = role:getProperty("radioTask")
  114 + local task = radioTask[id]
  115 + if not task then return 1 end
  116 + if skynet.timex() < task.time then return 2 end
  117 + -- check id
  118 + local config = csvdb["crusadeCsv"][id]
  119 + if not config then return 3 end
  120 + local carbonData = csvdb["idle_battleCsv"][config.unlock]
  121 + if not carbonData then return 4 end
  122 + -- get heros
  123 + local totalCoef = 0
  124 + local exp = config.time / 60
  125 + local heroFaithMap = {}
  126 + for _, heroId in ipairs(task.heros) do
  127 + local hero = role.heros[heroId]
  128 + if hero then
  129 + totalCoef = totalCoef + getHeroCoef(hero, config.success)
  130 + -- 增加英雄信赖
  131 + hero:addHeroFaith(exp)
  132 + heroFaithMap[heroId] = hero:getProperty("faith")
  133 + end
  134 + end
  135 + -- send award
  136 + local bigSuccess = false
  137 + local result = math.randomInt(0, 100)
  138 + if result < totalCoef then
  139 + bigSuccess = true
  140 + end
  141 + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear
  142 + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear
  143 + local itemReward = config.item_clear_special:toNumMap()
  144 + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money
  145 + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp
  146 + if bigSuccess then
  147 + for key, value in pairs(itemReward) do
  148 + itemReward[key] = math.ceil(1.5 * value)
  149 + end
  150 + end
  151 +
  152 + local r, change = role:award(itemReward, {log = {desc = "radioQuest", int1 = id}})
  153 +
  154 + radioTask[id] = nil
  155 + role:updateProperty({field="radioTask", value=radioTask, notNotify = true})
  156 +
  157 + local msg = role:packReward(r, change)
  158 + msg["big"] = bigSuccess
  159 + msg["id"] = id
  160 + msg["heroFaith"] = heroFaithMap
  161 + SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg))
  162 + return true
  163 +end
  164 +
  165 +function _M.cancelQuestRpc(agent, data)
  166 + local role = agent.role
  167 + local msg = MsgPack.unpack(data)
  168 + local id = msg.id
  169 + -- check finish time
  170 + local radioTask = role:getProperty("radioTask")
  171 + local task = radioTask[id]
  172 + if not task then return 1 end
  173 + if skynet.timex() > task.time then return 2 end
  174 + radioTask[id] = nil
  175 + role:updateProperty({field="radioTask", value=radioTask, notNotify = true})
  176 +
  177 + SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack({id = id}))
  178 + return true
  179 +end
  180 +
  181 +return _M
0 182 \ No newline at end of file
... ...
src/actions/RoleAction.lua
... ... @@ -291,7 +291,7 @@ function _M.loginRpc( agent, data )
291 291  
292 292  
293 293 -- 玩家登陆做的一些操作
294   - role:saveHangTeam()
  294 + role:updateHangTeamInfo()
295 295 role:savePvpCTeam()
296 296 role:savePvpHTeam()
297 297  
... ... @@ -1255,4 +1255,40 @@ function _M.useSelectItemRpc(agent, data)
1255 1255 return true
1256 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 +
  1282 +function _M.accuseRpc(agent, data)
  1283 + local role = agent.role
  1284 + local msg = MsgPack.unpack(data)
  1285 + local targetId = msg.targetId
  1286 + local atype = msg.type
  1287 + local note = msg.note
  1288 +
  1289 + role:mylog("role_action", {desc = "accuse", int1 = targetId, short1 = atype, text1 = note})
  1290 + SendPacket(actionCodes.Role_accuseRpc, "")
  1291 + return true
  1292 +end
  1293 +
1258 1294 return _M
1259 1295 \ No newline at end of file
... ...
src/actions/StoreAction.lua
1 1 local _M = {}
2 2  
3   -local serverId = tonumber(skynet.getenv("servId"))
4 3 local md5 = require "md5"
5 4  
6   -local function makeOrder(roleId, rechargeId)
7   - local orderId = redisproxy:hincrby("autoincrement_set", "order", 1)
8   - local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId)
9   - local orderKey = string.format("order:%d:%d", roleId, orderId)
10   - redisproxy:del(orderKey)
11   - local order = require("models.Order").new({
12   - key = orderKey,
13   - order = partnerOrderId,
14   - rechargeId = rechargeId,
15   - })
16   - order:create()
17   - redisproxy:sadd(string.format("role:%d:orders", roleId), partnerOrderId)
18   - return partnerOrderId
19   -end
20   -
21 5 -- 入口在正式服关闭 -- mock 充值
22 6 function _M.rechargeRpc(agent , data)
23 7 if true then return end
... ... @@ -29,7 +13,7 @@ function _M.rechargeRpc(agent , data)
29 13 local roleId = role:getProperty("id")
30 14  
31 15 --创建订单号
32   - local partnerOrderId = makeOrder(roleId, id)
  16 + local partnerOrderId = role:getPurchaseOrder(id)
33 17 SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId }))
34 18  
35 19  
... ... @@ -78,7 +62,7 @@ function _M.googleRechargeRpc(agent, data)
78 62  
79 63 role.ignoreHeartbeat = true
80 64 --创建订单号
81   - local partnerOrderId = makeOrder(roleId, id)
  65 + local partnerOrderId = role:getPurchaseOrder(id)
82 66 -- 签名
83 67 local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075"
84 68 local need = {
... ... @@ -105,7 +89,7 @@ function _M.myCardRechargeRpc(agent, data)
105 89  
106 90 role.ignoreHeartbeat = true
107 91 --创建订单号
108   - local partnerOrderId = makeOrder(roleId, id)
  92 + local partnerOrderId = role:getPurchaseOrder(id)
109 93 -- 签名
110 94 local secret_key = "48759e07540f46d9af17ec82669b4272"
111 95 local need = {
... ... @@ -131,7 +115,7 @@ function _M.iosRechargeRpc(agent, data)
131 115  
132 116 role.ignoreHeartbeat = true
133 117 --创建订单号
134   - local partnerOrderId = makeOrder(roleId, id)
  118 + local partnerOrderId = role:getPurchaseOrder(id)
135 119 -- 签名
136 120 local secret_key = "9647d2efe1074c73b9ac19af4337a70e"
137 121 local need = {
... ... @@ -155,43 +139,15 @@ function _M.purchaseOrderResult(agent, data)
155 139  
156 140 role.ignoreHeartbeat = false
157 141  
158   - local partnerOrderStr = msg.order
159   - local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)")
160   - local orderObject = require("models.Order").new({ key = string.format("order:%d:%d", roleId, orderId) })
161   - if not orderObject:load() then
162   - -- 订单不存在
163   - skynet.error("cancelPurchaseRpc", string.format("order %s not exist", partnerOrderStr))
164   - return true
165   - end
166   -
167   - if msg.status == "success" then
168   - orderObject:setProperty("transactionId", msg.platformOrder or "")
169   - local rechargeId = orderObject:getProperty("rechargeId")
170   - local dataSet = csvdb["shop_rechargeCsv"][rechargeId]
171   -
172   - role:log("setOrder", {
173   - order_status = 100, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
174   - item_id = rechargeId, -- 道具id
175   - item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
176   - item_name = dataSet.title, -- 购买的道具名
177   - item_number = 1, -- 购买的道具数量
178   - item_level = 1, -- 购买的道具等级
179   - order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
180   - order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
181   - order_type = role:getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0
182   - order_id = msg.platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
183   - })
184   -
185   - return true
186   - end
  142 + local status = {
  143 + fail = true,
  144 + success = true
  145 + }
187 146  
188   - if orderObject:getProperty("finishTime") > 0 then
189   - return true
  147 + local partnerOrderStr = msg.order
  148 + if partnerOrderStr then
  149 + role:updatePurchaseOrder(partnerOrderStr, msg.platformOrder, status[msg.status] and msg.status or "unknown")
190 150 end
191   -
192   - orderObject:setProperty("status", msg.status)
193   -
194   - redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr)
195 151 return true
196 152 end
197 153  
... ... @@ -441,4 +397,24 @@ function _M.getExploreCommandRewardRpc(agent, data)
441 397 return true
442 398 end
443 399  
  400 +-- 累充奖励
  401 +function _M.getTotalRechargeAwardRpc(agent, data)
  402 + local role = agent.role
  403 + local msg = MsgPack.unpack(data)
  404 + local index = msg.index -- 领取的索引id
  405 + local totalRechargeRecord = role.storeData:getProperty("totalRR")
  406 + local flag = string.char(string.getbit(totalRechargeRecord, index))
  407 + if flag == "1" then
  408 + return 1
  409 + end
  410 + totalRechargeRecord = string.setbit(totalRechargeRecord, index)
  411 + role.storeData:updateProperty({field = "totalRR", value = totalRechargeRecord})
  412 + local cfg = csvdb["Csv"][index]
  413 + if not cfg then return 2 end
  414 +
  415 + local reward, _ = role:award(cfg.reward, {log = {desc = "totalRecharge", int1 = index}})
  416 + SendPacket(actionCodes.Store_getTotalRechargeAwardRpc, MsgPack.pack({reward = reward}))
  417 + return true
  418 +end
  419 +
444 420 return _M
445 421 \ No newline at end of file
... ...
src/actions/TowerAction.lua
... ... @@ -8,36 +8,6 @@ local MsgPack = MsgPack
8 8 local _M = {}
9 9  
10 10  
11   -function _M.roleFormatRpc(agent , data)
12   - local role = agent.role
13   - local msg = MsgPack.unpack(data)
14   - local towerTeam = role:getProperty("towerF")
15   - for slot, heroId in pairs(msg.heros) do
16   - if not role.heros[heroId] then
17   - return
18   - end
19   - end
20   - local supports = {}
21   - for slot, support in pairs(msg.supports) do
22   - if slot ~= 1 and slot ~= 2 then return end
23   - local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
24   - if level <= 0 then return end
25   - supports[slot] = support
26   - end
27   - table.clear(towerTeam)
28   - towerTeam.heros = {}
29   - for slot, heroId in pairs(msg.heros) do
30   - towerTeam.heros[slot] = heroId
31   - end
32   - towerTeam.leader = msg.leader
33   - towerTeam.supports = supports
34   -
35   -
36   - role:updateProperty({field = "towerF", value = towerTeam})
37   - SendPacket(actionCodes.Tower_roleFormatRpc, '')
38   - return true
39   -end
40   -
41 11  
42 12 local function getUpdateTime(lastCount, lastTime)
43 13 local nextCount, nextTime = lastCount, skynet.timex()
... ...
src/adv/Adv.lua
... ... @@ -58,7 +58,7 @@ function Adv:initByInfo(advInfo)
58 58 self.maps[id] = AdvMap.new(self, id, map)
59 59 end
60 60  
61   - self:initBattle()
  61 + self:initBattle(advInfo)
62 62 end
63 63 -- 找出level 是否存在中继层
64 64 function Adv:isHaveRelay(level, chapterId)
... ... @@ -102,6 +102,9 @@ function Adv:initByChapter(params)
102 102 self.cacheUnlock = self.cacheUnlock or {}
103 103 self.shopStatus = self.shopStatus or {}
104 104 self.support = self.support or {}
  105 + if self.battle then
  106 + self.battle:overBattle()
  107 + end
105 108 self.battle = nil -- 清掉 老的 battle
106 109 self.logid = self.owner:getActionUcode()
107 110  
... ... @@ -146,7 +149,7 @@ function Adv:initByChapter(params)
146 149 self.maps = {}
147 150 self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay)
148 151  
149   - self:initBattle(true)
  152 + self:initBattle(nil)
150 153  
151 154 self:initLayerTask()
152 155  
... ... @@ -211,7 +214,7 @@ function Adv:saveDB(notNotify)
211 214 advInfo.logid = self.logid
212 215 advInfo.maps = {}
213 216  
214   - self.battle:saveDB()
  217 + self.battle:saveDB(advInfo)
215 218  
216 219 for id , map in ipairs(self.maps) do
217 220 advInfo.maps[id] = map:getDB()
... ... @@ -453,7 +456,7 @@ function Adv:clearAdvUnlockCache()
453 456 self.cacheUnlock = {}
454 457 end
455 458  
456   -function Adv:initBattle(notDb)
  459 +function Adv:initBattle(info)
457 460 self.battle = require("adv.AdvBattle").new(self)
458 461 for _, passiveC in ipairs(self.cachePassiveEvent or {}) do
459 462 self.battle:triggerPassive(passiveC[1], passiveC[2])
... ... @@ -465,9 +468,16 @@ function Adv:initBattle(notDb)
465 468 map:initBattleAfter()
466 469 end
467 470 --下层
468   - if notDb and self.level ~= 1 then
  471 + if not info and self.level ~= 1 then
469 472 self.battle.player:attrChangeCondBuffCheck(1)
470 473 end
  474 +
  475 + -- 初始化
  476 + if not info then
  477 + self.battle:newBattle()
  478 + else
  479 + self.battle:loadBattle(info)
  480 + end
471 481 end
472 482  
473 483 function Adv:triggerPassive(condType, params)
... ... @@ -936,7 +946,7 @@ end
936 946  
937 947 -- log long1 字段被征用!!!
938 948 -- 在冒险中获得的物品都发放在冒险背包内
939   -function Adv:award(gift, params)
  949 +function Adv:award(gift, params, backRewardParams)
940 950 params = params or {}
941 951 local tgift = {}
942 952 if type(gift) == "string" then
... ... @@ -948,6 +958,8 @@ function Adv:award(gift, params)
948 958 end
949 959 local items = self.owner:getProperty("advItems")
950 960 local oldItems = items
  961 +
  962 + local autoUse = {}
951 963 for itemId, count in pairs(tgift) do
952 964 if count > 0 then
953 965 local buffAdd = self.battle.player:getRewardChange(itemId)
... ... @@ -956,41 +968,45 @@ function Adv:award(gift, params)
956 968 self:checkAchievement(Adv.AchievType.GetItem, count, itemId)
957 969 end
958 970 tgift[itemId] = count
959   - local origin = items:getv(itemId, 0)
960   - local nums = origin + count
961   -
962   - if csvdb["adv_artifactCsv"][itemId] then -- 获得神器
963   - self:awardArtifact(itemId, params)
964   - if not self.owner:checkOverGuide(55) then
965   - self.owner:saveGuide(55,1,true)
966   - end
  971 + if globalCsv.adv_auto_useItem[itemId] and count > 0 then
  972 + autoUse[itemId] = count
967 973 else
968   - if nums <= 0 then
969   - items = items:delk(itemId)
970   - nums = 0
  974 + local origin = items:getv(itemId, 0)
  975 + local nums = origin + count
  976 +
  977 + if csvdb["adv_artifactCsv"][itemId] then -- 获得神器
  978 + self:awardArtifact(itemId, params)
  979 + if not self.owner:checkOverGuide(55) then
  980 + self.owner:saveGuide(55,1,true)
  981 + end
971 982 else
972   - items = items:setv(itemId, nums)
973   - end
  983 + if nums <= 0 then
  984 + items = items:delk(itemId)
  985 + nums = 0
  986 + else
  987 + items = items:setv(itemId, nums)
  988 + end
974 989  
975   - if itemId == 16 and not self.owner:checkOverGuide(51,4) then
976   - self.owner:saveGuide(51,4)
977   - end
978   - if params.log then
979   - local log = clone(params.log)
980   - if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then
981   - print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback())
  990 + if itemId == 16 and not self.owner:checkOverGuide(51,4) then
  991 + self.owner:saveGuide(51,4)
982 992 end
983   - log["cint1"] = itemId
984   - log["cint2"] = math.abs(count)
985   - log["cint3"] = self.chapterId
986   - log["long1"] = self.level
987   - if count >= 0 then
988   - self.owner:mylog("in_adv", log)
  993 + if params.log then
  994 + local log = clone(params.log)
  995 + if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then
  996 + print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback())
  997 + end
  998 + log["cint1"] = itemId
  999 + log["cint2"] = math.abs(count)
  1000 + log["cint3"] = self.chapterId
  1001 + log["long1"] = self.level
  1002 + if count >= 0 then
  1003 + self.owner:mylog("in_adv", log)
  1004 + else
  1005 + self.owner:mylog("out_adv", log)
  1006 + end
989 1007 else
990   - self.owner:mylog("out_adv", log)
  1008 + print("addAdvItem no log ", debug.traceback())
991 1009 end
992   - else
993   - print("addAdvItem no log ", debug.traceback())
994 1010 end
995 1011 end
996 1012 end
... ... @@ -1001,10 +1017,48 @@ function Adv:award(gift, params)
1001 1017 if tgift[ItemId.OldCoin] then
1002 1018 self.battle.player:attrChangeCondBuffCheck(0)
1003 1019 end
  1020 +
  1021 + if backRewardParams then
  1022 + self:backReward(tgift, backRewardParams)
  1023 + end
  1024 +
  1025 + if next(autoUse) then
  1026 + for itemId, count in pairs(autoUse) do
  1027 + self:useItem(itemId, count)
  1028 + end
  1029 + self:backUse(autoUse, 1)
  1030 + end
1004 1031 return tgift
1005 1032 end
1006 1033  
1007 1034  
  1035 +function Adv:useItem(itemId, count, target)
  1036 + local itemData = csvdb["adv_itemCsv"][itemId]
  1037 + if not itemData then return end
  1038 +
  1039 + if itemData["function"] == 0 or itemData["function"] == 2 then count = 1 end
  1040 +
  1041 + if itemId == 5020 then
  1042 + self.owner:finishGuide(53)
  1043 + end
  1044 +
  1045 + self:checkAchievement(self.AchievType.UseItem, count, itemId)
  1046 + self:mylog({desc = "useItem", int1 = itemId, int2 = count})
  1047 +
  1048 + self.owner:log("mission_pick_use", {
  1049 + mission_threadid = self.chapterId, -- 大地图ID
  1050 + mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称
  1051 + mission_id = self.level, -- 关卡ID
  1052 + item_id = itemId, -- 道具ID
  1053 + mission_pick_use_num = count, -- 道具使用量
  1054 + mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志
  1055 + })
  1056 +
  1057 + for i = 1, count do
  1058 + self:doActive(itemData.effect, target) -- target
  1059 + end
  1060 +end
  1061 +
1008 1062 -- 消耗物品 优先冒险背包 --check 只是检查够不够
1009 1063 function Adv:cost(item, params, check)
1010 1064 local items = self.owner:getProperty("advItems")
... ... @@ -1040,7 +1094,9 @@ local function clickOut(self, room, block, params, isExit)
1040 1094 end
1041 1095  
1042 1096 if #self.mapStack > 1 then -- 处于夹层中
  1097 + local oldMapIdx = self:getCurMapIdx()
1043 1098 table.remove(self.mapStack) --退出夹层
  1099 + self.battle:iLayerChange(oldMapIdx)
1044 1100 self:backLayer(-1)
1045 1101 else --处于底层
1046 1102  
... ... @@ -1071,11 +1127,10 @@ local function clickOut(self, room, block, params, isExit)
1071 1127 self.battle.player:triggerPassive(Passive.DOWN_LAYER)
1072 1128  
1073 1129 if curFloorData then
1074   - self:backReward(self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}}))
  1130 + self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}}, {})
1075 1131 end
1076 1132 local isHaveRelay = self:isHaveRelay(self.level)
1077 1133  
1078   - self.owner:getProperty("advTeam").player = self.battle.player:getDB() -- 临时缓存住 battle 的player
1079 1134 if isHaveRelay and not self.isRelay then
1080 1135 self:initByChapter({
1081 1136 chapterId = self.chapterId,
... ... @@ -1255,7 +1310,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
1255 1310 skynet.error(string.format("[ERROR]: event_dropCsv no id %s in %s id: %s", effect[2], tag, chooseData.id))
1256 1311 end
1257 1312 end
1258   - self:backReward(self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}), {roomId = room.roomId, blockId = block.blockId})
  1313 + self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, {roomId = room.roomId, blockId = block.blockId})
1259 1314 end,
1260 1315 [2] = function() --获得冒险buff
1261 1316 local layer = effect[3] or 1
... ... @@ -1419,14 +1474,12 @@ local function clickDrop(self, room, block, params)
1419 1474 if not self.battle or not self.battle.player then return end
1420 1475 self.battle.player:triggerPassive(Passive.CLICK_DROP)
1421 1476  
1422   - local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}})
1423   - -- local reward = self:award({[5801] = 1})
1424   - -- 获取绷带的引导
  1477 + local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}, {roomId = room.roomId, blockId = block.blockId})
  1478 +
1425 1479 if block.event.item[1] == 5020 and not self.owner:checkOverGuide(53,2) then
1426 1480 self.owner:saveGuide(53,2)
1427 1481 end
1428 1482 block:clear()
1429   - self:backReward(reward, {roomId = room.roomId, blockId = block.blockId})
1430 1483 return true
1431 1484 end
1432 1485  
... ... @@ -1447,7 +1500,7 @@ local function clickTrader(self, room, block, params)
1447 1500 local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100)
1448 1501 if not self:cost({[goodsData.currency] = costCount}, {log = {desc = "clickTrader", int1 = block.event.id}}) then return false, 6 end --不够
1449 1502 self:backCost({[goodsData.currency] = costCount})
1450   - local reward = self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}})
  1503 + self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}, {})
1451 1504 if goodsData.restrict == 1 then
1452 1505 self.shopStatus[goodsData.goods] = (self.shopStatus[goodsData.goods] or 0) + 1
1453 1506 elseif goodsData.restrict == 2 then
... ... @@ -1459,7 +1512,6 @@ local function clickTrader(self, room, block, params)
1459 1512 buyCount = buyCount + 1
1460 1513 self:checkTask(Adv.TaskType.Shop, 1, block.event.id)
1461 1514 self:checkAchievement(Adv.AchievType.Shop, 1, block.event.id)
1462   - self:backReward(reward)
1463 1515  
1464 1516 if (traderData.purchasetime ~= 0 and traderData.purchasetime <= buyCount) or #block.event.shop <= buyCount then
1465 1517 block:clear()
... ... @@ -1501,7 +1553,7 @@ local function clickClick(self, room, block, params)
1501 1553 local item = csvdb["event_dropCsv"][dropId]["range"]:randWeight(true)
1502 1554 reward[item[1]] = (reward[item[1]] or 0) + item[2]
1503 1555 end
1504   - self:backReward(self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}), {roomId = room.roomId, blockId = block.blockId})
  1556 + self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}, {roomId = room.roomId, blockId = block.blockId})
1505 1557 end,
1506 1558 [3] = function()
1507 1559 for _, buffId in ipairs(clickData.effect:toArray(true, "=")) do
... ... @@ -1521,6 +1573,7 @@ local function clickClick(self, room, block, params)
1521 1573 end
1522 1574  
1523 1575 local function clickLayer(self, room, block, params)
  1576 + local oldMapIdx = self:getCurMapIdx()
1524 1577 if block.event.mapIdx then
1525 1578 table.insert(self.mapStack, block.event.mapIdx) --进入夹层
1526 1579 else
... ... @@ -1536,6 +1589,7 @@ local function clickLayer(self, room, block, params)
1536 1589 self.maps[mapIdx]:initBattleAfter()
1537 1590 self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId)
1538 1591 end
  1592 + self.battle:iLayerChange(oldMapIdx)
1539 1593 self:backLayer(1)
1540 1594 return true
1541 1595 end
... ... @@ -1842,23 +1896,31 @@ end
1842 1896  
1843 1897 -- 地图上物品变化
1844 1898 function Adv:mapItemChange(ctype)
  1899 + local blocks = {}
  1900 + for roomId, room in pairs(self:getCurMap().rooms) do
  1901 + for blockId, block in pairs(room.blocks) do
  1902 + table.insert(blocks, block)
  1903 + end
  1904 + end
  1905 + self:blockDropChange(ctype, blocks)
  1906 +end
  1907 +
  1908 +function Adv:blockDropChange(ctype, blocks)
1845 1909 local clist = csvdb["transform_itemCsv"][ctype]
1846 1910 if clist then
1847   - for roomId, room in pairs(self:getCurMap().rooms) do
1848   - for blockId, block in pairs(room.blocks) do
1849   - if block:getEventType() == AdvEventType.Drop and block.event.item then
1850   - local id = block.event.item[1]
1851   - local count = block.event.item[2]
1852   - local changeTo = nil
1853   - if clist[id] then
1854   - changeTo = {clist[id].toId, math.ceil(count * clist[id].num)}
1855   - elseif clist[-1] then
1856   - changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)}
1857   - end
1858   - if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then
1859   - block.event.item = changeTo
1860   - self:backBlockChange(roomId, blockId, ctype)
1861   - end
  1911 + for _, block in ipairs(blocks) do
  1912 + if block:getEventType() == AdvEventType.Drop and block.event.item then
  1913 + local id = block.event.item[1]
  1914 + local count = block.event.item[2]
  1915 + local changeTo = nil
  1916 + if clist[id] then
  1917 + changeTo = {clist[id].toId, math.ceil(count * clist[id].num)}
  1918 + elseif clist[-1] then
  1919 + changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)}
  1920 + end
  1921 + if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then
  1922 + block.event.item = changeTo
  1923 + self:backBlockChange(block.room.roomId, block.blockId, ctype)
1862 1924 end
1863 1925 end
1864 1926 end
... ... @@ -1887,76 +1949,148 @@ function Adv:enemyDead(enemy, escape)
1887 1949 else
1888 1950 self:scoreChange(AdvScoreType.Kill, monsterData.advScore)
1889 1951 end
1890   - local changeV = self.battle.player:addExp(monsterData.exp)
1891   - self:backDead(enemyId, changeV)
1892   -
1893   - local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK)
1894   - if toClick then
1895   - toClick = toClick:effect()
  1952 + -- local changeV = self.battle.player:addExp(monsterData.exp)
  1953 + -- self:backDead(enemyId, changeV)
  1954 + self:backDead(enemyId)
  1955 +
  1956 + local isMine = false -- 是不是宝藏怪
  1957 + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do
  1958 + if mid == enemyId then
  1959 + isMine = true
  1960 + break
  1961 + end
1896 1962 end
  1963 + if isMine then
  1964 + local advMine = self.owner:getProperty("advMine")
  1965 + advMine[1] = advMine[1] or {}
  1966 + advMine[2] = advMine[2] or {}
  1967 + local mineCo = advMine[1].co or {}
  1968 + local mineCo2 = advMine[2].co or {}
  1969 + local mineCh = advMine[2].ch or globalCsv.adv_egg_treasureLayer_showup
  1970 + if monsterData.limit ~= 0 then
  1971 + mineCo[enemyId] = (mineCo[enemyId] or 0) + 1
  1972 + end
1897 1973  
1898   - local changItem = enemy:hadBuff(Buff.CHANGE_DROP)
1899   - if changItem then
1900   - changItem = table.pack(changItem:effect())
1901   - end
  1974 + local had = false
  1975 + if math.randomInt(1, 100) <= mineCh then -- 刷出来了
  1976 + local mpool = {}
  1977 + for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do
  1978 + local layer = csvdb["event_buildingCsv"][mid]
  1979 + if (not mineCo2[mid] or layer.limit == 0 or mineCo2[mid] < layer.limit) and layer.showup > 0 then
  1980 + mpool[mid] = {layer.showup}
  1981 + end
  1982 + end
  1983 + if next(mpool) then
  1984 + local cId = math.randWeight(mpool, 1)
  1985 + block:updateEvent({
  1986 + etype = AdvEventType.Build,
  1987 + id = cId
  1988 + })
  1989 + if csvdb["event_buildingCsv"][cId].limit ~= 0 then
  1990 + mineCo2[cId] = (mineCo2[cId] or 0) + 1
  1991 + end
  1992 + had = true
  1993 + end
  1994 + end
  1995 + if had then
  1996 + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureLayer_showup_add, 100)
  1997 + else
  1998 + mineCh = nil
  1999 + end
1902 2000  
1903   - local addMult = 0
1904   - local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数
1905   - if dropBuff then
1906   - local team = enemy:getTeam(1, true)
1907   - addMult = addMult + 0.2 * #team
1908   - end
  2001 + local drops = {}
  2002 + for _, dropId in ipairs(monsterData.dropid:toArray(true, "=")) do
  2003 + local dropData = csvdb["event_dropCsv"][dropId]
  2004 + if dropData then
  2005 + local cur = dropData["range"]:randWeight(true)
  2006 + if cur and cur[1] ~= 0 then
  2007 + drops[#drops + 1] = cur
  2008 + end
  2009 + end
  2010 + end
  2011 + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops)
  2012 + for _i, cblock in ipairs(blocks) do
  2013 + cblock:updateEvent({
  2014 + etype = AdvEventType.Drop,
  2015 + item = drops[_i]
  2016 + })
  2017 + if cblock ~= block then
  2018 + self:backBlockChange(cblock.room.roomId, cblock.blockId)
  2019 + end
  2020 + end
  2021 + advMine[1].co = mineCo
  2022 + advMine[2].co = mineCo2
  2023 + advMine[2].ch = mineCh
  2024 + self.owner:setProperty("advMine", advMine)
  2025 + else
  2026 + local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK)
  2027 + if toClick then
  2028 + toClick = toClick:effect()
  2029 + end
1909 2030  
1910   - local dropIds = monsterData.dropid:toArray(true, "=")
1911   - local drops = {}
1912   - local cCcount = 0 -- 需要改变为click 的个数
1913   - for _, dropId in ipairs(dropIds) do
1914   - local dropData = csvdb["event_dropCsv"][dropId]
1915   - if dropData then
1916   - local cur = dropData["range"]:randWeight(true)
1917   - if cur and cur[1] ~= 0 then
1918   - if toClick then
1919   - cCcount = cCcount + 1
1920   - else
1921   - local item = changItem and changItem or cur
1922   - item[2] = math.floor(item[2] * (1 + addMult))
1923   - drops[#drops + 1] = item
  2031 + local changItem = enemy:hadBuff(Buff.CHANGE_DROP)
  2032 + if changItem then
  2033 + changItem = table.pack(changItem:effect())
  2034 + end
  2035 +
  2036 + local addMult = 0
  2037 + local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数
  2038 + if dropBuff then
  2039 + local team = enemy:getTeam(1, true)
  2040 + addMult = addMult + 0.2 * #team
  2041 + end
  2042 +
  2043 + local dropIds = monsterData.dropid:toArray(true, "=")
  2044 + local drops = {}
  2045 + local cCcount = 0 -- 需要改变为click 的个数
  2046 + for _, dropId in ipairs(dropIds) do
  2047 + local dropData = csvdb["event_dropCsv"][dropId]
  2048 + if dropData then
  2049 + local cur = dropData["range"]:randWeight(true)
  2050 + if cur and cur[1] ~= 0 then
  2051 + if toClick then
  2052 + cCcount = cCcount + 1
  2053 + else
  2054 + local item = changItem and changItem or cur
  2055 + item[2] = math.floor(item[2] * (1 + addMult))
  2056 + drops[#drops + 1] = item
  2057 + end
1924 2058 end
1925 2059 end
1926 2060 end
1927   - end
1928   - -- 这些奖励可能会有被动加成
1929   - self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops})
  2061 + -- 这些奖励可能会有被动加成
  2062 + self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops})
1930 2063  
1931   - -- 自身带的掉落是不会被改变的 也不会被加成
1932   - if block.event.item and block.event.item[1] ~= 0 then
1933   - table.insert(drops, 1, block.event.item)
1934   - end
  2064 + -- 自身带的掉落是不会被改变的 也不会被加成
  2065 + if block.event.item and block.event.item[1] ~= 0 then
  2066 + table.insert(drops, 1, block.event.item)
  2067 + end
1935 2068  
1936   - -- 清空当前的格子
1937   - block:clear()
  2069 + -- 清空当前的格子
  2070 + block:clear()
1938 2071  
1939   - -- 掉落走一波
1940   - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops)
1941   - for _i, cblock in ipairs(blocks) do
1942   - cblock:updateEvent({
1943   - etype = AdvEventType.Drop,
1944   - item = drops[_i]
1945   - })
1946   - if cblock ~= block then
1947   - self:backBlockChange(cblock.room.roomId, cblock.blockId)
  2072 + -- 掉落走一波
  2073 + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops)
  2074 + for _i, cblock in ipairs(blocks) do
  2075 + cblock:updateEvent({
  2076 + etype = AdvEventType.Drop,
  2077 + item = drops[_i]
  2078 + })
  2079 + if cblock ~= block then
  2080 + self:backBlockChange(cblock.room.roomId, cblock.blockId)
  2081 + end
1948 2082 end
1949   - end
1950 2083  
1951   - -- 转换的click走一波
1952   - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount)
1953   - for _i, cblock in ipairs(blocks) do
1954   - cblock:updateEvent({
1955   - etype = AdvEventType.Click,
1956   - id = clickId
1957   - })
1958   - if cblock ~= block then
1959   - self:backBlockChange(cblock.room.roomId, cblock.blockId)
  2084 + -- 转换的click走一波
  2085 + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount)
  2086 + for _i, cblock in ipairs(blocks) do
  2087 + cblock:updateEvent({
  2088 + etype = AdvEventType.Click,
  2089 + id = clickId
  2090 + })
  2091 + if cblock ~= block then
  2092 + self:backBlockChange(cblock.room.roomId, cblock.blockId)
  2093 + end
1960 2094 end
1961 2095 end
1962 2096  
... ... @@ -1989,10 +2123,13 @@ end
1989 2123 function Adv:pushBackEvent(btype, params)
1990 2124 table.insert(self.backEvents, {btype = btype, params = params})
1991 2125 end
1992   -
  2126 +--[=[
  2127 +tag
  2128 +1 自动拾取
  2129 +--]=]
1993 2130 function Adv:backReward(items, params)
1994 2131 params = params or {}
1995   - self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId})
  2132 + self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId, tag = params.tag})
1996 2133 end
1997 2134  
1998 2135 -- if is player enemyId is nil
... ... @@ -2009,8 +2146,8 @@ function Adv:backBlockChange(roomId, blockId, itemChangeType)
2009 2146 self:pushBackEvent(AdvBackEventType.BlockChange, {roomId = roomId, blockId = blockId, itemChangeType = itemChangeType})
2010 2147 end
2011 2148  
2012   -function Adv:backDead(enemyId, exp)
2013   - self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId, exp = exp})
  2149 +function Adv:backDead(enemyId)
  2150 + self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId})
2014 2151 end
2015 2152  
2016 2153 function Adv:backTrap()
... ... @@ -2033,8 +2170,12 @@ function Adv:backCost(items)
2033 2170 self:pushBackEvent(AdvBackEventType.Cost, {items = items})
2034 2171 end
2035 2172  
2036   -function Adv:backUse(items)
2037   - self:pushBackEvent(AdvBackEventType.Use, {items = items})
  2173 +--[=[
  2174 +tag
  2175 +1 自动使用
  2176 +--]=]
  2177 +function Adv:backUse(items, tag)
  2178 + self:pushBackEvent(AdvBackEventType.Use, {items = items, tag = tag})
2038 2179 end
2039 2180  
2040 2181  
... ... @@ -2044,21 +2185,11 @@ function Adv:scoreChange(scoreType, score)
2044 2185 end
2045 2186  
2046 2187 function Adv:getScore()
2047   - self.score[AdvScoreType.Level] = math.floor(self.score[AdvScoreType.Level] or 0)
2048   - self.score[AdvScoreType.Task] = math.floor(self.score[AdvScoreType.Task] or 0)
2049   - self.score[AdvScoreType.Kill] = math.floor(self.score[AdvScoreType.Kill] or 0)
2050   - self.score[AdvScoreType.KillBoss] = math.floor(self.score[AdvScoreType.KillBoss] or 0)
2051   - self.score[AdvScoreType.ItemBack] = math.floor(self.score[AdvScoreType.ItemBack] or 0)
2052   - self.score[AdvScoreType.Event] = math.floor(self.score[AdvScoreType.Event] or 0)
2053   - self.score[AdvScoreType.Story] = math.floor(self.score[AdvScoreType.Story] or 0)
2054   -
2055   - return self.score[AdvScoreType.Level]
2056   - + self.score[AdvScoreType.Task]
2057   - + self.score[AdvScoreType.Kill]
2058   - + self.score[AdvScoreType.KillBoss]
2059   - + self.score[AdvScoreType.ItemBack]
2060   - + self.score[AdvScoreType.Event]
2061   - + self.score[AdvScoreType.Story]
  2188 + local allScore = 0
  2189 + for _, score in pairs(self.score) do
  2190 + allScore = allScore + math.floor(score)
  2191 + end
  2192 + return allScore
2062 2193 end
2063 2194  
2064 2195 function Adv:popBackEvents()
... ...
src/adv/AdvBattle.lua
... ... @@ -8,6 +8,7 @@ function Battle:ctor(adv)
8 8 self.isNewPlayer = false
9 9 self.enemys = {} --怪
10 10 self.builds = {} -- 建筑
  11 + self.auras = {} -- 光环
11 12 self.cachePassiveEvent = {}
12 13 self:initPlayer()
13 14 self:initEnemys()
... ... @@ -67,17 +68,17 @@ function Battle:initPlayer()
67 68 local advAddAttrs = self.adv.owner:getAdvLvAddAttrs()
68 69  
69 70 player = {}
70   - player.level = 1
71   - if self.adv.level ~= 1 then
72   - local relayData = self.adv:isHaveRelay()
73   - if relayData then
74   - player.level = relayData.level
75   - end
76   - end
77   - player.exp = 0
  71 + -- player.level = 1
  72 + -- if self.adv.level ~= 1 then
  73 + -- local relayData = self.adv:isHaveRelay()
  74 + -- if relayData then
  75 + -- player.level = relayData.level
  76 + -- end
  77 + -- end
  78 + -- player.exp = 0
78 79 player.sp = getAdvLvAttrUp(advAddAttrs, "sp", 100)
79 80 player.spMax = player.sp
80   - player.growth = {}
  81 + -- player.growth = {}
81 82 player.passives = {}
82 83  
83 84 for slot, heroId in pairs(advTeam.heros) do
... ... @@ -100,8 +101,8 @@ function Battle:initPlayer()
100 101 player[attrName] = (player[attrName] or 0) + hero[attrName]
101 102 end
102 103 player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName]) * (globalCsv.adv_battle_attr_ratio[attrName] or 1)
103   - player.growth[attrName] = player[attrName] * (globalCsv.adv_battle_attr_growth_ratio[attrName] or 1)
104   - player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1)
  104 + -- player.growth[attrName] = player[attrName] * (globalCsv.adv_battle_attr_growth_ratio[attrName] or 1)
  105 + -- player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1)
105 106 end
106 107  
107 108 player.hpMax = player.hp or 0
... ... @@ -198,8 +199,10 @@ function Battle:addEnemy(room, block, mapIdx, init)
198 199 end
199 200  
200 201 for _, buff in ipairs(buffs) do
201   - enemy:addBuff(buff)
  202 + player:addBuff(buff)
202 203 end
  204 + -- 新生成的怪 加上 已有的光环buff
  205 + player:checkAuraBuff(self:checkDiffAuraBuff({}, self:getAurasByMap()))
203 206 end
204 207 end
205 208 return player
... ... @@ -313,8 +316,19 @@ function Battle:afterRound()
313 316 build:afterRound("buffAfter")
314 317 end
315 318  
  319 + self.player:triggerPassive(Passive.AFTER_ROUND)
  320 +
  321 + self:checkAura()
316 322  
  323 + self:clearRound()
  324 +
  325 + if self.player.isDead then
  326 + self.adv:over(false, nil, -2)
  327 + end
  328 +end
317 329  
  330 +function Battle:clearRound()
  331 + local mapIdx = self.adv:getCurMapIdx()
318 332 self.player:clearRound()
319 333 for _, enemy in ipairs(self.enemys[mapIdx]) do
320 334 enemy:clearRound()
... ... @@ -344,12 +358,6 @@ function Battle:afterRound()
344 358 build:clear()
345 359 end
346 360 end
347   -
348   - self.player:triggerPassive(Passive.AFTER_ROUND)
349   -
350   - if self.player.isDead then
351   - self.adv:over(false, nil, -2)
352   - end
353 361 end
354 362  
355 363  
... ... @@ -358,18 +366,32 @@ function Battle:battleBegin(roomId, blockId, params)
358 366 if not enemy then return end
359 367 local player = params.player
360 368 if not player then return end
  369 + local penemy = params.enemy or {hp = 0}
  370 + if player.hp ~= 0 then
  371 + if penemy.hp <= 0 then
  372 + enemy:kill()
  373 + self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId})
  374 + else
  375 + -- 处理一下怪物
  376 + if penemy.hp > enemy.hp then
  377 + enemy:recover(penemy.hp - enemy.hp)
  378 + else
  379 + enemy:hurt(math.max(0, math.ceil(enemy.hp - penemy.hp)), self.player, {hurtType = 5}) --战斗血量只会变少
  380 + end
  381 + if penemy.escape and penemy.escape == 0 then
  382 + enemy.isDead = 1
  383 + end
  384 + end
  385 + end
361 386 -- 玩家没死就是怪死了
362 387 if player.hp > 0 then
363   - enemy:kill()
364 388 self.player:effectBattleBuff()
365   -
366   - self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId})
367 389 if params.bySkill then
368 390 self.player:triggerPassive(Passive.SKILL_KILL)
369 391 end
370 392 end
371 393 if player.hp > self.player.hp then
372   - self.player:recover(player.hp - self.player.hp, player)
  394 + self.player:recover(player.hp - self.player.hp)
373 395 else
374 396 self.player:hurt(math.max(0, math.ceil(self.player.hp - player.hp)), enemy, {hurtType = 5}) --战斗血量只会变少
375 397 end
... ... @@ -424,7 +446,7 @@ function Battle:initMapEffect(ilayer)
424 446 end
425 447  
426 448 for _, buff in ipairs(buffs[1] or {}) do
427   - self.palyer:addBuff(buff)
  449 + self.player:addBuff(buff)
428 450 end
429 451  
430 452 for _, buff in ipairs(buffs[2] or {}) do
... ... @@ -435,8 +457,126 @@ function Battle:initMapEffect(ilayer)
435 457 end
436 458  
437 459  
  460 +-- 夹层 进入退出 接口 清理玩家身上的老光环 添加新的光环
  461 +function Battle:iLayerChange(oldMapIdx)
  462 + local auras = self:getActiveAuras()
  463 + local playerBuffs = self:checkDiffAuraBuff(self:getAurasByMap(oldMapIdx), auras)
  464 + local enemyBuffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras)
  465 + self.player:checkAuraBuff(playerBuffs)
  466 + for _, enemy in pairs(self.player:getTeam(2)) do
  467 + enemy:checkAuraBuff(enemyBuffs)
  468 + end
  469 + self:setMapAuras(auras)
  470 + self:clearRound()
  471 +end
  472 +
  473 +-- 新的 关卡 关闭旧的战斗模块 清理 玩家身上的光环效果
  474 +function Battle:overBattle()
  475 + local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), {})
  476 + self.player:checkAuraBuff(buffs)
  477 + self:clearRound()
  478 + self.adv.owner:getProperty("advTeam").player = self.player:getDB() -- 临时缓存住 battle 的player
  479 +end
  480 +
  481 +-- 初始化 新的 关卡
  482 +function Battle:newBattle()
  483 + local auras = self:getActiveAuras()
  484 + local buffs = self:checkDiffAuraBuff({}, auras)
  485 + self.player:checkAuraBuff(buffs)
  486 + for _, enemy in pairs(self.player:getTeam(2)) do
  487 + enemy:checkAuraBuff(buffs)
  488 + end
  489 + self:setMapAuras(auras)
  490 +end
  491 +
  492 +function Battle:loadBattle(info)
  493 + self.auras = info.auras or {}
  494 +end
  495 +
  496 +-- 过了回合 检查光环
  497 +function Battle:checkAura()
  498 + local auras = self:getActiveAuras()
  499 + local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras)
  500 + self.player:checkAuraBuff(buffs)
  501 + for _, enemy in pairs(self.player:getTeam(2)) do
  502 + enemy:checkAuraBuff(buffs)
  503 + end
  504 + self:setMapAuras(auras)
  505 +end
  506 +
  507 +-- 查找差异buff
  508 +function Battle:checkDiffAuraBuff(oldAuras, newAuras)
  509 + local auras = {}
  510 + for aurasId , count in pairs(oldAuras) do
  511 + auras[aurasId] = -count
  512 + end
  513 + for aurasId , count in pairs(newAuras) do
  514 + auras[aurasId] = (auras[aurasId] or 0) + count
  515 + end
  516 +
  517 + local buffs = {}
  518 + for aurasId , count in pairs(auras) do
  519 + local auraData = csvdb["adv_map_haloCsv"][aurasId]
  520 + if auraData then
  521 + for _, effect in ipairs(auraData.effect:toTableArray(true)) do
  522 + temp = buffs
  523 + for i = 1, #effect do
  524 + temp[effect[i]] = temp[effect[i]] or {}
  525 + temp = temp[effect[i]]
  526 + end
  527 + temp.count = (temp.count or 0) + count
  528 + if newAuras[aurasId] then
  529 + -- 加上 未消失标记
  530 + temp.exist = true
  531 + end
  532 + end
  533 + end
  534 + end
  535 + return buffs
  536 +end
  537 +
  538 +-- 获取所有生效的 光环
  539 +function Battle:getActiveAuras()
  540 + local auras = {}
  541 + for _, one in pairs(self.player:getAuras()) do
  542 + auras[one] = (auras[one] or 0) + 1
  543 + end
  544 + for _, enemy in pairs(self.player:getTeam(2)) do
  545 + for _, one in pairs(enemy:getAuras()) do
  546 + auras[one] = (auras[one] or 0) + 1
  547 + end
  548 + end
  549 + for _, build in pairs(self:getBuilds()) do
  550 + for _, one in pairs(build:getAuras()) do
  551 + auras[one] = (auras[one] or 0) + 1
  552 + end
  553 + end
  554 + return auras
  555 +end
  556 +
  557 +function Battle:setMapAuras(auras)
  558 + self.auras[self.adv:getCurMapIdx()] = auras
  559 +end
  560 +
  561 +function Battle:getAurasByMap(mapIdx)
  562 + mapIdx = mapIdx or self.adv:getCurMapIdx()
  563 + local auras = self.auras[mapIdx] or {}
  564 + return auras
  565 +end
  566 +
  567 +function Battle:getBuilds()
  568 + local team = {}
  569 + for _, build in pairs(self.builds[self.adv:getCurMapIdx()]) do
  570 + if not build.isDead and not build.lock then -- 已经翻开的
  571 + table.insert(team, build)
  572 + end
  573 + end
  574 + return team
  575 +end
  576 +
  577 +
438 578 --写入数据
439   -function Battle:saveDB()
  579 +function Battle:saveDB(advInfo)
440 580 for idx, mapEnemys in pairs(self.enemys) do
441 581 for _, enemy in ipairs(mapEnemys) do
442 582 local block = self.adv:getBlock(enemy.roomId, enemy.blockId, idx)
... ... @@ -453,6 +593,7 @@ function Battle:saveDB()
453 593 end
454 594 end
455 595 end
  596 + advInfo.auras = self.auras
456 597 end
457 598  
458 599 return Battle
459 600 \ No newline at end of file
... ...
src/adv/AdvBlock.lua
... ... @@ -48,6 +48,8 @@ function Block:updateEvent(event, isInit)
48 48 end
49 49 end
50 50 end
  51 + local oldet = self:getEventType()
  52 +
51 53 self.event = event
52 54 if not isInit and self.event then
53 55 -- 判断下类型是不是错的
... ... @@ -58,18 +60,49 @@ function Block:updateEvent(event, isInit)
58 60 end
59 61 self:randomEvent()
60 62 end
  63 + self:quickDrop()
  64 +
  65 + if not isInit and self.isOpen then
  66 + local newet = self:getEventType()
  67 + if oldet ~= newet then
  68 + local em = {}
  69 + if oldet then
  70 + em[oldet] =1
  71 + end
  72 + if newet then
  73 + em[newet] =1
  74 + end
  75 +
  76 + local player = self.room.map.adv.battle.player
  77 + player:attrChangeCondBuffCheck(4, em)
  78 + for _, monster in pairs(player:getTeam(2)) do
  79 + monster:attrChangeCondBuffCheck(4, em)
  80 + end
  81 + end
  82 + end
61 83 end
62 84  
63 85 function Block:clear()
64   - if self:getEventType() == AdvEventType.Trap then
  86 + local et = self:getEventType()
  87 + if et == AdvEventType.Trap then
65 88 self.trapId = self.event.id
66   - elseif self:getEventType() == AdvEventType.Build then
  89 + elseif et == AdvEventType.Build then
67 90 local build = self.room.map.adv.battle:getBuild(self.room.roomId, self.blockId, self.room.map.mapIdx)
68 91 if build then
69 92 build.isDead = true
70 93 end
71 94 end
72 95 self.event = nil
  96 +
  97 +
  98 + if et then
  99 + local em = {[et] = 1}
  100 + local player = self.room.map.adv.battle.player
  101 + player:attrChangeCondBuffCheck(4, em)
  102 + for _, monster in pairs(player:getTeam(2)) do
  103 + monster:attrChangeCondBuffCheck(4, em)
  104 + end
  105 + end
73 106 end
74 107  
75 108  
... ... @@ -90,8 +123,10 @@ function Block:randomEvent()
90 123 enemy:triggerPassive(Passive.BORN_ONCE)
91 124  
92 125 adv.battle.player:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy})
  126 + adv.battle.player:attrChangeCondBuffCheck(3, enemy:getClassify())
93 127 for _, monster in pairs(adv.battle.player:getTeam(2)) do
94   - adv.battle.player:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy})
  128 + monster:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy})
  129 + monster:attrChangeCondBuffCheck(3, enemy:getClassify())
95 130 end
96 131 end
97 132 randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster]
... ... @@ -208,6 +243,13 @@ function Block:randomEvent()
208 243 e:addBuff(buffId)
209 244 end
210 245 end
  246 + elseif data.target == 4 then
  247 + local enemys = self.room.map.adv:getCurMap():openBlocksIsMonsterByRoom(self.room.roomId)
  248 + for _, e in ipairs(enemys) do
  249 + for _, buffId in ipairs(buffs) do
  250 + e:addBuff(buffId)
  251 + end
  252 + end
211 253 end
212 254  
213 255 if data.specialEff ~= "" then
... ... @@ -263,10 +305,37 @@ function Block:open()
263 305 local adv = map.adv
264 306 self.isOpen = true
265 307 self:randomEvent()
  308 + self:quickDrop()
  309 +
  310 + local et = self:getEventType()
  311 + if et then
  312 + local em = {[et] = 1}
  313 + local player = self.room.map.adv.battle.player
  314 + player:attrChangeCondBuffCheck(4, em)
  315 + for _, monster in pairs(player:getTeam(2)) do
  316 + monster:attrChangeCondBuffCheck(4, em)
  317 + end
  318 + end
266 319 return true
267 320 end
268 321  
  322 +function Block:quickDrop()
  323 + if self:getEventType() == AdvEventType.Drop and self.event.item then
  324 + local itemId, count = table.unpack(self.event.item)
  325 + if globalCsv.adv_auto_collect[itemId] then
  326 + self.room.map.adv:award({[itemId] = count}, {log = {desc = "clickDrop"}}, {roomId = self.room.roomId, blockId = self.blockId, tag = 1})
  327 + self:clear()
  328 + end
  329 + end
  330 +end
  331 +
269 332 function Block:getObstacle()
  333 + if self:isMonster() then
  334 + local enemy = self.room.map.adv.battle:getEnemy(self.room.roomId, self.blockId)
  335 + if enemy then
  336 + return enemy:getObstacle()
  337 + end
  338 + end
270 339 local data = self:getEventData()
271 340 if not data then return 0 end
272 341 return data.obstacle or 0
... ...
src/adv/AdvBuff.lua
... ... @@ -20,7 +20,7 @@ Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效)
20 20 Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff
21 21 Buff.CHANGE_DROP = 18 -- 转换掉落
22 22 Buff.BATTLE_PASSIVE = 19 -- 切换为战斗中的被动技
23   -Buff.EXP_ADD = 20 -- 增加exp(每回合)
  23 +-- Buff.EXP_ADD = 20 -- 增加exp(每回合)
24 24 Buff.DONT_DEFEND = 21 -- 不看守地板 -- 怪周围点半可点击
25 25 Buff.SHOW_DANGER = 22 -- 扫雷 展示地上怪物和陷阱数量的标记
26 26 Buff.SHOW_MONSTER_POS = 23 -- 蓝臂章训练场 感知
... ... @@ -34,6 +34,10 @@ Buff.Buff_EFFECT_CHANGE = 30 -- 改变 buff 效果
34 34 Buff.Buff_NO_PASSIVE_MONSTER = 31 -- 地图被动刷新不出来怪物
35 35 Buff.SNEAK = 32 --潜行
36 36 Buff.DROP_BUFF_BY_ENEMY = 33 -- 怪物掉落加成 -- 怪物使用
  37 +Buff.GET_PASSIVE = 34 -- 获得 passive -- 结束失效
  38 +Buff.OBSTACLE_CHANGE = 35 -- 看守类型改变 -- 怪物使用 0 - 1
  39 +Buff.DISABLE_AURA = 36 -- 禁用光环
  40 +Buff.GET_AURA = 37 -- 获得光环
37 41  
38 42  
39 43 --角色一些属性的变化
... ... @@ -87,13 +91,24 @@ local function commonAttCond(_Buff, attrName)
87 91 if buff then
88 92 effectCount = buff.layer
89 93 end
  94 + elseif self.buffData.effectValue4 == 3 then
  95 + local classify = tonumber(self.buffData.effectValue5) -- 怪标签
  96 + local enemy = self.owner.battle.player:getTeam(2)
  97 + for _, one in pairs(enemy) do
  98 + if one.isClassify and one:isClassify(classify) then
  99 + effectCount = effectCount + 1
  100 + end
  101 + end
  102 + elseif self.buffData.effectValue4 == 4 then
  103 + local eventType = tonumber(self.buffData.effectValue5) -- event 类型
  104 + effectCount = #self.owner.battle.adv:getCurMap():getEventTypeAllMap(eventType)
90 105 end
91 106 return self.buffData.effectValue2 * effectCount
92 107 end
93 108  
94 109 _Buff.getEffectBy = function(self)
95 110 local cond = nil
96   - if self.buffData.effectValue4 == 2 then
  111 + if self.buffData.effectValue4 == 2 or self.buffData.effectValue4 == 3 or self.buffData.effectValue4 == 4 then
97 112 cond = tonumber(self.buffData.effectValue5)
98 113 end
99 114 return self.buffData.effectValue4, attrName, cond
... ... @@ -302,18 +317,30 @@ local BuffFactory = {
302 317 end
303 318 end,
304 319  
305   - [Buff.EXP_ADD] = function(_Buff)
306   - _Buff._afterRound = function(self)
307   - local value = self:effect()
308   - self.owner.battle.player:addExp(value)
  320 + -- [Buff.EXP_ADD] = function(_Buff)
  321 + -- _Buff._afterRound = function(self)
  322 + -- local value = self:effect()
  323 + -- self.owner.battle.player:addExp(value)
  324 + -- end
  325 + -- _Buff._effectValue = function(self)
  326 + -- -- 经验值
  327 + -- return self.buffData.effectValue1 * self.layer
  328 + -- end
  329 + -- end,
  330 +
  331 + [Buff.DISABLE_BUFF] = function(_Buff)
  332 + _Buff._effectValue = function(self)
  333 + return self.buffData.effectValue1
309 334 end
  335 + end,
  336 +
  337 + [Buff.DISABLE_AURA] = function(_Buff)
310 338 _Buff._effectValue = function(self)
311   - -- 经验值
312   - return self.buffData.effectValue1 * self.layer
  339 + return self.buffData.effectValue1
313 340 end
314 341 end,
315 342  
316   - [Buff.DISABLE_BUFF] = function(_Buff)
  343 + [Buff.GET_AURA] = function(_Buff)
317 344 _Buff._effectValue = function(self)
318 345 return self.buffData.effectValue1
319 346 end
... ... @@ -378,6 +405,14 @@ local BuffFactory = {
378 405 self.layer = self.buffData.effectValue1
379 406 end
380 407 end,
  408 + [Buff.GET_PASSIVE] = function( _Buff )
  409 + _Buff._init = function(self)
  410 + self.owner:addPassive({id = self.buffData.effectValue1})
  411 + end
  412 + _Buff._endBuff = function(self)
  413 + self.owner:delPassiveById(self.buffData.effectValue1)
  414 + end
  415 + end
381 416 }
382 417  
383 418 -- 同样的返回 effectValue1, effectValue2 * self.layer 类型的buff
... ... @@ -439,7 +474,18 @@ function Buff:initNew(release, data)
439 474 end
440 475 end
441 476  
442   -function Buff:createAfter()
  477 +function Buff:createAfter(layer)
  478 + layer = layer or 1
  479 + local otype, maxLayer = self:getOverlay()
  480 + if otype then
  481 + self.layer = layer
  482 + if maxLayer ~= 0 then
  483 + self.layer = math.min(maxLayer, self.layer)
  484 + end
  485 + else
  486 + self.layer = 1
  487 + end
  488 +
443 489 if self._init then
444 490 self:_init()
445 491 end
... ... @@ -626,12 +672,13 @@ function Buff:getOverlay()
626 672 end
627 673  
628 674 -- 叠加
629   -function Buff:overlay(releaser, data)
  675 +function Buff:overlay(releaser, data, layer)
630 676 local otype, maxLayer = self:getOverlay()
631 677 if self.isDel or not otype then -- 新获得的 (不可叠加相当于新获得的)
632   - self.isDel = false
633 678 self:endBuff()
  679 + self.isDel = false
634 680 self:initNew(releaser, data)
  681 + self:createAfter(layer)
635 682 else
636 683 -- 重置回合 次数
637 684 self.roundSpace = 0
... ... @@ -644,7 +691,7 @@ function Buff:overlay(releaser, data)
644 691  
645 692 self.release = releaser or self.release
646 693 -- 叠加层数
647   - self.layer = self.layer + 1
  694 + self.layer = self.layer + layer
648 695 if maxLayer ~= 0 then
649 696 self.layer = math.min(maxLayer, self.layer)
650 697 end
... ... @@ -655,14 +702,32 @@ function Buff:overlay(releaser, data)
655 702 end
656 703  
657 704 -- 扣减层数
658   -function Buff:uncover()
659   - if self.layer <= 1 then
  705 +function Buff:uncover(layer, isAura)
  706 + layer = layer or 1
  707 + local oldLayer = self.layer
  708 +
  709 + self.layer = self.layer - layer
  710 +
  711 + if self.layer <= 0 then
660 712 self.isDel = true
661 713 end
662 714  
663   - self.layer = self.layer - 1
664   - if self._uncover then
665   - self:_uncover()
  715 + if isAura then
  716 + if layer == -1 then
  717 + self.layer = 0
  718 + self.isDel = true
  719 + else
  720 + self.layer = math.max(1, self.layer)
  721 + self.isDel = false
  722 + end
  723 + end
  724 +
  725 + if self.isDel then return end
  726 +
  727 + if oldLayer ~= self.layer then
  728 + if self._uncover then
  729 + self:_uncover()
  730 + end
666 731 end
667 732 end
668 733  
... ...
src/adv/AdvMap.lua
... ... @@ -256,7 +256,7 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack)
256 256  
257 257 if status then
258 258 if isPlayer then
259   - self.adv.battle:triggerPassive(Passive.OPEN_BLOCK)
  259 + self.adv.battle:triggerPassive(Passive.OPEN_BLOCK, {roomId = roomId, blockId = blockId})
260 260 self.adv.owner:checkTaskEnter("AdvOpenBlock")
261 261  
262 262 -- 潜行检查
... ... @@ -272,8 +272,8 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack)
272 272 if not ignoreBack then
273 273 self.adv:backBlockChange(roomId, blockId)
274 274 end
275   -
276 275 end
  276 + return status
277 277 end
278 278  
279 279 function Map:openBlocksBySize(roomId, blockId, size, isPlayer, ignoreBack)
... ... @@ -292,6 +292,41 @@ function Map:openBlocksByRoom(roomId, isPlayer, ignoreBack)
292 292 end
293 293 end
294 294  
  295 +function Map:openBlocksIsMonsterByRoom(roomId, count, isPlayer, ignoreBack)
  296 + local room = self.rooms[roomId]
  297 + if not room then return end
  298 +
  299 + local allBlock = {}
  300 + for blockId, block in pairs(room.blocks) do
  301 + if block:isMonster() and not block.isOpen then
  302 + table.insert(allBlock, blockId)
  303 + end
  304 + end
  305 +
  306 + local enemys = {}
  307 + local openBlock = function(blockId)
  308 + if self:openBlock(roomId, blockId, isPlayer, ignoreBack) then
  309 + local e = self.adv.battle:getEnemy(roomId, blockId)
  310 + if e then
  311 + table.insert(enemys, e)
  312 + end
  313 + end
  314 + end
  315 +
  316 + if not count or count == -1 or count >= #allBlock then
  317 + for _, blockId in ipairs(allBlock) do
  318 + openBlock(blockId)
  319 + end
  320 + else
  321 + for i = 1, count do
  322 + local idx = math.randomInt(1, #allBlock)
  323 + openBlock(allBlock[idx])
  324 + table.remove(allBlock, idx)
  325 + end
  326 + end
  327 + return enemys
  328 +end
  329 +
295 330 function Map:openAllBlocks(isPlayer, ignoreBack)
296 331 for roomId, room in pairs(self.rooms) do
297 332 self:openBlocksByRoom(room.roomId, isPlayer, ignoreBack)
... ... @@ -309,6 +344,22 @@ function Map:getRBByPos(c, r)
309 344 end
310 345 end
311 346  
  347 +function Map:getDistance(froomId, fblockId, troomId, tblockId)
  348 + local distance = -1
  349 + local room1 = self.rooms[froomId]
  350 + local room2 = self.rooms[troomId]
  351 + if room1 and room2 then
  352 + local block1 = room1[fblockId]
  353 + local block2 = room2[tblockId]
  354 + if block1 and block2 then
  355 + local c1, r1 = room1:tranLtoG(block1.col, block1.row)
  356 + local c2, r2 = room2:tranLtoG(block2.col, block2.row)
  357 + distance = math.max(math.abs(c1 - c2), math.abs(r1 - r2))
  358 + end
  359 + end
  360 + return distance
  361 +end
  362 +
312 363 function Map:getAroundBlocks(room, block)
313 364 local blocks = {}
314 365 local range = {1, -1}
... ... @@ -412,6 +463,18 @@ function Map:getEnemysBySize(roomId, blockId, size)
412 463 return enemys
413 464 end
414 465  
  466 +function Map:getEventTypeAllMap(eventType)
  467 + local blocks = {}
  468 + if not eventType then return blocks end
  469 + for roomId, room in pairs(self.rooms) do
  470 + for blockId, block in pairs(room.blocks) do
  471 + if block.isOpen and block:getEventType() == eventType then
  472 + table.insert(blocks, block)
  473 + end
  474 + end
  475 + end
  476 + return blocks
  477 +end
415 478 -----------------------------随机地图-----------------------------
416 479  
417 480 -- isEnter isNewRelay 区分中继层的类型 --是否是开始进入 是否是第一次进入
... ... @@ -749,6 +812,47 @@ createMap = function(self, mapId, isEnter, isNewRelay)
749 812 end
750 813 end
751 814  
  815 + -- 宝藏怪刷新
  816 + for idx = #(stagePool["global"][AdvCodeRandomStage] or {}), 1, -1 do
  817 + local c = stagePool["global"][AdvCodeRandomStage][idx] -- {room = roomId, block = blockId}
  818 + if mapInfo.rooms[c["room"]]["event"][c["block"]] then -- 存在
  819 + table.remove(stagePool["global"][AdvCodeRandomStage], idx)
  820 + end
  821 + end
  822 + local ln = #(stagePool["global"][AdvCodeRandomStage] or {})
  823 + local advMine = self.adv.owner:getProperty("advMine")
  824 + advMine[1] = advMine[1] or {}
  825 + local mineCh = advMine[1].ch or globalCsv.adv_egg_treasureMonster_showup
  826 + local mineCo = advMine[1].co or {}
  827 + local had = false
  828 + if ln > 0 then
  829 + if math.randomInt(1, 100) <= mineCh then -- 刷出来了
  830 + local mpool = {}
  831 + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do
  832 + local monster = csvdb["event_monsterCsv"][mid]
  833 + if (not mineCo[mid] or monster.limit == 0 or mineCo[mid] < monster.limit) and monster.showup > 0 then
  834 + mpool[mid] = {monster.showup}
  835 + end
  836 + end
  837 + if next(mpool) then
  838 + local idx = math.randomInt(1, ln)
  839 + local cur = stagePool["global"][AdvCodeRandomStage][idx]
  840 + giveEvent(cur["room"], cur["block"], AdvEventType.Monster, math.randWeight(mpool, 1))
  841 + table.remove(stagePool["global"][AdvCodeRandomStage], idx)
  842 + ln = ln - 1
  843 + had = true
  844 + end
  845 + end
  846 + end
  847 + if not had then
  848 + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureMonster_showup_add, 100)
  849 + else
  850 + mineCh = nil
  851 + end
  852 + advMine[1].ch = mineCh
  853 + self.adv.owner:setProperty("advMine", advMine)
  854 +
  855 +
752 856 if mapCsvData.clearType == 1 and not haveBoss then
753 857 if not next(monsterEvents) then
754 858 error("这个地图没有钥匙!!! mapId : " .. mapId)
... ...
src/adv/AdvPassive.lua
... ... @@ -7,6 +7,8 @@ Filter.HP_LOW = 4 -- 血量&lt;value%
7 7 Filter.BUFF_BY_TYPE = 5 -- 指定类型buff
8 8 Filter.BUFF_BY_ID = 6 -- 指定id的buff
9 9 Filter.CAMP = 7 -- 玩家是指定阵营
  10 +Filter.RANGE = 8 -- 筛选范围 (触发是地块)
  11 +Filter.CLASSIFY = 9 -- 标签
10 12  
11 13 local FilterFactory = {}
12 14 FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter)
... ... @@ -46,6 +48,21 @@ FilterFactory[Filter.CAMP] = function (_Filter)
46 48 end
47 49 end
48 50  
  51 +FilterFactory[Filter.RANGE] = function (_Filter)
  52 + _Filter._execute = function (self, target, params)
  53 + if self.owner.blockId and self.owner.roomId and params.blockId and params.roomId then
  54 + local distance = self.owner.battle.adv:getCurMap():getDistance(self.owner.roomId, self.owner.blockId, params.roomId, params.blockId)
  55 + return distance ~= -1 and distance <= self.value
  56 + end
  57 + return false
  58 + end
  59 +end
  60 +
  61 +FilterFactory[Filter.CLASSIFY] = function (_Filter)
  62 + _Filter._execute = function (self, target)
  63 + return target.isClassify and target:isClassify(self.value)
  64 + end
  65 +end
49 66  
50 67 function Filter:ctor(params)
51 68 self.owner = params.owner
... ... @@ -79,7 +96,7 @@ function Filter:execute(params)
79 96 return
80 97 end
81 98 if self:_execute(target) then
82   - return self:_execute(target)
  99 + return self:_execute(target, params)
83 100 end
84 101 end
85 102  
... ... @@ -120,6 +137,7 @@ Passive.GET_BUFF = 28 --获得指定buff
120 137 Passive.OPEN_BLOCK = 29 --翻开格子
121 138 Passive.OPEN_MONSTER = 30 --翻开怪物
122 139 Passive.PLAYER_BUFF = 31 --玩家获得buff
  140 +
123 141 Passive.PLAYER_BUFF_CLASSIFY = 35 -- 获得指定标签的buff
124 142  
125 143 -- 不同的开启条件
... ... @@ -442,6 +460,7 @@ end
442 460  
443 461 --3=翻开自己所在格子
444 462 function Passive:effect3(value)
  463 + if not self.owner.roomId or not self.owner.blockId then return end
445 464 if value == 0 then
446 465 self.owner.battle.adv:getCurMap():openBlock(self.owner.roomId, self.owner.blockId)
447 466 elseif value > 0 then
... ... @@ -494,7 +513,7 @@ function Passive:effect8(dropId)
494 513 skynet.error(string.format("CSVDATA Error adv_map_passive %s effect 8 not id %s in event_drop", self.id, dropId))
495 514 end
496 515 local item = dropData["range"]:randWeight(true)
497   - self.owner.battle.adv:backReward(self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}), {roomId = self.owner.roomId, blockId = self.owner.blockId})
  516 + self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId})
498 517  
499 518 end
500 519  
... ... @@ -509,7 +528,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max)
509 528 return
510 529 end
511 530 if not cond then return end
512   - self.owner.battle.adv:backReward(self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}), {roomId = self.owner.roomId, blockId = self.owner.blockId})
  531 + self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId})
513 532 end
514 533  
515 534 --10=战斗额外掉落次数
... ... @@ -561,5 +580,22 @@ function Passive:effect14(value, triggerPms, enemyId)
561 580 end
562 581 end
563 582  
  583 +--15=翻开房间内的count 个怪 并且增加一个buff
  584 +function Passive:effect15(count, triggerPms, buffId)
  585 + local roomId = self.owner.roomId
  586 + if not roomId then return end
  587 + local enemys = self.owner.battle.adv:getCurMap():openBlocksIsMonsterByRoom(roomId, count)
  588 + for _, e in ipairs(enemys) do
  589 + e:addBuff(buffId)
  590 + end
  591 +end
  592 +
  593 +--16=转变 value 范围内的掉落物 为 id count
  594 +function Passive:effect16(value, triggerPms, changeType)
  595 + if not self.owner.roomId or not self.owner.blockId then return end
  596 + local blocks = self.owner.battle.adv:getCurMap():getBlocksBySize(self.owner.roomId, self.owner.blockId, value)
  597 + self.owner.battle.adv:blockDropChange(changeType, blocks)
  598 +end
  599 +
564 600  
565 601 return Passive
566 602 \ No newline at end of file
... ...
src/adv/AdvPlayer.lua
... ... @@ -90,6 +90,12 @@ end
90 90 function BaseObject:clear()
91 91 self.buffs = {}
92 92 self.passives = {}
  93 + if self:is("Enemy") then
  94 + self.battle.player:attrChangeCondBuffCheck(3, self:getClassify())
  95 + for _, monster in pairs(self.battle.player:getTeam(2)) do
  96 + monster:attrChangeCondBuffCheck(3, self:getClassify())
  97 + end
  98 + end
93 99 end
94 100  
95 101 function BaseObject:addPassive(params)
... ... @@ -137,7 +143,21 @@ function BaseObject:getDisablePassiveCount()
137 143 return count
138 144 end
139 145  
140   -function BaseObject:addBuff(buffId, releaser)
  146 +function BaseObject:getDisableAuraCount()
  147 + local count = 0
  148 + for _, buff in ipairs(self.buffs) do
  149 + if not buff:isHide() and buff:getType() == Buff.DISABLE_AURA then
  150 + if buff:effect() == 0 then
  151 + return 0
  152 + end
  153 + count = (count or 0) + buff:effect()
  154 + end
  155 + end
  156 + return count
  157 +end
  158 +
  159 +function BaseObject:addBuff(buffId, releaser, layer)
  160 + layer = layer or 1
141 161 local buffData = csvdb["adv_map_buffCsv"][buffId]
142 162 if not buffData then return end
143 163 for _, buff in ipairs(self.buffs) do
... ... @@ -151,7 +171,7 @@ function BaseObject:addBuff(buffId, releaser)
151 171 local oldBuff = self:getBuffById(buffId)
152 172 if oldBuff then
153 173 if not oldBuff:checkKeep() then return end
154   - oldBuff:overlay(releaser, {}) -- 叠加
  174 + oldBuff:overlay(releaser, {}, layer) -- 叠加
155 175 else
156 176 -- 不能保持的buff 也加不上去
157 177 if not Buff.checkKeep({
... ... @@ -161,10 +181,11 @@ function BaseObject:addBuff(buffId, releaser)
161 181 }) then return end
162 182 local buff = Buff.create(self, releaser, {id = buffId})
163 183 table.insert(self.buffs, buff)
164   - buff:createAfter()
  184 + buff:createAfter(layer)
165 185 end
166 186 self:triggerPassive(Passive.GET_BUFF, {trigger = releaser, buffId = buffId})
167 187 self:triggerPassive(Passive.PLAYER_BUFF_CLASSIFY, {trigger = releaser, classify = buffData.classify})
  188 + self:attrChangeCondBuffCheck(2, buffId)
168 189 return true
169 190 end
170 191  
... ... @@ -217,6 +238,44 @@ end
217 238 function BaseObject:reSetSpMax()
218 239 end
219 240  
  241 +function BaseObject:checkAuraBuff(buffs)
  242 +end
  243 +
  244 +function BaseObject:getAuras()
  245 + local disable = self:getDisableAuraCount()
  246 + local auras = {}
  247 + local function addAura(one)
  248 + if disable > 0 then
  249 + disable = disable - 1
  250 + else
  251 + table.insert(auras, one)
  252 + end
  253 + end
  254 + if self:is("Enemy") then
  255 + local halo = csvdb["event_monsterCsv"][self.monsterId].halo
  256 + if halo then
  257 + for _, one in ipairs(halo:toArray(true, "=")) do
  258 + addAura(one)
  259 + end
  260 + end
  261 + elseif self:is("Build") then
  262 + local halo = csvdb["event_buildingCsv"][self.id].halo
  263 + if halo then
  264 + for _, one in ipairs(halo:toArray(true, "=")) do
  265 + addAura(one)
  266 + end
  267 + end
  268 + end
  269 +
  270 + for _, buff in ipairs(self.buffs) do
  271 + if not buff:isHide() and buff:getType() == Buff.GET_AURA then
  272 + addAura(buff:effect())
  273 + end
  274 + end
  275 +
  276 + return auras
  277 +end
  278 +
220 279  
221 280 -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类
222 281 function BaseObject:getCommonBuffEffect(bType, otherCond)
... ... @@ -417,7 +476,7 @@ function BaseObject:hurt(value, releaser, params)
417 476 if self.hp == 0 then
418 477 self:triggerPassive(Passive.SELF_DEAD)
419 478 for _, team in ipairs(self:getTeam(1, true)) do
420   - team:triggerPassive(Passive.TEAM_DEAD)
  479 + team:triggerPassive(Passive.TEAM_DEAD, {trigger = self})
421 480 end
422 481  
423 482 if (params.hurtType == 6 or params.hurtType == 2) and self ~= self.battle.player then
... ... @@ -505,6 +564,50 @@ function BaseObject:getTeam(nType, noSelf, mapIdx, includeLock)
505 564 return team
506 565 end
507 566  
  567 +function BaseObject:attrChangeCondBuffCheck(etype, cond)
  568 + local effect = {}
  569 + if etype == 3 then
  570 + if type(cond) ~= "string" then
  571 + return
  572 + end
  573 + local temp = cond:toArray(true, " ")
  574 + cond = {}
  575 + for _, one in pairs(temp) do
  576 + cond[one] = 1
  577 + end
  578 + elseif etype == 4 then
  579 + if not cond then
  580 + cond = {}
  581 + end
  582 + if type(cond) == "number" then
  583 + cond = {[cond] = 1}
  584 + end
  585 + end
  586 + for _, buff in ipairs(self.buffs) do
  587 + if not buff:isHide() and (buff:getType() == Buff.ATTR_CHANGE_COND) then
  588 + local _et, _attr, _co = buff:getEffectBy()
  589 + if etype == _et then
  590 + if etype == 3 or etype == 4 then
  591 + if cond[_co] then
  592 + effect[_attr] = 1
  593 + end
  594 + else
  595 + if (not _co or _co == cond) then
  596 + effect[_attr] = 1
  597 + end
  598 + end
  599 + end
  600 + end
  601 + end
  602 + for attrName, _ in pairs(effect) do
  603 + if attrName == "hp" then
  604 + self:reSetHpMax()
  605 + else
  606 + self:reSetAttr(attrName)
  607 + end
  608 + end
  609 +end
  610 +
508 611 function BaseObject:getDB()
509 612 local db = {}
510 613 db.hp = self.hp
... ... @@ -557,6 +660,51 @@ function Enemy:isEnemy()
557 660 return true
558 661 end
559 662  
  663 +function Enemy:getObstacle()
  664 + local obstacle = csvdb["event_monsterCsv"][self.monsterId].obstacle
  665 + if obstacle == 0 and self:hadBuff(Buff.OBSTACLE_CHANGE) then
  666 + obstacle = 1
  667 + end
  668 + return obstacle
  669 +end
  670 +
  671 +function Enemy:isClassify(check)
  672 + local classify = self:getClassify()
  673 + return classify and classify:sismember(check, " ")
  674 +end
  675 +
  676 +function Enemy:getClassify()
  677 + return csvdb["event_monsterCsv"][self.monsterId].classify
  678 +end
  679 +
  680 +-- 0=所有 1=怪物 2=玩家
  681 +function Enemy:checkAuraBuff(buffs)
  682 + local needBuffs = {}
  683 +
  684 + for buffId, info in pairs(buffs[0] or {}) do
  685 + needBuffs[buffId] = needBuffs[buffId] or {}
  686 + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  687 + needBuffs[buffId].exist = info.exist
  688 + end
  689 +
  690 + for buffId, info in pairs(buffs[1] or {}) do
  691 + needBuffs[buffId] = needBuffs[buffId] or {}
  692 + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  693 + needBuffs[buffId].exist = info.exist
  694 + end
  695 +
  696 + for buffId, info in pairs(needBuffs) do
  697 + if info.count < 0 then
  698 + local buff = self:getBuffById(buffId)
  699 + if buff then
  700 + buff:uncover(info.exist and -info.count or -1, true)
  701 + end
  702 + elseif info.count > 0 then
  703 + self:addBuff(buffId, nil, info.count)
  704 + end
  705 + end
  706 +end
  707 +
560 708 function Enemy:kill()
561 709 self:hurt(self.hp, self.battle.player, {hurtType = 5})
562 710 end
... ... @@ -569,44 +717,44 @@ end
569 717  
570 718 function Player:initData(data)
571 719 Player.super.initData(self, data)
572   - self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr
  720 + -- self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr
573 721 self.growth = data.growth
574   - self.exp = data.exp or 0
  722 + -- self.exp = data.exp or 0
575 723 self.sp = data.sp or 100
576 724 self.spMax = data.spMax or 100
577 725 self._spMax = data._spMax or 100
578 726 end
579 727  
580   -function Player:addExp(value)
581   - -- buff 经验加成
582   - local up = self:getCommonBuffEffect(Buff.EXP_UP)
583   - value = math.ceil((value + up[0]) * (1 + up[1]))
584   -
585   - if value <= 0 then return end
586   - local newExp = self.exp + value
587   - local level = self.level
588   - if level >= #csvdb["adv_levelCsv"] then return end
589   - while true do
590   - local curData = csvdb["adv_levelCsv"][level]
591   - if newExp < curData.exp then break end
592   - level = level + 1
593   - newExp = newExp - curData.exp
594   - if level >= #csvdb["adv_levelCsv"] then break end
595   - end
596   - local delta = level - self.level
597   -
598   - self.battle.adv:pushBackEvent(AdvBackEventType.Exp, {delta = value})
599   -
600   - if delta > 0 then
601   - for attr, _ in pairs(AdvAttsEnum) do
602   - self:addBaseAttr(attr, self.growth[attr] * delta, 0, true)
603   - end
604   - self.battle.adv:pushBackEvent(AdvBackEventType.Level, {level = level, delta = delta})
605   - end
606   - self.level = level
607   - self.exp = newExp
608   - return value
609   -end
  728 +-- function Player:addExp(value)
  729 +-- -- buff 经验加成
  730 +-- local up = self:getCommonBuffEffect(Buff.EXP_UP)
  731 +-- value = math.ceil((value + up[0]) * (1 + up[1]))
  732 +
  733 +-- if value <= 0 then return end
  734 +-- local newExp = self.exp + value
  735 +-- local level = self.level
  736 +-- if level >= #csvdb["adv_levelCsv"] then return end
  737 +-- while true do
  738 +-- local curData = csvdb["adv_levelCsv"][level]
  739 +-- if newExp < curData.exp then break end
  740 +-- level = level + 1
  741 +-- newExp = newExp - curData.exp
  742 +-- if level >= #csvdb["adv_levelCsv"] then break end
  743 +-- end
  744 +-- local delta = level - self.level
  745 +
  746 +-- self.battle.adv:pushBackEvent(AdvBackEventType.Exp, {delta = value})
  747 +
  748 +-- if delta > 0 then
  749 +-- for attr, _ in pairs(AdvAttsEnum) do
  750 +-- self:addBaseAttr(attr, self.growth[attr] * delta, 0, true)
  751 +-- end
  752 +-- self.battle.adv:pushBackEvent(AdvBackEventType.Level, {level = level, delta = delta})
  753 +-- end
  754 +-- self.level = level
  755 +-- self.exp = newExp
  756 +-- return value
  757 +-- end
610 758 --vtype 0/1 值/%
611 759 function Player:addBaseAttr(attr, value, vtype, ignoreBack)
612 760 local attrName = attr
... ... @@ -696,7 +844,6 @@ end
696 844 function Player:addBuff(buffId, releaser)
697 845 local status = Player.super.addBuff(self, buffId, releaser)
698 846 if status then
699   - self.battle.player:attrChangeCondBuffCheck(2, buffId)
700 847 self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId)
701 848 self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId})
702 849 self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId})
... ... @@ -707,23 +854,30 @@ function Player:addBuff(buffId, releaser)
707 854 end
708 855 return status
709 856 end
  857 +-- 0=所有 1=怪物 2=玩家
  858 +function Player:checkAuraBuff(buffs)
  859 + local needBuffs = {}
710 860  
711   -function Player:attrChangeCondBuffCheck(etype, cond)
712   - local effect = {}
713   - for _, buff in ipairs(self.buffs) do
714   - if not buff:isHide() and (buff:getType() == Buff.ATTR_CHANGE_COND) then
715   - local _et, _attr, _co = buff:getEffectBy()
716   - if etype == _et and (not _co or _co == cond) then
717   - effect[_attr] = 1
718   - end
719   -
720   - end
  861 + for buffId, info in pairs(buffs[0] or {}) do
  862 + needBuffs[buffId] = needBuffs[buffId] or {}
  863 + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  864 + needBuffs[buffId].exist = info.exist
721 865 end
722   - for attrName, _ in pairs(effect) do
723   - if attrName == "hp" then
724   - self:reSetHpMax()
725   - else
726   - self:reSetAttr(attrName)
  866 +
  867 + for buffId, info in pairs(buffs[2] or {}) do
  868 + needBuffs[buffId] = needBuffs[buffId] or {}
  869 + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  870 + needBuffs[buffId].exist = info.exist
  871 + end
  872 +
  873 + for buffId, info in pairs(needBuffs) do
  874 + if info.count < 0 then
  875 + local buff = self:getBuffById(buffId)
  876 + if buff then
  877 + buff:uncover(info.exist and -info.count or -1, true)
  878 + end
  879 + elseif info.count > 0 then
  880 + self:addBuff(buffId, nil, info.count)
727 881 end
728 882 end
729 883 end
... ... @@ -734,7 +888,8 @@ end
734 888  
735 889 function Player:getDB()
736 890 local db = Player.super.getDB(self)
737   - for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do
  891 + -- for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do
  892 + for _ , field in pairs({"level", "growth", "sp", "spMax"}) do
738 893 db[field] = self[field]
739 894 end
740 895 db["_spMax"] = self._spMax
... ...
1   -Subproject commit 02a9bbbb10bb99a91cc5d67f62dc7e5b49d8cb46
  1 +Subproject commit 897a3e0e4afa8217614a9ecf199d54b0ca641bab
... ...
src/models/Activity.lua
... ... @@ -19,6 +19,11 @@ Activity.ActivityType = {
19 19 AdvDraw = 13, --拾荒抽周 资助
20 20 OpenBox = 14, --拆解周 时钟箱
21 21 RaceDraw = 16, -- 定向招募活动
  22 +
  23 + ChallengeLevel = 17, -- 挑战关卡活动
  24 + Exchange = 18, -- 兑换活动
  25 + HangDrop = 19, -- 挂机掉落活动
  26 + Gachakon = 20, -- 扭蛋活动
22 27 }
23 28  
24 29  
... ... @@ -48,6 +53,11 @@ Activity.schema = {
48 53 act12 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励
49 54 act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励
50 55 act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励
  56 +
  57 + act20 = {"table", {}, true}, -- {id=兑换数量}
  58 + act21 = {"table", {}}, -- {id=抽取的数量}
  59 + act22 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害}
  60 + act23 = {"table", {}}, -- {挂机信息}
51 61 }
52 62  
53 63 function Activity:data()
... ... @@ -409,12 +419,34 @@ activityFunc[Activity.ActivityType.CalendaTask] = {
409 419 -- end,
410 420 }
411 421  
  422 +-- 兑换
  423 +activityFunc[Activity.ActivityType.Exchange] = {
  424 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  425 + local role = self.owner
  426 + local actData = self:getActData(actType) or {}
  427 + actData[actId] = {}
  428 + self:updateActData(actType, actData, not notify)
  429 + end,
  430 + --["close"] = function(self, actType, notify, actId)
  431 + --end,
  432 +}
  433 +
  434 +-- 扭蛋机
  435 +activityFunc[Activity.ActivityType.Gachakon] = {
  436 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  437 + self:updateActData(actType, {}, not notify)
  438 + end,
  439 + ["crossDay"] = function(self, actType, notify)
  440 + self:updateActData(actType, {}, not notify)
  441 + end,
  442 +}
  443 +
412 444 function Activity:initActivity(actId, isCrossDay, notify)
413 445 local actData = csvdb["activity_ctrlCsv"][actId]
414 446 if not actData then return end
415 447 local actType = actData.showType
416 448 if activityFunc[actType] and activityFunc[actType]['close'] then
417   - activityFunc[actType]["init"](self, actType, isCrossDay, notify)
  449 + activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId)
418 450 end
419 451 end
420 452  
... ... @@ -423,7 +455,8 @@ function Activity:closeActivity(actId, notify, notUpdateAct)
423 455 if not actData then return end
424 456 local actType = actData.showType
425 457 if activityFunc[actType] and activityFunc[actType]['close'] then
426   - activityFunc[actType]["close"](self, actType, notify)
  458 + activityFunc[actType]["close"](self, actType, notify, actId)
  459 + self:recycleActItem(actId)
427 460 end
428 461 if Activity.schema["act".. actType] then
429 462 self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct)
... ... @@ -529,5 +562,33 @@ function Activity:getPaySignReward()
529 562 --SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change)))
530 563 end
531 564  
  565 +-- 回收活动道具
  566 +function Activity:recycleActItem(actId)
  567 + local role = self.owner
  568 + local actCfg = csvdb["activity_ctrlCsv"][actId]
  569 + if not actCfg then return end
  570 + local gift = {}
  571 + local costs = {}
  572 + for _, arr in ipairs(role:getItemCount(actCfg.recycle):toTableArray(true)) do
  573 + local fromId, toId, toNum = arr[1], arr[2], arr[3]
  574 + local itemCount = role:getItemCount(fromId)
  575 + if itemCount > 0 then
  576 + costs[fromId] = (costs[fromId] or 0) + itemCount
  577 + gift[toId] = toNum * itemCount
  578 + end
  579 + end
  580 + if next(costs) then
  581 + local itemStr = ""
  582 + for k, v in pairs(costs) do
  583 + if itemStr ~= "" then
  584 + itemStr = itemStr .. " "
  585 + end
  586 + itemStr = itemStr .. k .. "=" .. v
  587 + end
  588 + role:costItems(costs, {log = {desc = "actRecycle"}})
  589 + role:sendMail(actCfg.recycle_email, nil, gift, {itemStr})
  590 + end
  591 +end
  592 +
532 593  
533 594 return Activity
... ...
src/models/Email.lua
... ... @@ -48,10 +48,10 @@ function Email:data()
48 48  
49 49 if emailData then
50 50 -- 如果内容是直接插入到数据库
51   - if content == "" and emailData.body ~= "" then
52   - content = io.readfile("src/" .. emailData.body) or ""
53   - content = content:format(table.unpack(contentPms))
54   - end
  51 + --if content == "" and emailData.body ~= "" then
  52 + -- content = io.readfile("src/" .. emailData.body) or ""
  53 + -- content = content:format(table.unpack(contentPms))
  54 + --end
55 55  
56 56 if title == "" and emailData.title ~= "" then
57 57 title = emailData.title
... ... @@ -67,12 +67,14 @@ function Email:data()
67 67 end
68 68  
69 69 return {
  70 + cfgId = emailId,
70 71 id = self:getProperty("id"),
71 72 status = self:getProperty("status"),
72 73 createtime = self:getProperty("createtime"),
73 74 title = title,
74 75 stitle = stitle,
75 76 content = content,
  77 + contentPms = contentPms,
76 78 attachments = attachments,
77 79 }
78 80 end
... ...
src/models/Hero.lua
... ... @@ -15,6 +15,7 @@ Hero.schema = {
15 15 -- loveL = {"number", 0}, --好感度等级
16 16 equip = {"string",""}, --装备 type=level
17 17 rune = {"string",""}, --零件 type=id
  18 + faith = {"number", 0}, -- 信赖
18 19 }
19 20  
20 21 function Hero:ctor( properties )
... ... @@ -102,6 +103,7 @@ function Hero:data()
102 103 -- loveL = self:getProperty("loveL"),
103 104 equip = self:getProperty("equip"),
104 105 rune = self:getProperty("rune"),
  106 + faith = self:getProperty("faith")
105 107 }
106 108 end
107 109  
... ... @@ -113,4 +115,8 @@ function Hero:getRare()
113 115 return csvdb["unitCsv"][self:getProperty("type")].rare
114 116 end
115 117  
  118 +function Hero:getPosition()
  119 + return csvdb["unitCsv"][self:getProperty("type")].position
  120 +end
  121 +
116 122 return Hero
117 123 \ No newline at end of file
... ...
src/models/HeroPlugin.lua
... ... @@ -48,30 +48,29 @@ function HeroPlugin.bind(Hero)
48 48 local breakL = params.breakL or self:getProperty("breakL")
49 49 local wakeL = params.wakeL or self:getProperty("wakeL")
50 50 local talent = params.talent or self:getProperty("talent")
51   -
  51 + local heroCfgId = self:getProperty("type")
52 52 --天赋
53 53 local talentAttrS = {}
54 54  
55 55 -- 四个基础属性
56 56 local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)]
  57 + local curTalentLvl = 0
57 58 if not curData then -- 已经满阶段了
58   - curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]]
59   - local strength = curData[#curData].strength
60   - for i = 1, 4 do
61   - talentAttrS[TalentAttsEnumEx[i]] = (talentAttrS[TalentAttsEnumEx[i]] or 0) + strength
62   - end
  59 + local cfgName = "unit_talent_"..heroCfgId.."Csv"
  60 + curData = csvdb[cfgName][#csvdb[cfgName]]
63 61 else
64   - for i = 1, 4 do --4个天赋
65   - talentAttrS[TalentAttsEnumEx[i]] = (talentAttrS[TalentAttsEnumEx[i]] or 0) + curData[talent:getv(i, 0)].strength
66   - end
  62 + curTalentLvl = talent:getv(1, 1)
67 63 end
68   - --阶段属性
69   - for i = 1, (talent:getv(0, 1) - 1) do
70   - local curData = csvdb["unit_talentCsv"][i]
71   - local effect = curData[#curData].effect:toArray(true, "=")
72   - talentAttrS[AttsEnumEx[effect[1]]] = (talentAttrS[AttsEnumEx[effect[1]]] or 0) + effect[2]
  64 + for lvl, cfg in pairs(curData) do
  65 + if lvl < curTalentLvl or curTalentLvl == 0 then
  66 + if cfg.effect ~= 99 then
  67 + local curVal = talentAttrS[cfg.effect] or 0
  68 + if curVal < cfg.strength then
  69 + talentAttrS[cfg.effect] = cfg.strength
  70 + end
  71 + end
  72 + end
73 73 end
74   -
75 74  
76 75 for _, attrName in pairs(AttsEnumEx) do
77 76 if talentAttrS[attrName] then
... ... @@ -79,6 +78,22 @@ function HeroPlugin.bind(Hero)
79 78 end
80 79 end
81 80  
  81 + -- 信赖属性
  82 + local faithAttr = {}
  83 + local faith = self:getProperty("faith")
  84 + local faithConfig = csvdb["unit_trustCsv"]
  85 + for lvl = 1, #faithConfig do
  86 + if faith >= faithConfig[lvl].exp then
  87 + local add = faithConfig[lvl]["position_"..unitData.position]:toArray(true, "=")
  88 + faithAttr[add[1]] = (faithAttr[add[1]] or 0) + add[2]
  89 + end
  90 + end
  91 + for _, attrName in pairs(AttsEnumEx) do
  92 + if faithAttr[attrName] then
  93 + faithAttr[attrName] = addAttr(unitData[attrName], faithAttr[attrName], 1, attrName)
  94 + end
  95 + end
  96 +
82 97 local attrs = {}
83 98 for _, attName in pairs(AttsEnumEx) do
84 99 attrs[attName] = unitData[attName] or 0
... ... @@ -90,7 +105,7 @@ function HeroPlugin.bind(Hero)
90 105 for attr, value in pairs(attrs) do
91 106 attrs[attr] = attrs[attr] + addAttr(attrs[attr], lData[attr .. "Level"], 1, attr)
92 107 attrs[attr] = attrs[attr] + addAttr(attrs[attr], blData[attr .. "Level"], 1, attr)
93   - attrs[attr] = attrs[attr] + addAttr(attrs[attr], wData[attr .. "Level"], 1, attr) + (talentAttrS[attr] or 0)
  108 + attrs[attr] = attrs[attr] + addAttr(attrs[attr], wData[attr .. "Level"], 1, attr) + (talentAttrS[attr] or 0) + (faithAttr[attr] or 0)
94 109 end
95 110  
96 111 return attrs
... ... @@ -237,6 +252,37 @@ function HeroPlugin.bind(Hero)
237 252 return level
238 253 end
239 254  
  255 + -- 天赋获得的技能
  256 + function Hero:getTalentSkill()
  257 + local TalentEnum = {
  258 + [1] = 1, -- 血量
  259 + [2] = 2, -- 攻击
  260 + [3] = 3, -- 物理防御
  261 + [4] = 4, -- 命中
  262 + [5] = 5, -- 闪避
  263 + }
  264 + local talentCsv = csvdb["unit_talent_" .. self:getProperty("type") .. "Csv"]
  265 + local curLv = self:getProperty("talent"):getv(1,1) - 1
  266 + local curRan = self:getProperty("talent"):getv(0,1)
  267 + local skills = {}
  268 + for ran, data in ipairs(talentCsv) do
  269 + if ran <= curRan then
  270 + for lv, value in ipairs(data) do
  271 + if ran < curRan or lv <= curLv then
  272 + if not TalentEnum[value.effect] then
  273 + skills[value.strength] = true
  274 + end
  275 + else
  276 + break
  277 + end
  278 + end
  279 + else
  280 + break
  281 + end
  282 + end
  283 + return skills
  284 + end
  285 +
240 286 function Hero:getSkillData(idx)
241 287 local unitData = csvdb["unitCsv"][self:getProperty("type")]
242 288 if idx == 1 then
... ... @@ -296,6 +342,27 @@ function HeroPlugin.bind(Hero)
296 342 end
297 343 return
298 344 end
  345 +
  346 + -- 添加英雄信赖
  347 + function Hero:addHeroFaith(exp)
  348 + local faith = self:getProperty("faith")
  349 + local config = csvdb["unit_trustCsv"]
  350 + local star = self:getProperty("wakeL")
  351 + local tmpExp = faith + exp
  352 + for lvl = 1, #config do
  353 + if star < config[lvl].star then
  354 + break
  355 + end
  356 + if tmpExp < config[lvl].exp then
  357 + faith = tmpExp
  358 + break
  359 + else
  360 + faith = config[lvl].exp
  361 + end
  362 + end
  363 + self:setProperty("faith", faith)
  364 + end
  365 +
299 366 end
300 367  
301 368  
... ...
src/models/Role.lua
... ... @@ -99,11 +99,11 @@ Role.schema = {
99 99 advLimit = {"table", {}}, -- 冒险事件每次的limit
100 100 advC = {"number", 0}, -- 冒险次数(消耗体力)
101 101 advCT = {"number", 0}, -- 冒险次数 上次恢复时间
102   -
  102 + advMine = {"table", {}}, -- -- {1 = {ch = 0, co = {id = count}}, 2 = {ch = 0, co = {id = count}}} 宝藏怪刷出概率 1 宝藏怪 2 宝藏洞 ch 概率 co 不同id 次数记录
  103 +
103 104 --挂机相关
104 105 hangPass = {"table", {}}, -- 挂机通过的最大关卡
105 106 hangGift = {"table", {}}, -- 挂机奖励 {id = 1}
106   - hangTeam = {"table", {}}, -- 挂机队伍
107 107 hangTS = {"table", {}}, -- 挂机队伍他人可读的队伍信息
108 108 hangTB = {"table", {}}, -- 挂机队伍他人可用的战斗信息mao
109 109 hangTBV = {"number", 0}, -- 挂机队伍他人可用的战斗力
... ... @@ -111,8 +111,11 @@ Role.schema = {
111 111 hangInfo = {"table", {}}, -- 当前挂机信息
112 112 hangBag = {"table", {}}, -- 背包
113 113 hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限
114   - bTeam = {"table", {}}, -- 奖励副本队伍
115   - heroFormate = {"table", {}}, -- 自选编队 {adv={}, hang={}}
  114 + hangTeams = {"table", {}}, -- pve自选编队
  115 + teamIndex = {"table", {}}, -- 各个系统使用的编队索引 type->index 见TeamSystemType
  116 + advTeams = {"table", {}}, -- 拾荒自选编队
  117 +
  118 + bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1
116 119  
117 120 --引导相关
118 121 newerGuide = {"string","1=1"}, -- 新手引导 master=slave
... ... @@ -143,7 +146,6 @@ Role.schema = {
143 146 boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}}
144 147  
145 148 towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey}
146   - towerF = {"table", {}}, -- 爬塔阵容
147 149  
148 150 spTask = {"table", {}}, -- 特殊任务 -- {id = status}
149 151  
... ... @@ -166,7 +168,8 @@ Role.schema = {
166 168 repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次
167 169 floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count}
168 170 ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count}
169   - newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr
  171 + newerDraw = {"number", 0}, -- 新手池子抽卡次数
  172 + wishPool = {"table", {}}, -- 心愿池子
170 173  
171 174 sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况
172 175 sign = {"table", {}}, -- 签到记录 {[1] = 20181029}
... ... @@ -179,6 +182,7 @@ Role.schema = {
179 182 feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数
180 183  
181 184 calTask = {"table", {}}, -- 英雄令活动 日历任务活动
  185 + radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv
182 186 }
183 187  
184 188  
... ... @@ -354,11 +358,14 @@ function Role:data()
354 358  
355 359 hangPass = self:getProperty("hangPass"),
356 360 hangGift = self:getProperty("hangGift"),
357   - hangTeam = self:getProperty("hangTeam"),
358 361 hangInfo = self:getProperty("hangInfo"),
359 362 hangBag = self:getProperty("hangBag"),
360 363 hangBagLimit = self:getProperty("hangBagLimit"),
361   - bTeam = self:getProperty("bTeam"),
  364 + hangTeams = self:getProperty("hangTeams"),
  365 + teamIndex = self:getProperty("teamIndex"),
  366 + advTeams = self:getProperty("advTeams"),
  367 +
  368 + bonusStar = self:getProperty("bonusStar"),
362 369  
363 370 newerGuide = self:getProperty("newerGuide"),
364 371 funcGuide = self:getProperty("funcGuide"),
... ... @@ -374,7 +381,6 @@ function Role:data()
374 381 equips = self:getProperty("equips"),
375 382 boxL = self:getProperty("boxL"),
376 383 towerInfo = self:getProperty("towerInfo"),
377   - towerF = self:getProperty("towerF"),
378 384 spTask = self:getProperty("spTask"),
379 385 dTask = self:getProperty("dTask"),
380 386 wTask = self:getProperty("wTask"),
... ... @@ -390,6 +396,7 @@ function Role:data()
390 396 repayHero = self:getProperty("repayHero"),
391 397 newerDraw = self:getProperty("newerDraw"),
392 398 floorHero = self:getProperty("floorHero"),
  399 + wishPool = self:getProperty("wishPool"),
393 400  
394 401 sudoku = self:getProperty("sudoku"),
395 402 sign = self:getProperty("sign"),
... ... @@ -401,6 +408,7 @@ function Role:data()
401 408 feedback = self:getProperty("feedback"),
402 409 ctime = self:getProperty("ctime"),
403 410 calTask = self:getProperty("calTask"),
  411 + radioTask = self:getProperty("radioTask"),
404 412 }
405 413 end
406 414  
... ...
src/models/RoleBattle.lua
... ... @@ -57,7 +57,7 @@ function Role:checkBattle(battleType, params)
57 57 end
58 58 end,
59 59 tower = function()
60   - local towerF = self:getProperty("towerF")
  60 + local towerF = self:getTeamFormatByType(TeamSystemType.Tower)
61 61 for slot, hero in pairs(self:getTeamHerosInfo(towerF.heros)) do
62 62 selflist[slot] = hero.type
63 63 end
... ... @@ -72,7 +72,7 @@ function Role:checkBattle(battleType, params)
72 72 end
73 73 end,
74 74 bonus = function()
75   - local bTeam = self:getProperty("bTeam")
  75 + local bTeam = self:getTeamFormatByType(TeamSystemType.BonusBattle)
76 76 for slot, hero in pairs(self:getTeamHerosInfo(bTeam.heros)) do
77 77 selflist[slot] = hero.type
78 78 end
... ...
src/models/RoleLog.lua
... ... @@ -42,6 +42,10 @@ local ItemReason = {
42 42 freeGift = 127, -- 免费礼包
43 43 exploreCommand = 128, -- 探索指令
44 44 drawHeroExtraReward = 129, -- 抽卡阶段奖励
  45 + actRecycle = 130, -- 活动道具回收
  46 + actExchange = 131, -- 兑换活动
  47 + actGachakon = 132, -- 扭蛋活动
  48 + totalRecharge = 133, -- 累计充值奖励
45 49  
46 50  
47 51 advHang = 301, -- 拾荒挂机
... ... @@ -107,6 +111,8 @@ local ItemReason = {
107 111 unlockPool = 1208, -- 解锁英雄定向抽卡池
108 112 downloadCv = 1209, -- 下载 cv包奖励
109 113 refer = 1210, -- 穿戴
  114 + itemCompose = 1211, -- 天赋道具合成
  115 + radioQuest = 1212, -- 电台任务奖励
110 116  
111 117 -- pvp
112 118 pvpCHead = 1301, -- pvp 跨服竞技场头像
... ...
src/models/RolePlugin.lua
1 1  
2   -
  2 +local serverId = tonumber(skynet.getenv("servId"))
3 3 local RolePlugin = {}
4 4  
5 5 function RolePlugin.bind(Role)
... ... @@ -64,6 +64,9 @@ function RolePlugin.bind(Role)
64 64 [ItemId.PlayerExp] = function()
65 65 self:addPlayExp(count, pms)
66 66 end,
  67 + [ItemId.AdvPower] = function()
  68 + self:changeAdvCount(-count)
  69 + end,
67 70 }
68 71  
69 72 local itemTypeAward = {
... ... @@ -1132,7 +1135,7 @@ function RolePlugin.bind(Role)
1132 1135 local now = skynet.timex()
1133 1136 local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年
1134 1137 local ct = 10000 - ct -- 越早的排名越靠前
1135   - local towerTeam = self:getProperty("towerF")
  1138 + local towerTeam = self:getTeamFormatByType(TeamSystemType.Tower)
1136 1139 local battleV = self:getTeamBattleValue(towerTeam.heros)
1137 1140 local score = (level * 10000 + ct) * 10000000 + battleV
1138 1141  
... ... @@ -1279,11 +1282,13 @@ function RolePlugin.bind(Role)
1279 1282 info.specialLevel = hero:getSkillLevel(1)
1280 1283 info.passiveLevel = hero:getSkillLevel(3)
1281 1284 info.runeSkill = hero:getRuneSkill(102)
  1285 + info.talentSkills = hero:getTalentSkill()
1282 1286 teamInfo.heros[slot] = info
1283 1287 end
1284 1288 for slot, id in pairs(team.supports or {}) do
1285 1289 teamInfo.supports[slot] = {id, self.dinerData:getProperty("dishTree"):getv(id, 0)}
1286 1290 end
  1291 + teamInfo.tactics = globalCsv.tactics_skill_passive_cell[team.tactics] and team.tactics or nil
1287 1292 return teamInfo
1288 1293 end
1289 1294  
... ... @@ -1310,13 +1315,10 @@ function RolePlugin.bind(Role)
1310 1315 return self:getRealBattleValue(heros)
1311 1316 end
1312 1317  
1313   - -- 不传参数 只修改保存的阵容信息
1314   - function Role:saveHangTeam(team)
1315   - if not team then
1316   - team = self:getProperty("hangTeam")
1317   - else
1318   - self:updateProperty({field = "hangTeam", value = team})
1319   - end
  1318 + function Role:updateHangTeamInfo()
  1319 + local team = self:getTeamFormatByType(TeamSystemType.Hang)
  1320 + if not team then return end
  1321 +
1320 1322 self:setProperties({
1321 1323 hangTS = self:getTeamHerosInfo(team.heros),
1322 1324 hangTB = self:getTeamBattleInfo(team),
... ... @@ -1324,6 +1326,41 @@ function RolePlugin.bind(Role)
1324 1326 })
1325 1327 end
1326 1328  
  1329 + -- 设置pve阵容
  1330 + function Role:getTeamFormat(index)
  1331 + local teams = self:getProperty("hangTeams") or {}
  1332 + local team = teams[index] or {}
  1333 + return team
  1334 + end
  1335 +
  1336 + function Role:getTeamFormatByType(type)
  1337 + local teamIndex = self:getProperty("teamIndex") or {}
  1338 + local index = teamIndex[type]
  1339 + if not index then return {} end
  1340 +
  1341 + return self:getTeamFormat(index)
  1342 + end
  1343 +
  1344 + function Role:setTeamFormat(index, team)
  1345 + local teams = self:getProperty("hangTeams") or {}
  1346 + teams[index] = team
  1347 + self:updateProperty({field = "hangTeams", value = teams, notNotify = false})
  1348 + end
  1349 +
  1350 + -- 设置拾荒编队阵容
  1351 + function Role:getAdvTeamFormat(index)
  1352 + local teams = self:getProperty("advTeams") or {}
  1353 + local team = teams[index] or {}
  1354 + return team
  1355 + end
  1356 +
  1357 + function Role:setAdvTeamFormat(index, team)
  1358 + local teams = self:getProperty("advTeams") or {}
  1359 + teams[index] = team
  1360 + self:updateProperty({field = "advTeams", value = teams, notNotify = false})
  1361 + end
  1362 +
  1363 +
1327 1364 function Role:savePvpCTeam(team)
1328 1365 if not team then
1329 1366 team = self:getProperty("pvpTC")
... ... @@ -1497,6 +1534,102 @@ function RolePlugin.bind(Role)
1497 1534 self:updateProperty({field = "redp", value = redp})
1498 1535 end
1499 1536  
  1537 + -- 获取充值订单号
  1538 + function Role:getPurchaseOrder(rechargeId)
  1539 + local roleId = self:getProperty("id")
  1540 + local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
  1541 + if not rechargeData then
  1542 + skynet.error("recharge id not exist", rechargeId)
  1543 + return ""
  1544 + end
  1545 + local limit = rechargeData.limit
  1546 + local rechargeRecord = self:getProperty("payR") or {}
  1547 + if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then
  1548 + return ""
  1549 + end
  1550 +
  1551 + local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId)
  1552 + if orderId then
  1553 + local orderObject = require("models.Order").new({ key = string.format(R_ORDER, roleId, orderId) })
  1554 + if orderObject:load() and orderObject:getProperty("rechargeId") == rechargeId and math.abs(skynet.timex() - orderObject:getProperty("createTime")) < 5 * 60 then
  1555 + return string.format("%d_%d_%d", serverId, roleId, orderId)
  1556 + end
  1557 + end
  1558 +
  1559 + orderId = redisproxy:hincrby("autoincrement_set", "order", 1)
  1560 + local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId)
  1561 + local orderKey = string.format(R_ORDER, roleId, orderId)
  1562 + redisproxy:del(orderKey) -- 删掉可能有了
  1563 + local order = require("models.Order").new({
  1564 + key = orderKey,
  1565 + order = partnerOrderId,
  1566 + rechargeId = rechargeId,
  1567 + })
  1568 + order:create()
  1569 + -- 正在进行中的订单 缓存
  1570 + redisproxy:hset(string.format(R_ORDERS, roleId), rechargeId, orderId)
  1571 + return partnerOrderId
  1572 + end
  1573 +
  1574 + -- 更新订单信息
  1575 + --[[
  1576 +
  1577 + status
  1578 +
  1579 + success
  1580 + fail
  1581 + finsh
  1582 + unknow
  1583 +
  1584 + --]]
  1585 + function Role:updatePurchaseOrder(partnerOrderStr, platformOrder, status)
  1586 + if not partnerOrderStr then return false end
  1587 + local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)")
  1588 +
  1589 + local roleId = self:getProperty("id")
  1590 + local orderObject = require("models.Order").new({ key = string.format(R_ORDER, roleId, orderId) })
  1591 + if not orderObject:load() then
  1592 + return false
  1593 + end
  1594 +
  1595 + local rechargeId = orderObject:getProperty("rechargeId")
  1596 + local dataSet = csvdb["shop_rechargeCsv"][rechargeId]
  1597 +
  1598 + if orderObject:getProperty("finishTime") > 0 then
  1599 + return false, "finsh"
  1600 + end
  1601 +
  1602 + if platformOrder then
  1603 + orderObject:setProperty("transactionId", platformOrder)
  1604 + end
  1605 + orderObject:setProperty("status", status)
  1606 +
  1607 + -- 开始下单
  1608 + if status == "success" then
  1609 + elseif status == "fail" then
  1610 + redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId)
  1611 + elseif status == "finsh" then
  1612 + orderObject:setProperty("finishTime", skynet.time())
  1613 + redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId)
  1614 + end
  1615 +
  1616 + if status ~= "unknow" then
  1617 + self:log("setOrder", {
  1618 + order_status = ({success = 100, finsh = 200, fail = 300})[status] or 1000, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
  1619 + item_id = rechargeId, -- 道具id
  1620 + item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
  1621 + item_name = dataSet.title, -- 购买的道具名
  1622 + item_number = 1, -- 购买的道具数量
  1623 + item_level = 1, -- 购买的道具等级
  1624 + order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
  1625 + order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
  1626 + order_type = self:getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0
  1627 + order_id = platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
  1628 + })
  1629 + end
  1630 +
  1631 + return true, rechargeId
  1632 + end
1500 1633  
1501 1634 -- 充值 --
1502 1635 --[[
... ... @@ -1511,63 +1644,37 @@ function RolePlugin.bind(Role)
1511 1644 local roleId = self:getProperty("id")
1512 1645 local partnerOrderStr = params.order
1513 1646  
1514   - local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)")
1515   - local orderObject = require("models.Order").new({ key = string.format("order:%d:%d", roleId, orderId) })
1516   - if not orderObject:load() then
1517   - -- 订单不存在
1518   - skynet.error("ayncPurchaseRpc", string.format("order %s not exist", partnerOrderStr))
1519   - return
1520   - end
1521 1647  
1522   - if orderObject:getProperty("finishTime") > 0 then
1523   - -- 订单已经处理
1524   - SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" }))
  1648 + local status, back = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh")
  1649 + if not status then
  1650 + if back == "finsh" then
  1651 + -- 订单已经处理
  1652 + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" }))
  1653 + end
1525 1654 return
1526 1655 end
1527   - local rechargeId = orderObject:getProperty("rechargeId")
  1656 + local rechargeId = back
1528 1657 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
1529 1658 if rechargeData.rmb ~= tonumber(params.amount) then
1530   - skynet.error(string.format("fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
  1659 + skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
1531 1660 params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount
1532 1661 ))
1533 1662 return
1534 1663 end
1535 1664  
1536   - local order_type = self:getProperty("rmbC") > 0 and 0 or 1
1537 1665 local status, reward = self:recharge({
1538 1666 id = rechargeId,
1539 1667 transactionId = params.transactionId,
1540 1668 pay_time = params.pay_time,
1541 1669 order = partnerOrderStr,
1542 1670 })
1543   - orderObject:setProperty("finishTime", skynet.time())
1544   - orderObject:setProperty("status", "finish")
1545   -
1546   - redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr)
1547 1671  
1548 1672 if not status then
1549   - status = 200
1550   - else
1551   - status = 1000 + status
1552   - end
1553   - self:log("setOrder", {
1554   - order_status = status, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
1555   - item_id = rechargeId, -- 道具id
1556   - item_type = rechargeData.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
1557   - item_name = rechargeData.title, -- 购买的道具名
1558   - item_number = 1, -- 购买的道具数量
1559   - item_level = 1, -- 购买的道具等级
1560   - order_cost = rechargeData.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
1561   - order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
1562   - order_type = order_type, -- 订单类型,首充记录为1,否则为0
1563   - order_id = params.transactionId, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
1564   - })
1565   - if status ~= 200 then return end
1566   -
1567   - SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr,
1568   - result = "success", reward = reward}))
  1673 + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr,
  1674 + result = "success", reward = reward}))
  1675 + end
1569 1676  
1570   - return orderObject:getProperty("rechargeId")
  1677 + return rechargeId
1571 1678 end
1572 1679  
1573 1680  
... ... @@ -1575,7 +1682,7 @@ function RolePlugin.bind(Role)
1575 1682 local id = tonumber(params.id)
1576 1683 local rechargeData = csvdb["shop_rechargeCsv"][id]
1577 1684 if not rechargeData then
1578   - skynet.error("recharge id not exist", id)
  1685 + skynet.error("[recharge] recharge id not exist", id)
1579 1686 return 1
1580 1687 end
1581 1688  
... ... @@ -1600,7 +1707,7 @@ function RolePlugin.bind(Role)
1600 1707 elseif rechargeData.shop == 3 then -- 礼包商店
1601 1708 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
1602 1709 else
1603   - skynet.error("invalid recharge shop type " .. id)
  1710 + skynet.error("[recharge] invalid recharge shop type " .. id)
1604 1711 return 3
1605 1712 end
1606 1713  
... ...
src/models/RoleTask.lua
... ... @@ -33,7 +33,7 @@ local TaskType = {
33 33 HangQuick = 303, -- 快速挂机
34 34 HangBattle = 304, -- 挂机战斗 - id
35 35 HangGetGold = 305, -- 挂机获得齿轮 - count
36   - BonusPass = 306, -- 奖励副本通关 - id
  36 + BonusPass = 306, -- 奖励副本通关 - id count
37 37  
38 38 -- 冒险相关
39 39 AdvPass = 401, -- 冒险通过关 - id level score
... ... @@ -142,7 +142,7 @@ local CommonListener = {
142 142 [TaskType.GiveFriendP] = {{20, f("count")}},
143 143 [TaskType.UnionBoss] = {{21}},
144 144 [TaskType.GetFriendP] = {{22, f("count")}},
145   - [TaskType.BonusPass] = {{23}},
  145 + [TaskType.BonusPass] = {{23, f("count")}},
146 146 [TaskType.AdvStartSelf] = {{24}},
147 147 [TaskType.ShopAll] = {{25, f("count")}},
148 148 [TaskType.RuneUp] = {{26}},
... ... @@ -244,7 +244,7 @@ local CalendaTaskListener = {
244 244 func = "checkCalendaTask",
245 245 listen = {
246 246 [TaskType.DrawHero] = {{1, 1, f("count")}},
247   - [TaskType.BonusPass]= {{2, 1}},
  247 + [TaskType.BonusPass]= {{2, 1, f("count")}},
248 248 [TaskType.AdvStart]= {{3, 1}},
249 249 [TaskType.DinerLevelUp]= {{4, 2, f("level")}},
250 250 [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄
... ...
src/models/RoleTimeReset.lua
... ... @@ -17,6 +17,11 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now)
17 17 self:advRandomSupportEffect(not notify)
18 18  
19 19 self:checkExpireItem(not notify)
  20 + local advMine = self:getProperty("advMine")
  21 + if advMine[1] then
  22 + advMine[1].co = nil
  23 + end
  24 + self:setProperty("advMine", advMine)
20 25  
21 26 response.dTask = {}
22 27 response.advSup = self:getProperty("advSup")
... ... @@ -24,10 +29,16 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now)
24 29 end
25 30  
26 31 ResetFunc["CrossWeek"] = function(self, notify, response)
  32 + local advMine = self:getProperty("advMine")
  33 + if advMine[2] then
  34 + advMine[2].co = nil
  35 + end
27 36 self:setProperties({
28 37 wTask = {},
29 38 dinerS = {},
  39 + advMine = advMine,
30 40 })
  41 +
31 42 response.wTask = {}
32 43 response.dinerS = {}
33 44 end
... ...
src/models/Store.lua
... ... @@ -33,6 +33,8 @@ Store.schema = {
33 33 actGoodsFlag = {"table", {}}, -- ActGoodsType 1购买,0未购买
34 34  
35 35 bpInfo = {"table", {}}, -- battle pass 探索指令 1={flag=0 为1表示买了,br=""付费领取记录, fr=""免费领取记录},2,3,4
  36 +
  37 + totalRR = {"string", ""}, -- 累计充值奖励领取记录
36 38 }
37 39  
38 40 function Store:updateProperty(params)
... ... @@ -224,9 +226,9 @@ end
224 226  
225 227 --检测购买是否超过限制数量
226 228 function Store:checkRechargeRecord(limit, id)
227   - local rechargeRecord = self:getProperty("payR")
  229 + local rechargeRecord = self:getProperty("payR") or {}
228 230 if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then
229   - skynet.error(string.format("recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id")))
  231 + skynet.error(string.format("[recharge] recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id")))
230 232 return false
231 233 end
232 234 rechargeRecord[id] = (rechargeRecord[id] or 0) + 1
... ... @@ -464,6 +466,7 @@ function Store:data()
464 466 --packTrigger = self:getProperty("packTrigger"),
465 467 actGoodsFlag = self:getProperty("actGoodsFlag"),
466 468 bpInfo = self:getProperty("bpInfo"),
  469 + totalRR = self:getProperty("totalRR"),
467 470 }
468 471 end
469 472  
... ...